Created
March 27, 2011 17:30
-
-
Save thefuxia/889394 to your computer and use it in GitHub Desktop.
Renames the first submenu item for a custom post type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: *WPSE13210 | |
*/ | |
! defined( 'ABSPATH' ) and exit; | |
add_action( 'init', 'register_academia' ); | |
/** | |
* Registers te post type academias | |
* | |
* @return void | |
*/ | |
function register_academia() | |
{ | |
register_post_type( | |
'academias' | |
, array ( | |
'can_export' => TRUE | |
, 'exclude_from_search' => FALSE | |
, 'has_archive' => TRUE | |
, 'hierarchical' => TRUE | |
, 'label' => 'Academias' | |
, 'labels' => array ( | |
'menu_name' => 'See All Academias' | |
, 'name' => 'Academias' | |
) | |
, 'menu_position' => 5 | |
, 'public' => TRUE | |
, 'publicly_queryable' => TRUE | |
, 'query_var' => 'academias' | |
, 'rewrite' => array ( 'slug' => 'academias' ) | |
, 'show_ui' => TRUE | |
, 'show_in_menu' => TRUE | |
, 'show_in_nav_menus' => TRUE | |
, 'supports' => array ( 'editor', 'title' ) | |
) | |
); | |
} | |
add_filter( 'attribute_escape', 'rename_second_menu_name', 10, 2 ); | |
/** | |
* Renames the first occurence of 'See All Academias' to 'Academias' | |
* and deactivates itself then. | |
* @param $safe_text | |
* @param $text | |
*/ | |
function rename_second_menu_name( $safe_text, $text ) | |
{ | |
if ( 'See All Academias' !== $text ) | |
{ | |
return $safe_text; | |
} | |
// We are on the main menu item now. The filter is not needed anymore. | |
remove_filter( 'attribute_escape', 'rename_second_menu_name' ); | |
return 'Academias'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See http://wordpress.stackexchange.com/questions/13210/post-type-label-name/ for more information.