What are some examples of well-written plugins that exemplify wordpress plugin best practices? [closed]

You can buy the Professional WordPress Plugin Development book from Amazon: http://www.amazon.com/Professional-WordPress-Plugin-Development-Williams/dp/0470916222 I’m learning tons from it and it’s packed full of good information about best practices. It will walk you through building your own plugin with lots of code samples. I cannot recommend it enough. If you’re serious about learning to write plugins then … Read more

Woocommerce Product Category Widget – hide categories that have no products in stock [closed]

Use the woocommerce_product_categories_widget_args and woocommerce_get_availability filters in a custom function to filter the product categories widget for out of stock products. See what you can come up using these filters and post the code back here if you get stuck. Here’s some code from my site which may help you get started. add_filter( ‘woocommerce_product_categories_widget_args’, ‘wpsites_exclude_product_cat_widget’ … Read more

Disable author pages for specific users

I think a combination of the answers so far along with an admin area field to disable the author archive(s) is the best bet. A class to wrap everything up (along with some constants and methods that will be clear later): <?php class Author_Archive_Disabler { // meta key that will store the disabled status const … Read more

How do I only load a plugin js on it’s settings pages?

You need to use a plugin page-specific script enqueue hook. Edit Best-practice method is to use admin_enqueue_scripts-{hook}, rather than admin_print_scirpts-{hook}. But, because you’re targeting your own Plugin’s admin page specifically, either one is perfectly fine. The hook to avoid is the “global” admin_print_scripts. Original The call would look like this: /* Using registered $page handle … Read more

Generate custom output for page/URL in a plugin

<?php /* Plugin Name: Custom output Description: A module to test the custom output. To test: http://your_wordpress_site.com/customop_uri_path Version: 1.0 Author: Danilo Silva Author URI: http://danilocgsilva.me */ // Write a new permalink entry on code activation register_activation_hook( __FILE__, ‘customop_activation’ ); function customop_activation() { customop_custom_output(); flush_rewrite_rules(); // Update the permalink entries in the database, so the permalink … Read more