ControlledChaos
3/30/2015 - 9:46 AM

Modify editor messages for custom post types

Modify editor messages for custom post types

<?php

  function ccd_cpt_updated_messages( $messages ) {

  $messages['custom_post_type'] = array(
  0 => '', // Unused. Messages start at index 1.
  1 => sprintf( __( 'CPT updated. <a href="%s">View CPT</a>' ), esc_url( get_permalink( $post_ID ) ) ),
  2 => __( 'Custom field updated.' ),
  3 => __( 'Custom field deleted.' ),
  4 => __( 'CPT updated.' ),
  /* translators: %s: date and time of the revision */
  5 => isset($_GET['revision']) ? sprintf( __( 'CPT restored to revision from %s' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
  6 => sprintf( __( 'CPT published. <a href="%s">View CPT</a>' ), esc_url( get_permalink( $post_ID ) ) ),
  7 => __('CPT saved.'),
  8 => sprintf( __( 'CPT submitted. <a target="_blank" href="%s">Preview CPT</a>' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ),
  9 => sprintf( __( 'CPT scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview CPT</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( __( 'CPT draft updated. <a target="_blank" href="%s">Preview CPT</a>' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ),
  );
}
add_filter( 'post_updated_messages', 'ccd_cpt_updated_messages' );

?>

Modify editor messages for custom post types

WordPress Snippet