How do I filter the excerpt metabox description in admin?

This description is generated by post_excerpt_meta_box() function and is not passed through any explicit filters. It is however echoed by translation-related _e() function and so passes through gettext filter (which from your question you are already familiar with). As for limiting it to your CPT, I think current post type in admin is held in … Read more

how to group custom post types

The filter Inside /wp-admin/menu.php, you’ll find this filter at the end of the “add css classes”-loop: apply_filters( ‘add_menu_classes’, $menu ) The function The following code attaches the right classes to the first and previous elements. It also adds the separator in between. If you need to add another separator to the end/after your group, you’ll … Read more

Uploading Images in the Link Manager

Well, started as a curiosity, ended up doing a plugin… : After finishing, I went to look in WordPress repository and…yes, there’s already one that does it: Easy Blogroll Image : At least, I took a different approach and did something different. Featured Link Image – [edit: released in the WordPress repository, link updated]

How to Remove All Admin Bar Menu Items?

I’m solving this getting all nodes from the Admin Bar, iterating through them and removing all that doesn’t have a parent. An exception is made to the User Actions menu (“Howdy, user_name”), which needs an extra checking. add_action( ‘admin_bar_menu’, ‘wpse_76491_admin_bar_menu’, 200 ); function wpse_76491_admin_bar_menu() { global $wp_admin_bar; if ( !is_object( $wp_admin_bar ) ) return; // … Read more

Remove unusable metaboxes in nav menu management screen

There are two important global variables in wp-admin/nav-menus.php: $nav_menus is an array of all available menus, filled with wp_get_nav_menus(). $wp_meta_boxes[‘nav-menus’] is an array of all available metaboxes for this screen. We can hook into admin_head-nav-menus.php, an action called after the first variable has been set up, and change the second variable: add_action( ‘admin_head-nav-menus.php’, ‘t5_hide_dead_menu_metaboxes’ ); … Read more

How to change admin bar color scheme in MP6 / WP 3.8 front end?

At the moment (3.8) color schemes do not apply to admin bar at front end at all, even if user is logged in and has non-default scheme selected. The shortest way would probably be to force enqueue color scheme at front end: add_action( ‘wp_enqueue_scripts’, function () { wp_enqueue_style( ‘color-admin-bar’, admin_url( ‘/css/colors/coffee/colors.min.css’ ), array( ‘admin-bar’ ) … Read more

Admin Filter – Add Post Type Description on Post Type Page

The filter views_{$this->screen->id} is fired just after the title of post edit screen has been print to screen, so it’s a safe place to just echo what you want. So you can simply do: function post_type_desc( $views ){ $screen = get_current_screen(); $post_type = get_post_type_object($screen->post_type); if ($post_type->description) { printf(‘<h4>%s</h4>’, esc_html($post_type->description)); // echo } return $views; // … Read more

What hook do I use to edit the post statuses option in admin?

You can use the filter views_edit-post (or views_edit-{custom-post-type}) to modify the available “views”: add_filter(‘views_edit-post’, ‘cyb_remove_pending_filter’ ); function cyb_remove_pending_filter( $views ) { if( isset( $views[‘pending’] ) ) { unset( $views[‘pending’] ); } return $views; } In the above filter you need inlude the user rules you want to apply. For exmple, if you want to remove … Read more

Make fonts.com font work in TinyMCE (iframe referrer issue)

I ran into this issue with Typekit, here’s my solution: http://www.tomjn.com/150/typekit-wp-editor-styles/ add_filter(“mce_external_plugins”, “tomjn_mce_external_plugins”); function tomjn_mce_external_plugins($plugin_array){ $plugin_array[‘typekit’] = get_template_directory_uri().’/typekit.tinymce.js’; return $plugin_array; } and this js: (function() { tinymce.create(‘tinymce.plugins.typekit’, { init: function(ed, url) { ed.onPreInit.add(function(ed) { // Get the DOM document object for the IFRAME var doc = ed.getDoc(); // Create the script we will add to … Read more

How to check if I’m on a custom post type archive in the admin area

Here are three possibilities, based on the /wp-admin/admin.php file: Method #1 There are the global $pagenow and $typenow available: global $pagenow, $typenow; if( ‘my_venue’ === $typenow && ‘edit.php’ === $pagenow ) { // … } Method #2 Then there’s the current screen, also set in the admin.php file with set_current_screen(); $screen = get_current_screen(); if( is_a( … Read more