Last active
September 11, 2015 21:48
-
-
Save mindofjonas/39e08d9aa0f3088e2d67 to your computer and use it in GitHub Desktop.
Edit Post Messages + Remove "View Post" link from WordPress 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
/* | |
* Edit Post Messages for WordPress Custom Post Type | |
* Replace POST_TYPE_NAME with post type. Ex: films, movies, gallery | |
* Replace Post_Type_Name with proper name of post type. Ex: Films, Movies, Gallery | |
*/ | |
add_filter('post_updated_messages', 'post_type_updated_messages'); | |
function post_type_updated_messages( $messages ) { | |
$messages['POST_TYPE_NAME'] = array( //Specify the built in or custom post type | |
0 => '', // Unused. Messages start at index 1. | |
1 => sprintf( __('Post_Type_Name updated. <a href="%s">View Post_Type_Name</a>'), esc_url( get_permalink($post_ID) ) ), | |
2 => __('Custom field updated.'), | |
3 => __('Custom field deleted.'), | |
4 => __('Post_Type_Name updated.'), | |
/* translators: %s: date and time of the revision */ | |
5 => isset($_GET['revision']) ? sprintf( __('Post_Type_Name restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, | |
6 => sprintf( __('Post_Type_Name published. <a href="%s">View Post_Type_Name</a>'), esc_url( get_permalink($post_ID) ) ), | |
7 => __('Post_Type_Name saved.'), | |
8 => sprintf( __('Post_Type_Name submitted. <a target="_blank" href="%s">Preview Post_Type_Name</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), | |
9 => sprintf( __('Post_Type_Name scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview Post_Type_Name</a>'), | |
// translators: Publish box date format, see http://php.net/date | |
date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ), | |
10 => sprintf( __('Post_Type_Name draft updated. <a target="_blank" href="%s">Preview Post_Type_Name</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), | |
); | |
return $messages; | |
} | |
/* | |
* Remove "View Post" + "Preview Post" link from WordPress Custom Post Type | |
* Replace POST_TYPE_NAME with post type. Ex: films, movies, gallery | |
* Replace Post_Type_Name with proper name of post type. Ex: Films, Movies, Gallery | |
*/ | |
add_filter('post_updated_messages', 'remove_view_post'); | |
function remove_view_post( $messages ) { | |
$messages['POST_TYPE_NAME'] = array( //Specify the built in or custom post type | |
0 => '', // Unused. Messages start at index 1. | |
1 => sprintf( __('Post_Type_Name updated.), esc_url( get_permalink($post_ID) ) ), | |
2 => __('Custom field updated.'), | |
3 => __('Custom field deleted.'), | |
4 => __('Post_Type_Name updated.'), | |
/* translators: %s: date and time of the revision */ | |
5 => isset($_GET['revision']) ? sprintf( __('Post_Type_Name restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, | |
6 => sprintf( __('Post_Type_Name published.'), esc_url( get_permalink($post_ID) ) ), | |
7 => __('Post_Type_Name saved.'), | |
8 => sprintf( __('Post_Type_Name submitted.'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), | |
9 => sprintf( __('Post_Type_Name scheduled for: <strong>%1$s</strong>.'), | |
// translators: Publish box date format, see http://php.net/date | |
date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ), | |
10 => sprintf( __('Post_Type_Name draft updated.'), 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