Last active
October 10, 2015 06:47
-
-
Save rfmeier/3649599 to your computer and use it in GitHub Desktop.
my_post_updated_messages filter
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 | |
// do not include php tag | |
add_filter( 'post_updated_messages', 'my_post_updated_messages' ); | |
/** | |
* Callback for WordPress 'post_updated_messages' filter. | |
* | |
* @param array $messages The array of messages. | |
* @return array $messages The array of messages. | |
*/ | |
public function my_post_updated_messages( $messages ){ | |
global $post; | |
$post_ID = $post->ID; | |
$messages['custom_post_type'] = array( | |
0 => '', // Unused. Messages start at index 1. | |
1 => sprintf( __('Post Type updated. <a href="%s">View Post Type</a>'), esc_url( get_permalink($post_ID) ) ), | |
2 => __('Post Type field updated.'), | |
3 => __('Post Type field deleted.'), | |
4 => __('Post Type updated.'), | |
5 => isset($_GET['revision']) ? sprintf( __('Post Type restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, | |
6 => sprintf( __('Post Type published. <a href="%s">View run</a>'), esc_url( get_permalink($post_ID) ) ), | |
7 => __('Post Type saved.'), | |
8 => sprintf( __('Post Type submitted. <a target="_blank" href="%s">Preview run</a>'), esc_url( add_query_arg( 'preview', 'true',get_permalink($post_ID) ) ) ), | |
9 => sprintf( __('Post Type scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview run</a>'), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ), | |
10 => sprintf( __('Post Type draft updated. <a target="_blank" href="%s">Preview post type</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