Check php version before theme activation

As you want to implement the check within your theme files you can use the action after_switch_theme; as you can guess this will activate your theme to perform the check but will switch back to the previous theme if necessary. If the requirements are not fulfilled we’re going to notify the user via an admin … Read more

When and Where to use wp_insert_post()

Use some type of conditional tag to check if those posts exist or not. If they do not exist, have them created with wp_insert_post. Do this logic inside the AddMyPages function and not around the add_action function. Example You want to add a page with a parent ID only if it does not exist, and … Read more

Is there an action for when permalinks are rebuilt?

The action is update_option_permalink_structure. You get the old and the new value as parameters. add_action( ‘update_option_permalink_structure’ , ‘my_custom_function’, 10, 2 ); function my_custom_function( $oldvalue, $_newvalue ) { // do something } There are also the actions update_option_category_base and update_option_tag_base.

How do I print a notice only on certain admin pages?

There is a global variable called $pagenow for the use within WP Admin: global $pagenow; if ( $pagenow == ‘upload.php’ ) : function custom_admin_notice() { echo ‘<div class=”updated”><p>Updated!</p></div>’; } add_action( ‘admin_notices’, ‘custom_admin_notice’ ); endif; UPDATE: Simply include the snippet in your themes or plugins functions.php