New Landing How can we help? Themeforest Theme Support Dante Cannot open Swift Framework Shortcodes

Viewing 15 posts - 16 through 30 (of 37 total)
  • Posted in: Dante
  • #54250
    Jan B
    Member
    Post count: 14
    This reply has been marked as private.
    #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');
    ?>
    #54338
    Melanie – SUPPORT
    Member
    Post count: 11032

    Hi, since the config.php is in the server path swift-framework > sf-shortcodes, you will have to create this path in your child theme and make sure the file that calls config.php is also in your child theme.

    #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

    #54774
    Melanie – SUPPORT
    Member
    Post count: 11032

    Hey, interface.php is being called by the file

    tinymce.editor.plugin.js

    which is called by the file

    shortcodes.php (the one in the swift-frameworks folder)

    which is called by the file

    swift-framework.php

    which is called by functions.php

    Maybe you can try to get those files in your child theme as well? Functions.php cannot be copied fully, so you need to write a custom call for the swift-framework.php

    I’m pretty sure that’s how it will work, but I will forward it to a colleague to verify, maybe there’s an easier way.

    #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?

    #54896
    Melanie – SUPPORT
    Member
    Post count: 11032

    Seems my colleague assigned the thread back to me, but I don’t know the solution, so I will assign it to the developer, maybe he can help!

    #54993
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    Hi there,

    Unfortunately it’s not able to overwrite this in a child theme as of yet. What version of Dante do you have at the moment?

    – Ed

    #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.

    #55003
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    Can you try out this code:

    <?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;	
    		}
    	}
    	
    	$wp_path = sf_wp_path();
    	
    	if (strpos($wp_path, '/') !== false) {
    		require_once( $wp_path . '/wp-load.php' );
    	} else {
    		require_once( $wp_path . '\wp-load.php' );
    	}
    ?>

    If that sorts it, we’ll use it in the next update.

    Thanks,

    – Ed

    #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');
    
    #55084
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Great! Thanks for sharing your solution

    #55086
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    Using that gives me an error though:

    Notice: Constant ABSPATH already defined in /Users/Ed/Dropbox/Swift Ideas/WordPress Theme Builds/nhood/wp-load.php on line 22

    – Ed

    #55090
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    The code I posted above detects the correct path if wp-content isn’t found – so not sure why it needed modification on your part?

    – Ed

    #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');
    }
    
Viewing 15 posts - 16 through 30 (of 37 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register