Dynamically determine URI to scripts and styles included with a class which could be added from plugin/theme/child theme/mu plugin

For plugins it is: $plugin_url = plugin_dir_url( __FILE__ ); This works even if wp-content is on a separate domain. You may get problems if your class is in a subdirectory of the plugin – you should probably make the __FILE__ a parameter for a function: public function get_plugin_url( $base = __FILE__ ) { return plugin_dir_url( … Read more

add_action outside a plugin

You add your _setup function to wp_head without priority, so it’s given priority of 20. All of the actions you are trying to remove within that function either have a higher priority (lower number), or same priority but are already in the queue ahead of yours, so when your _setup function runs, they’ve already sent … Read more

if statement parent page for child pages

If test.php is in your theme directory, try locate_template(‘test.php’) instead. If it is somewhere else, make sure that you are trying to include it properly via the path needed. Just doing include ‘test.php’ most likely makes it think that test.php is in the root directory of the site as /index.php runs the site (e.g. where … Read more

Need to override file included in parent theme

Hello you would have to edit the parent theme as there is no way to overwrite the include_once ‘bookingtable/bookingtable.php’;. So to keep edits to the parent theme minimal, the whole code can be rewritten using wordpress get_template_part() as if ( class_exists(‘rtbInit’) ) { get_template_part(‘bookingtable/bookingtable’); } This way you can then copy the file to your … Read more

Make changes in /includes/http.php update safe

Fuxia is right, you need to fix the underlying problem; however I can’t resist answering with a quick and dirty solution; and its also useful when customizing plugins. (you may also be able to protect the file by changing its owner and permissions – but I don’t know all the implications) immediately after the starting … 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