is_plugin_active() returning false on active plugin

So I have the following in an include in my theme file: include_once( ABSPATH . ‘wp-admin/includes/plugin.php’ ); if ( is_plugin_active( WP_PLUGIN_DIR . ‘/woocommerce/woocommerce.php’ ) ) { $shop_id = woocommerce_get_page_id( ‘shop’ ); $shop_page = get_page( $shop_id ); } but is_plugin_active( WP_PLUGIN_DIR . ‘/woocommerce/woocommerce.php’) is returning false, despite the fact that the plugin is active. I’m wondering … Read more

Should we use get_template_part() in functions files instead of include_once?

I’m using the theme-check plugin to check my theme for errors and recommendations, I’m using get_template_part() in theme files like header.php and index.php but in functions.php I’m using include_once() theme-check is not pointing at these, it’s pointing at include_once used in a widgets.php file which is included in functions.php my question is should we use … Read more

How do I replace a function, declared inside a plugin’s class, in functions.php?

I want to modify a function in a plugin. It is declared in the plugin’s main file like this: class WCPGSK_Main { … public function wcpgsk_email_after_order_table($order) { … } } Add called from there like this: add_action( ‘woocommerce_email_after_order_table’, array($this, ‘wcpgsk_email_after_order_table’) ); I guess it would be possible to replace it if had an access to … Read more

The proper way to include/require PHP files in WordPress

I’m a new WordPress developer and recently I’ve been having problems (on multiple sites) with include_once and require_once for PHP files. If I include (get_theme_directory_uri() . ‘subdir/file’) the specified file gets included (or required, which leads to fatal errors) but if any WordPress functions are called within ‘file’ I get something similar to: ‘Call to … Read more

Difference between require, include, require_once and include_once?

In PHP: When should I use require vs. include? When should I use require_once vs. include_once? 2 26 There are require and include_once as well. So your question should be… When should I use require vs. include? When should I use require_once vs. require The answer to 1 is described here. The require() function is … Read more

Is there any way to use get_template_part() with folders?

I’m wondering if there is any way to use get_template_part() with folders? My main folder has a lot of files now because I put every re-usable element in a separate file. I’d like to put them in folders then. There is no information about that in Codex: http://codex.wordpress.org/Function_Reference/get_template_part 3 In fact you can, I have … Read more

Passing variables through locate_template

While I’ve typically used include or require on their own to save long term code maintenance I’ve started to use get_template_part and locate_template as using built in WordPress stuff is always best. My question is are you supposed to be able to pass variables through to the results of either get_template_part or locate_template? <?php $var … Read more