Make WordPress Core

Opened 7 years ago

Closed 5 months ago

#48201 closed defect (bug) (worksforme)

post_updated_messages event stop working version 5.2.3

Reported by: majavsc's profile majavsc Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.2.3
Component: Posts, Post Types Keywords:
Focuses: Cc:

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 (6)

#1 follow-up: @ocean90
7 years 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
7 years 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
7 years ago

  • Component changed from General to Posts, Post Types

#4 @majavsc
7 years ago

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

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

Tnx.

This ticket was mentioned in Slack in #core by sirlouen. View the logs.


5 months ago

#6 @SirLouen
5 months ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Reproduction Report

Description

❌ This report can't validate that the issue can be reproduced.

Environment

  • WordPress: 7.0-alpha-61215-src
  • PHP: 8.2.29
  • Server: nginx/1.29.3
  • Database: mysqli (Server: 8.4.7 / Client: mysqlnd 8.2.29)
  • Browser: Chrome 142.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Twenty 3.0
  • MU Plugins: None activated
  • Plugins:
    • BBB Testing Dolly
    • Classic Editor 1.6.7
    • Gutenberg 22.2.0
    • Test Reports 1.2.1

Testing Instructions

  1. Enable Classic Editor as @majavsc suggests
  2. Add the snippet
  3. Create a new post
  4. 👌 Custom message shows correctly

Actual Results

  1. ❌ Error condition not occurring

Additional Notes

  • Note that this does not work in the Blocks editor as @ocean90 suggested. Judging by the video, @majavsc is using the blocks editor not the classic editor. This is the reason of the malfunctioning. Closing this as worksforme
Note: See TracTickets for help on using tickets.