Digital experiences for all disciplines
New Landing › How can we help? › Themeforest Theme Support › Dante › Cannot open Swift Framework Shortcodes
New Landing › How can we help? › Themeforest Theme Support › Dante › Cannot open Swift Framework Shortcodes
- This topic has 36 replies, 8 voices, and was last updated 10 years by Swift Ideas – Ed.
-
Posted in: Dante
-
March 5, 2014 at 7:09 am #54250This reply has been marked as private.March 5, 2014 at 7:19 am #54254
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'); ?>
March 5, 2014 at 9:46 am #54338Hi, 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.
March 5, 2014 at 12:55 pm #54477Hi 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
March 6, 2014 at 9:09 am #54774Hey, 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.
March 6, 2014 at 10:09 am #54839Hi 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?
March 6, 2014 at 10:47 am #54896Seems 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!
March 6, 2014 at 2:19 pm #54993Hi 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
March 6, 2014 at 2:21 pm #54995Hi Ed,
I actually use Neighborhood, but I guess this error is Theme-independent.
I use Neighborhood V.1.66 on WP 3.8.1.
March 6, 2014 at 2:24 pm #55003Can 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
March 6, 2014 at 3:40 pm #55083Hi 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');
March 6, 2014 at 3:41 pm #55084Great! Thanks for sharing your solution
March 6, 2014 at 3:43 pm #55086Using 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
March 6, 2014 at 3:45 pm #55090The 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
March 6, 2014 at 3:48 pm #55093I 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'); }
-
Posted in: Dante
You must be logged in and have valid license to reply to this topic.