Forum Replies Created

Viewing 8 posts - 1 through 8 (of 8 total)
  • in reply to: Cannot open Swift Framework Shortcodes #55631
    Jan B
    Member
    Post count: 14

    Yes i think using composer with wordpress is not very common at the moment but in my oppinion composer in general is rising.

    I found a solution for me which suit us both.

    I put a modified wp-load.php in my root so that I can use your solution.

    It would be awesome if you could include your solution in an upcoming release of the theme 🙂

    in reply to: Cannot open Swift Framework Shortcodes #55093
    Jan B
    Member
    Post count: 14

    I have put WP in a subfolder and only wp-config.php and index.php are stored on root level. The code above detects the root level. But in my case wp-load.php is not present in there but in /cms/wp-load.php. For more information about this folder structure please read Using Composer with WordPress.

    The notice is right since wp-load.php does not check if ABSPATH is already defined. Usually wp first loads wp-load and then wp-config. I cannot think of any way to prevent this notice in my setting.

    In general we could look for wp-load.php in the root and only if it is not present, we include wp-config.php.

    This code would look like this:

    
    <?php
    if (!function_exists('sf_wp_path')) {
        function sf_wp_path()
        {
            $wp_path = "";
            if (strstr($_SERVER["SCRIPT_FILENAME"], "/wp-content/")) {
                $wp_path = preg_replace("/\/wp-content\/.*/", "", $_SERVER["SCRIPT_FILENAME"]);
            } else {
                $wp_path = preg_replace("/\/[^\/]+?\/themes\/.*/", "", $_SERVER["SCRIPT_FILENAME"]);
            }
    
            if (strpos($wp_path, 'interface.php') !== FALSE) {
                $absolute_path = __FILE__;
                $file_path = explode('wp-content', $absolute_path);
                $wp_path = $file_path[0];
            }
    
            return $wp_path;
        }
    }
    if(file_exists(sf_wp_path() . DIRECTORY_SEPARATOR . 'wp-load.php')){
        require_once(sf_wp_path() . DIRECTORY_SEPARATOR . 'wp-load.php');
    }else{
        //first load wp-config to get the ABSPATH
        require_once(sf_wp_path() . DIRECTORY_SEPARATOR . 'wp-config.php');
        //Do the WP bootstrap
        require_once(ABSPATH . DIRECTORY_SEPARATOR . 'wp-load.php');
    }
    
    in reply to: Cannot open Swift Framework Shortcodes #55083
    Jan B
    Member
    Post count: 14

    Hi Ed,

    this works with a little modification. WordPress allows it to put the whole WP core stuff in a subdirectory. Only the index.php and wp-config.php have to be on the root level. In this case – which it is in my case – there is no wp-load.php in the root. I propose to first require_once wp-config.php since this file has to be in the root in all cases. When wp-config.php is loaded you have access to the ABSPATH and thus you know the location of wp-load.php.

    My working code looks like this:

    
    <?php
    if (!function_exists('sf_wp_path')) {
        function sf_wp_path()
        {
            $wp_path = "";
            if (strstr($_SERVER["SCRIPT_FILENAME"], "/wp-content/")) {
                $wp_path = preg_replace("/\/wp-content\/.*/", "", $_SERVER["SCRIPT_FILENAME"]);
            } else {
                $wp_path = preg_replace("/\/[^\/]+?\/themes\/.*/", "", $_SERVER["SCRIPT_FILENAME"]);
            }
    
            if (strpos($wp_path, 'interface.php') !== FALSE) {
                $absolute_path = __FILE__;
                $file_path = explode('wp-content', $absolute_path);
                $wp_path = $file_path[0];
            }
    
            return $wp_path;
        }
    }
    //first load wp-config to get the ABSPATH
    require_once(sf_wp_path() . DIRECTORY_SEPARATOR . 'wp-config.php');
    //Do the WP bootstrap
    require_once(ABSPATH . DIRECTORY_SEPARATOR . 'wp-load.php');
    
    in reply to: Cannot open Swift Framework Shortcodes #54995
    Jan B
    Member
    Post count: 14

    Hi Ed,

    I actually use Neighborhood, but I guess this error is Theme-independent.

    I use Neighborhood V.1.66 on WP 3.8.1.

    in reply to: Cannot open Swift Framework Shortcodes #54839
    Jan B
    Member
    Post count: 14

    Hi Melanie,

    I tried to put all the files you mentioned (except functions.php) in my child theme but it changed nothing.

    Then I tried to include the swift-framework.php of my child theme in my child theme’s functions.php but then I got problems with includes etc

    
    Warning: include(SF_FRAMEWORK_PATH/page-builder/sf-page-builder.php): failed to open stream: No such file or directory in /content/themes/wassershop/includes/swift-framework/swift-framework.php on line 15
    
    Warning: include(SF_FRAMEWORK_PATH/page-builder/sf-page-builder.php): failed to open stream: No such file or directory in /content/themes/wassershop/includes/swift-framework/swift-framework.php on line 15
    
    [...]
    

    So maybe I need another solution?

    in reply to: Cannot open Swift Framework Shortcodes #54477
    Jan B
    Member
    Post count: 14

    Hi Melanie,
    thanks for your reply!

    I created the files as you said, but still the files from the parent theme are used.

    My Child theme looks basically like this:

    
    |-- functions.php
    |-- includes
    |   |-- swift-framework
    |       |-- sf-shortcodes
    |           |-- config.php
    |           |-- interface.php
    |-- language
    |   |-- de_DE.mo
    |   |-- de_DE.po
    |-- screenshot.png
    |-- style.css
    

    4 directories, 7 files

    in reply to: Cannot open Swift Framework Shortcodes #54254
    Jan B
    Member
    Post count: 14

    I wrote my own config.php and now it works. My only issue is now: How can I get this into my child theme so that I do not have to modify the main theme?

    <?php
        $full_path = dirname(__FILE__);
        $path_fragments = explode(DIRECTORY_SEPARATOR, $full_path);
        $theme_key = array_search('neighborhood', $path_fragments);
        $wp_content_level = $path_fragments[($theme_key - 2)]; //usually the wp-base is two levels below the theme folder
        $file_path = explode($wp_content_level, $full_path);
        $wp_path = $file_path[0];
        
        include_once($wp_path . 'wp-config.php');
        
        require_once(ABSPATH . DIRECTORY_SEPARATOR . 'wp-load.php');
    ?>
    in reply to: Cannot open Swift Framework Shortcodes #54250
    Jan B
    Member
    Post count: 14
    This reply has been marked as private.
Viewing 8 posts - 1 through 8 (of 8 total)