plugin dev – minimum base css specificity?

There’s no standard. CSS specificity in themes varies wildly, and I’m convinced many theme authors are not even aware of the concept given some of the CSS I’ve seen. If something is very important to the appearance of your plugin, then high specificity may be desirable, but in many cases if you’re just styling divs … Read more

flush_rewrite_rules() not working with update_option_{$option}

flush_rewrite_rules() should be called very early within the WordPress initialization. The reason is that the entpoints cannot be changed afterwards. A solution could look like this: function updateMySlugOption($old_value, $value, $option) { if( $old_value != $value ) { set_transient(‘update_slugs’, 1); } } add_action( ‘update_option_mySlug’, ‘updateMySlugOption’, 10, 3); function update_slugs() { if( get_transient(‘update_slugs’) ) { flush_rewrite_rules(); delete_transient(‘update_slugs’); … Read more

Trying to add a page template for my custom post type from a plugin, but it will not display in the template dropdown unless file is in theme

The filter hook you’re using is theme_<post type>_templates, which means that the <post type> part is dynamic and it’s the post type in which you want the custom template be added to the Template dropdown. So since the template is enabled for three post types, you would do so to add the template to the … Read more

How to find out whether a plugin is used in pages or posts?

You are looking for: is_plugin_active( string $plugin ) This function takes a string parameter that is the representation of the path to the plugin relative path in the plugins directory. So your practical implementation would look something like this: <?php if(is_plugin_active(‘elementor/elementor.php’) || is_plugin_active(‘woocommerce/woocommerce.php’)){ // Do something, remove scripts etc.. }

WP.org acceptable iframe alternative

Use JavaScript to poll for new data at an interval and update the DOM as it comes in. Downloading the complete log file at intervals would be very inefficient and quite likely consume a huge amount of bandwidth. Instead, use some server-side code to determine if new data is available and if so return that … Read more