Skip to content

Instantly share code, notes, and snippets.

@markoheijnen
Created April 16, 2012 16:40
Show Gist options
  • Save markoheijnen/2399864 to your computer and use it in GitHub Desktop.
Save markoheijnen/2399864 to your computer and use it in GitHub Desktop.
Change Post to News
<?php
add_action( 'init', array( &$this, 'change_post_object_label' ), 0 );
add_action( 'admin_menu', array( &$this, 'change_post_menu_label' ), 0 );
add_filter( 'post_updated_messages', array( &$this, 'post_updated_messages') );
function change_post_menu_label() {
global $menu;
global $submenu;
if( isset( $menu[5], $submenu['edit.php'] ) ) {
$menu[5][0] = 'News';
$submenu['edit.php'][5][0] = 'News';
$submenu['edit.php'][10][0] = 'Add News';
$submenu['edit.php'][16][0] = 'News tags';
}
}
function change_post_object_label() {
global $wp_post_types;
$labels = &$wp_post_types['post']->labels;
$labels->name = 'News';
$labels->singular_name = 'News';
$labels->add_new = 'Add new';
$labels->add_new_item = 'Add news article';
$labels->edit_item = 'Edit news article';
$labels->new_item = 'News';
$labels->view_item = 'View news article';
$labels->search_items = 'Search news articles';
$labels->not_found = 'No news articles found';
$labels->not_found_in_trash = 'No news articles found in Trash';
$labels->all_items = 'All news articles';
$labels->menu_name = 'News articles';
$labels->name_admin_bar = 'News';
}
function post_updated_messages( $messages ) {
global $post, $post_ID;
$messages['post'] = array(
0 => '',
1 => sprintf( 'News article updated. <a href="%s">View article</a>', esc_url( get_permalink( $post_ID ) ) ),
2 => 'Custom field updated.',
3 => 'Custom field deleted.',
4 => 'News Article updated.',
5 => isset( $_GET['revision'] ) ? sprintf( 'News article restored to revision from %s', wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => sprintf( 'News article published. <a href="%s">View article</a>', esc_url( get_permalink( $post_ID ) ) ),
7 => 'News article saved.',
8 => sprintf( 'News article submitted. <a target="_blank" href="%s">Preview article</a>', esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ),
9 => sprintf( 'News article scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview article</a>',
date_i18n( 'M j, Y @ G:i', strtotime( $post->post_date ) ), esc_url( get_permalink( $post_ID ) ) ),
10 => sprintf( 'News article draft updated. <a target="_blank" href="%s">Preview article</a>', esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ),
);
return $messages;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment