What is the best practice for customizing a plugin’s JavaScript/jQuery?

If a Plugin is coded properly, it will: Use core-bundled jQuery, and any other core-bundled script, rather than bundling/using custom versions of such scripts enqueue its scripts, via wp_enqueue_script(), hooked into an appropriate hook, via an explicit function So, for such a Plugin: You won’t need to worry about customizing/overriding core-bundled scripts, since the Theme … Read more

Add class to before_widget for all widgets with a dropdown and a counter

The CSS classes are applied in the function dynamic_sidebar(). There is no specific filter for that: // Substitute HTML id and class attributes into before_widget $classname_ = ”; foreach ( (array) $wp_registered_widgets[$id][‘classname’] as $cn ) { if ( is_string($cn) ) $classname_ .= ‘_’ . $cn; elseif ( is_object($cn) ) $classname_ .= ‘_’ . get_class($cn); } … Read more

How can I see what template parts are being called for rendering the viewable page?

You can view the template part by using get_template_part($slug) It’s one of those hidden gems inside of WordPress that don’t get the attention they deserve. The get_template_part function is essentially a PHP include or require, on steroids: It already knows where your theme is located and it will look for the requested file in that … Read more

How to access certain WP functions inside custom class, in theme folder

You’re actually calling the add_meta_box() function before it’s defined, when you run this directly: \ci\wp\Metaboxes::addMetabox( ‘front_page_slide_settings’, ‘Slide settings’, ‘page’, ‘normal’, ‘high’ ); You don’t mention where you run it, but it’s too early or you run it in the front-end, where add_meta_box() is not defined. The add_meta_box() function is defined within this file: /** WordPress … Read more

The seventh parameter passed to add_submenu_page()

I was able to track this down to the culprit function add_theme_page(). There There was an additional parameter, per the codex for add_theme_page() that needed to be removed. Removing that seemed to help. function fivehundred_register_admin_menu() { add_theme_page( ‘500 Settings’, ‘500 Settings’, ‘manage_options’, ‘theme-settings’, ‘fivehundred_admin_menu’, plugins_url( ‘/ignitiondeck/images/ignitiondeck-menu.png’ ) ); } add_action( ‘admin_menu’, ‘fivehundred_register_admin_menu’ ); Fixed code … Read more

How to determine if a category is empty?

The get_term() function accepts a term id and a taxonomy slug. It returns an object that contains a “count” for that term. $obj_term = get_term(123, ‘your-taxonomy-slug’); echo $term->count; I’m not aware of any utility function that just counts posts in a particular category.