Default Plugin Settings Not Writing to Database

I believe the issue is that your function that sets up the settings initially isn’t getting run upon activation. Add a call to your mouldings_register_settings_initial() in the activation hook, like this: function mouldings_activate() { global $wpdb, $mouldings_options; mouldings_register_settings_initial(); if ($mouldings_options === false){ $mouldings_options = array( ‘idea_item_columns’ => ‘4’ ); update_option( ‘mouldings_settings’, $mouldings_options ); } } … Read more

Set of plugins to control the Admin UI

I have found Role Scopper to be a powerful role management tool. It’s a PAIN to figure out, but once it clicks, it’s genius. There’s a new, paid version (not terribly expensive), but I have not tried it, and can’t speak to it’s usefulness. @brasofilo, thanks for the good information. I will incorporate some of … Read more

Output HTML only on individual post view

If you want to load your js only on page/post view you can do it like this: function myplugin_enqueue_scripts() { global $wp_query; if ( $wp_query->is_single ) { wp_enqueue_script( ‘my_js’, … ); } } add_action( ‘wp_enqueue_scripts’, ‘myplugin_enqueue_scripts’ );

Custom Taxonomy Tag Search

One plugin that I’ve used successfully is Relevanssi: http://wordpress.org/extend/plugins/relevanssi/ Also, you could try to make your custom taxonomy into a search filter, like it’s described in this post: http://wordpress.org/support/topic/search-form-with-custom-taxonomy-dropdown . I’ve used this on my projects and it worked wonders! Hope this helps!

Where should a plugin or widget cache its results?

I find that relying on the filesystem to cache results is easy for maintenance, diagnostics, and performance. Please note that this might be true in some (maybe even most) circumstances, but not all of them. If your code is meant for anything beyond personal usage you don’t know with which file system and hardware will … Read more

How to remove all javascript in a theme wordpress?

You either use the admin_*/wp_print_scripts hook or the admin_*/wp_print_styles hook. The styles hook comes before the print scripts hook, so maybe it fits better than just using a priority of 0 for the *_print_scripts hook (there might be function with a name that’s hooked in earlier on priority 0). function wpse61635_remove_all_scripts() { global $wp_scripts; $leave_alone … Read more

adding meta data using plugin to top of head

Okay, here’s the answer: function CustomHead() { include(‘headcontent.php’); } add_action(‘wp_head’,’CustomHead’,1,1); The key is that first “1”, which sets the priority of it to run at the highest (this is an optional element, defaulting to 10, putting it at the end of the head by default). More info here: http://codex.wordpress.org/Function_Reference/add_action

Avoiding Duplicate function names in Post Loop (WP_Footer script)

I would wrap the whole thing in a class and put your data into a class var. class WPA69616_Plugin { private $data=””; public function __construct() { add_shortcode(‘my_shortcode’, array($this, ‘add_content’)); add_action(‘wp_footer’, array($this, ‘output_content’)); } public function add_content($atts) { extract( shortcode_atts( array( ‘content’ => ” ), $atts ) ); $this->data .= $content; } public function output_content() { … Read more

Error handling a plugin with exceptions

You can also extend expections and then catch only those that you throw. For example: function do_add_my_pws_exceptions() { class PWS_Exception extends Exception {} class PWS_Init_Exception extends PWS_Exception {} } add_action(‘plugins_loaded’, ‘do_add_my_pws_exceptions’); Of course, you should be certain the user is running at least version 5 of PHP by having your theme of plugin activation do … Read more