Including CSS and JS on Admin Screen of Custom Theme Options

If you create an admin theme plugin from the Codex steps, you will notice it says not to insert stylesheets as per above – although the above will work. If you place the following inside your admin theme file, it will serve the same purpose, but uses the wp_enqueue_styles approach: function add_admin_theme_styles() { wp_register_style($handle=”mytheme-theme-admin-styles”, $src … Read more

Send automatic mail to Admin when user/member changes/adds profile

you got the first part right about using personal_options_update but to be on the safe side add edit_user_profile_update also. and as for sending emails within WordPress the best way would be to use wp_mail, So something like this: add_action( ‘personal_options_update’, ‘notify_admin_on_update’ ); add_action( ‘edit_user_profile_update’,’notify_admin_on_update’); function notify_admin_on_update(){ global $current_user; get_currentuserinfo(); if (!current_user_can( ‘administrator’ )){// avoid sending … Read more

Redirect Admin User in Dashboard

You should not use Userlevels. Userlevels have been replaced in WP 2.0 and have been officially deprecated since 3.0 add_filter( ‘login_redirect’, ‘dashboard_redirect’ ); function dashboard_redirect( $url ) { if ( current_user_can( ‘manage_options’ ) ) { $url = esc_url( admin_url( ‘edit.php’ ) ); } return $url; } Will do what you want.

Modifying admin sidebar contents to show pending posts indicator

@ign Replace the line of code you posted with the following.. foreach( $menu as $menu_key => $menu_data ) : if( ‘edit.php’ != $menu_data[2] ) continue; $menu[$menu_key][0] .= ” <span class=”update-plugins count-$pending_count”><span class=”plugin-count”>” . number_format_i18n($pending_count) . ‘</span></span>’; endforeach; ..that should avoid the need to know the specific key.. (let me know if any problems).. Hope that … Read more

Create a dropdown with Custom Post Types as option in admin

Here is the code I’m using in a project I’m working on. function generate_post_select($select_id, $post_type, $selected = 0) { $post_type_object = get_post_type_object($post_type); $label = $post_type_object->label; $posts = get_posts(array(‘post_type’=> $post_type, ‘post_status’=> ‘publish’, ‘suppress_filters’ => false, ‘posts_per_page’=>-1)); echo ‘<select name=”‘. $select_id .'” id=”‘.$select_id.'”>’; echo ‘<option value = “” >All ‘.$label.’ </option>’; foreach ($posts as $post) { echo … Read more

Remove Customize Background and Header from Appearance admin menu without CSS or JS

As overcomplicated as it sounds, I always find the best way to handle admin menu modifications is to overlook the given wordpress remove_ functions and go straight to the $menu and $submenu globals. In the case you’ve specified here, you’d want to change your code to: add_action(‘admin_menu’, ‘remove_unnecessary_wordpress_menus’, 999); function remove_unnecessary_wordpress_menus(){ global $submenu; unset($submenu[‘themes.php’][20]); unset($submenu[‘themes.php’][22]); … Read more