Why should I use get_template_directory() when include files?

get_template_directory() can be filtered. This can be useful when a plugin wants to interact with your theme, for example when you want to write custom plugins to extend the theme without changing it. For example: add_filter( ‘template_directory’, function( $template_dir, $template, $theme_root ) { if ( some_condition( $theme_root ) ) { return plugin_dir_path( __FILE__ ) . … Read more

can’t access some WordPress function from my plugin

First, since the if (!function_exists(‘check_admin_referer’)) echo “<h1>check_admin_referer not found</h1>”; code is working, then you’ve eliminated the issue being proper including of your Plugin sub-file. Second, all four of those functions are core WordPress functions, so you should never get a call to undefined function error for any of them. Can you post your relevant Plugin … Read more

including Zend Gdata library path error

* UPDATE * Please see at the bottom for right solution!!! One way to solve this problem is that you use ini_set to set the path to your Zend folder. I have the Zend folder in my current theme folder so i only need to tell path var what the path to my theme folder … Read more

Load content From Include File within plugin

A better solution might be to do it along the lines of /* In your main plugin file */ if ( ! defined( ‘YOUR_PLUGIN_ABSPATH’ ) ) { define( ‘YOUR_PLUGIN_ABSPATH’, dirname( __FILE__ ) ); } /* In any file of the plugin */ if( is_front_page() ) { /* adjust path if file.php is in a subfolder … Read more