How To Determine If A Filter Is Called In A Sidebar/Widget Context?

On a parallel thread over on the WordPress hacks forum, someone suggested using in_the_loop() and that works some of the time, with some plugins that use either the_content and/or the_excerpt, but not all of the time with all the plugins I’ve been testing against. Likewise, I’ve now done further testing using is_main_query() and that works … Read more

Problems with autoloading classes via sp_autoload_register / maybe interfering WP-specific autoloader

There is no built-in autoloader in WordPress. But other plugins or a theme might have registered an autoloader, and depending on the order of execution these are called earlier or later than yours. Update 21. 08. 2014 This answer is no longer what I would recommend. Do use an autoloader if you need one. The … Read more

how to include other plugins css files in a shortcode?

I think you could get around this by pre-running the shortcodes on the page by applying the content filters before the header is output. This should allow any internal shortcodes run inside the included post to add any action hooks properly and thus any needed stylesheets/resources. add_action(‘wp_loaded’,’maybe_prerun_shortcodes’); function maybe_prerun_shortcodes() { if (is_page()) { global $post; … Read more

Show Woocommerce minicart widget in checkout page sidebar? And, how to make this update secure by overriding widget?

The cart widget isn’t showing because it’s configured to not show on the cart and checkout page. If you want to change that take a look at class-wc-widget-cart.php, there you find the following line: if ( is_cart() || is_checkout() ) return; Change it to: if ( is_cart() ) return; To show the widget on the … Read more

Change capability type of post type registered by plugin

@PieterGoosen is cool, and still awake like me and answering like boss. To simplify his code and make it work to this specifically without a bunch of junk on your page: /** * Pieter Goosen writes awesome code */ add_filter( ‘register_post_type_args’, ‘change_capabilities_of_the_custom_css_js_posttype’ , 10, 2 ); function change_capabilities_of_the_custom_css_js_posttype( $args, $post_type ){ // Do not filter … Read more

Run WP-CLI using PHP

Regarding the wp –info output, that makes sense. If you don’t have any packages installed (see wp package –help or a global configuration files (wp-cli.yml) then those items would be blank. You can run the wp command from any location. If you’re anywhere within your website’s folder structure it will automatically detect the site you’re … Read more