From a0ae6943f7bd92e14f5407d2946c5764e498a9f6 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 19 Nov 2015 10:03:23 -0500 Subject: [PATCH] Adding post messages --- models/block.php | 51 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/models/block.php b/models/block.php index 99d8286..088f6cf 100644 --- a/models/block.php +++ b/models/block.php @@ -31,6 +31,7 @@ class glm_models_block { $this->pluginDirName = $path; add_action('init', array($this, 'addPostTypes')); + add_filter('post_updated_messages', array($this, 'blocksUpdatedMessages')); add_action('admin_enqueue_scripts', array($this, 'load_admin_scripts')); add_action('add_meta_boxes', array($this, 'addMetaBoxes')); add_action('save_post', array($this, 'saveMetaBox')); @@ -64,7 +65,11 @@ class glm_models_block */ public function sortQuery($query) { - if (is_admin() && !isset($_REQUEST['orderby'])) { + if ( is_admin() + && !isset($_REQUEST['orderby']) + && isset($query) + && is_object($query) + && isset($query->query['post_type'])) { $postType = $query->query['post_type']; if ($postType == GLM_BLOCK_POST_TYPE) { $query->set('orderby', 'menu_order'); @@ -246,6 +251,50 @@ class glm_models_block include $this->pluginDirName . 'views/front/showBlocks.php'; } + /** + * Update the message text for the block post type + * + * @global type $post Post object + * @global type $post_ID Id of post + * + * @param type $messages Messages array + * + * @return type + */ + public function blocksUpdatedMessages($messages) + { + global $post, $post_ID; + + $messages['glm_blocks'] = array( + 0 => '', // Unused. Messages start at index 1. + 1 => sprintf(__('Block updated. View item'), + esc_url(get_permalink($post_ID))), + 2 => __('Custom field updated.'), + 3 => __('Custom field deleted.'), + 4 => __('Block updated.'), + /* translators: %s: date and time of the revision */ + 5 => isset($_GET['revision']) + ? sprintf(__('Block restored to revision from %s'), + wp_post_revision_title((int) $_GET['revision'], + false)) + : false, + 6 => sprintf(__('Block published. View event'), + esc_url(get_permalink($post_ID))), + 7 => __('Block saved.'), + 8 => sprintf(__('Block submitted. Preview event'), + esc_url(add_query_arg('preview', 'true', + get_permalink($post_ID)))), + 9 => sprintf(__('Block scheduled for: %1$s. Preview job'), + // 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(__('Block draft updated. Preview event'), + esc_url(add_query_arg('preview', 'true', + get_permalink($post_ID)))), + ); + return $messages; + } /** * addOrderColumn * -- 2.17.1