Allow a theme to call a plugin's functions - Printable Version +- GetSimple Support Forum (http://get-simple.info/forums) +-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3) +--- Forum: Developer Discussions (http://get-simple.info/forums/forumdisplay.php?fid=8) +--- Thread: Allow a theme to call a plugin's functions (/showthread.php?tid=3637) |
Allow a theme to call a plugin's functions - michaellindahl - 2012-10-01 I am making a theme and have a plugin to add additional settings. The theme works without the plugin, the plugin just adds additional capabilities. I would rather not place plugin related functions inside the theme functions location. How can I call functions inside of the plugin/NAME/common_functions.php file inside of the Theme template.php? Sorry if there is an obvious answer, I thought I would find something in hooks but I didn't (new to developing for GetSimple). Thanks! Allow a theme to call a plugin's functions - n00dles101 - 2012-10-01 once the plugin is activated and the common_functions.php file has been included as part of the plugin, all the functions are available to your theme. Allow a theme to call a plugin's functions - michaellindahl - 2012-10-01 n00dles101 Wrote:once the plugin is activated and the common_functions.php file has been included as part of the plugin, all the functions are available to your theme. I believe that is the case but it is not working. Do I need to do anything other than just putting the common_functions.php in the folder? Link it in NAME.php? -NAME.php -NAME/common_functions.php UPDATE: Actually the problem may lie in the layout of common_functions.php, this is the skeleton of what I have: Code: <?php Allow a theme to call a plugin's functions - shawn_a - 2012-10-02 Shouldn't they always be available ? I thought the template system wasn't initialized until after plugins are loaded. You should be able to just call them. Allow a theme to call a plugin's functions - n00dles101 - 2012-10-02 in NAME.php make your you include the common_functions.php file. like this: Code: include GSPLUGINPATH.'/NAME/common_functions.php'; Allow a theme to call a plugin's functions - michaellindahl - 2012-10-02 n00dles101 Wrote:in NAME.php make your you include the common_functions.php file. like this: That's what I was thinking, however adding that gives me a "HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request". (The common_functions.php file is in plugins/NAME/common_functions.php) The permissions on it are rw-r--r-- (644). Changing to 755 didn't help. UPDATE: I found that when outputting that include statement in the template.php file I got the following: /home/username/URL.com/plugins/NAME/common_functions.php. Removing the /home/username part removed the 500 error. But this now hard codes the location in. Also the template.php file still cannot call code inside common_functions.php Update #3: Fixed it! Yay! Here is the published theme's forum post: http://get-simple.info/forum/post/31057/ |