Best way to abort plugin in case of insufficient PHP version?

This function and activation hook prevents the plugin from activating and allows you to check for both a minimum PHP and WordPress version. register_activation_hook( __FILE__, array( ‘Your_Plugin_Class_Name’, ‘activate’ ) ); /** * Plugin Activation hook function to check for Minimum PHP and WordPress versions * @param string $wp Minimum version of WordPress required for this … Read more

New WP_Customize API – how does it work under the hood?

There’s a few bits here that apply, but the short of it is this code in customize-preview.js: this.body.on( ‘click.preview’, ‘a’, function( event ) { event.preventDefault(); self.send( ‘scroll’, 0 ); self.send( ‘url’, $(this).prop(‘href’) ); }); The event.preventDefault prevents the links from actually working. The following code then sends a message back upwards telling it to a) … Read more

Is there a action hook for the “Empty Trash” button?

I don’t think there exist one, but you could create your own, wpse_empty_trash, with something like this: /** * Add a custom hook ‘wpse_empty_trash’ */ add_action( ‘load-edit.php’, function() { add_action( ‘before_delete_post’, function ( $post_id ) { if ( ‘trash’ === get_post_status( $post_id ) && filter_input( INPUT_GET, ‘delete_all’ ) && 1 === did_action( ‘before_delete_post ‘ ) … Read more

get_template_directory() vs bloginfo( ‘template_directory’ ) vs TEMPLATEPATH

To make a long story short: get_bloginfo( ‘template_directory’ ) and get_bloginfo( ‘template_url’ ) simply return get_template_directory_uri(). So, you can shortcut that second call simply by referring directly to the latter template tag. Refer to source for get_bloginfo(). A few others: ‘url’ => home_url() ‘wpurl’ => site_url() ‘stylesheet_url’ => get_stylesheet_uri() ‘stylesheet_directory’ => get_stylesheet_directory_uri() ‘locale’ => get_locale() … Read more

How do I make my child theme re-apply the settings that were customised when its parent was active?

I gave a +1 to the @webtoure’s answer because it gives you the right direction, however I think it lacks some checks. First of all it does not check that the theme that’s being activated is a child theme, and does not check that the theme previously active is the parent theme of the child … Read more