How to add an admin alert for missing plugins

To check if a plugin is installed and activated, use the is_plugin_active() function. Note that you need to include this function first on the front-end before you can use it: include_once ABSPATH.’wp-admin/includes/plugin.php’; Avoid function_exists() for doing the check. Plugins may refactor their code and a previously existing function might disappear. You never know.

Function to add custom HTML into head in custom post-type list page

If its okey you can hook into admin_notices. Like this: Change post_type to the real post_type name.. I assumed it would be “program”. function wpse_76471_add_html() { global $pagenow ,$post; if( $post->post_type == ‘program’ && $pagenow == ‘edit.php’ ) { $output=”<div class=”my-div”>”; $output .= ‘<h2>’. __(‘My custom content (HTML/PHP)’, ‘program’) .'</h2>’; $output .= ‘</div>’; echo $output; … Read more

How to include stylesheet in custom admin using parent_slug

Don’t confuse menu structure with page/URL structure. Each one of your pages may have a different hook. Do this: function my_enqueue($hook) { echo $hook; } add_action( ‘admin_enqueue_scripts’, ‘my_enqueue’ ); Load your pages and write down the hook names. There may be other ways to do this too, like the admin-print-scripts-$hook_suffix hooks. Look in wp-admin/admin-header.php to … Read more

How to show a custom notification to a specific user?

You can show admin notices via the admin_notices action. You can display it for a specific user by checking the contents of the global $current_user: function wpa80367_admin_notice() { global $current_user; if ( ‘someusername’ == $current_user->user_login ): echo ‘<div class=”updated”><p>’; echo ‘This is an admin notice just for you, someusername.’; echo ‘</p></div>’; endif; } add_action( ‘admin_notices’, … Read more

Is there a hook between clicking on “Add new” and the edit screen of a new post?

This plugin does the same thing as what you are looking for: http://wordpress.org/extend/plugins/magic-action-box It has a custom post type called action-box but has different types of action boxes that you can select when you create a new action box. The code you want is found inside the plugin’s directory lib/classes/ProsulumMabAdmin.php. Look for the method add_actions() … Read more

Adding a ‘style=’ bit to image_send_to_editor output

I can’t find the proper hook, but there is alternative solution: to add style=”float:right” to all images in content, which have class=”alignright”: add_filter(‘the_content’, ‘my_add_image_float_right’); function my_add_image_float_right($content) { $pattern = ‘@(<img.+)(alignright)(.*)(/>)@Ui’; $replacement=”$1$2$3 style=”float:right” />”; $content = preg_replace($pattern, $replacement, $content); return $content; }