WordPress.org

Make WordPress Core

Opened 6 weeks ago

Last modified 5 weeks ago

#48201 new defect (bug)

post_updated_messages event stop working version 5.2.3

Reported by: majavsc Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.2.3
Component: Posts, Post Types Keywords: reporter-feedback
Focuses: Cc:
PR Number:

Description

I really think that there is some problem with post_updated_messages event in 5.2.3 version. Tried the same code in vanila vrsion 4.9.11 and vanila 5.2.3. In 4.9.11 messages are overwritten and they are working good in 5.2.3 nothing’s happened.
Try to add next code in wp-content/plugins/hello.php and activate Hello Dolly plugin:

<?php


function frl_change_post_updated_labels($messages) {    
    global $post;      
    $permalink = get_permalink($post->ID);         
    $messages['post'] = array(         
    0 => '', 
    1 => sprintf( __('Article updated. <a href="%s">View post</a>', 'frl'), esc_url($permalink)),
    2 => __('Custom field updated.', 'frl'),
    3 => __('Custom field deleted.', 'frl'),
    4 => __('Article updated.', 'frl'),    
    5 => isset($_GET['revision']) ? sprintf(__('Article restored to revision from %s', 'frl'), wp_post_revision_title((int)$_GET['revision'], false)) : false,
    6 => sprintf( __('Article published. <a href="%s">View post</a>'), esc_url($permalink)),
    7 => __('Article saved.', 'frl'),
    8 => sprintf( __('Article submitted. <a target="_blank" href="%s" rel="noopener noreferrer">Preview</a>', 'frl'), esc_url(add_query_arg('preview','true', $permalink))),
    9 => __('Article scheduled. <a target="_blank" href="%2$s" rel="noopener noreferrer">Preview</a>', 'frl'),
    10 => sprintf( __('Article draft updated. <a target="_blank" href="%s" rel="noopener noreferrer">Preview</a>', 'frl'), esc_url(add_query_arg('preview', 'true', $permalink))) 
    ); 
    return $messages;
}
add_filter('post_updated_messages', 'frl_change_post_updated_labels');

Also tried adding new category ‘article’ instead of ‘post’ and create new array $messages[‘article’] and assinged post to article category but it is working the same.

So the problem exists in both cases:
– when we want to overwrite existing messages (post, page, attachment)
– when we want to add the new message type

I would be very thankful if someone helps me with solving this.
Tnx.

Change History (4)

#1 follow-up: @ocean90
6 weeks ago

  • Keywords reporter-feedback added

Hello @majavsc, welcome to WordPress Trac!

Are you expecting the messages to appear in the new block editor? If that's the case then you have to use the new post type labels instead since the filter isn't used in the block editor.

#2 in reply to: ↑ 1 @majavsc
6 weeks ago

Replying to ocean90:

Hello @majavsc, welcome to WordPress Trac!

Are you expecting the messages to appear in the new block editor? If that's the case then you have to use the new post type labels instead since the filter isn't used in the block editor.

No, I am expecting the message to be overwritten - instead of "Post published view" to have "Bla bla something". I don't want to use the new block.
Tnx for your replay.

#3 @SergeyBiryukov
6 weeks ago

  • Component changed from General to Posts, Post Types

#4 @majavsc
5 weeks ago

Hi to all,
I captured the video that demonstrates the bug

https://drive.google.com/file/d/1Hhzhwkr9KVLA-AQsvH9aF00kWa_qX-gf/view

Tnx.

Note: See TracTickets for help on using tickets.