Make WordPress Core

Opened 5 years ago

Last modified 5 years ago

#45558 new defect (bug)

Move _draft_or_post_title() from wp-admin/includes to wp-includes

Reported by: swissspidy's profile swissspidy Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 5.0
Component: Editor Keywords: has-patch dev-feedback
Focuses: Cc:


In the WordPress 5.0 release package, the wp_latest_comments_draft_or_post_title() and render_block_core_latest_comments() functions don't exist because they were overwritten during npm install in the build process. That's because the changes from were manually added to core, before that PR was merged (which happened today).

Instead, we have gutenberg_draft_or_post_title() and gutenberg_render_block_core_latest_comments() in core now.

That's certainly less than ideal. Not only because the prefix is wrong, but also because gutenberg_draft_or_post_title() / wp_latest_comments_draft_or_post_title() duplicated the existing _draft_or_post_title() function. We should fix this as soon as possible, before people try to use gutenberg_ prefixed functions in their projects.

That function was duplicated in Gutenberg because they didn't want to include admin functions in front-end facing code, which makes sense.

Suggested solution:

  1. Move _draft_or_post_title() to wp-includes/template.php
  2. In the block-library package in Gutenberg, rename wp_latest_comments_draft_or_post_title() / gutenberg_draft_or_post_title() from latest-comments.php to _draft_or_post_title() and add a function_exists() check. This way, nothing should break.
  3. Use that function in render_block_core_latest_comments()

Alternatively to step 2, Gutenberg should just bump the minimum WP version to 5.0.1, which makes sure the _draft_or_post_title() function is available at all times.


  1. No duplicated code.
  2. No gutenberg_ prefixes in core

Attachments (1)

45558.diff (1.5 KB) - added by swissspidy 5 years ago.

Download all attachments as: .zip

Change History (10)

5 years ago

#1 @swissspidy
5 years ago

  • Keywords has-patch added; needs-patch removed

#2 @pento
5 years ago

  • Milestone changed from 5.0.1 to 5.0.2

#3 @swissspidy
5 years ago

  • Version set to 5.0

#4 @pento
5 years ago

I'm a little concerned about moving such an old function.

Moving it from wp-admin to wp-includes means it's now defined everywhere, there's possibly ancient code that relies on it only being in wp-admin.

Moving the file it's in will break any code that specifically loads that file, rather than all of WordPress: we ran into this problem a bunch of times the last time functions were moved around.

I'd be more inclined to move wp_latest_comments_draft_or_post_title() out of the block file, and deprecate _draft_or_post_title().

#5 @pento
5 years ago

  • Milestone changed from 5.0.2 to 5.0.3

#6 @audrasjb
5 years ago

  • Keywords dev-feedback added
  • Milestone changed from 5.0.3 to 5.1

5.0.3 is going to be released in a couple of weeks. We are currently sorting the remaining tickets in the milestone. It doesn't appear that ticket can be handled in the next couple of weeks (needs feedback and maybe some additional work). Let's address it in 5.1 which is coming in February. Feel free to change/ask to change the milestone if you think the issue can be quickly resolved.

#7 follow-up: @swissspidy
5 years ago

I'd be more inclined to move wp_latest_comments_draft_or_post_title() out of the block file

That means moving it in core and removing it from the block-library package in Gutenberg, correct?

#8 in reply to: ↑ 7 @pento
5 years ago

  • Milestone changed from 5.1 to 5.2

Replying to swissspidy:

That means moving it in core and removing it from the block-library package in Gutenberg, correct?

Yup. Give it a better name in core, then wp_latest_comments_draft_or_post_title() and _draft_or_post_title() can both be deprecated, and just call the core function.

#9 @pento
5 years ago

  • Milestone changed from 5.2 to Future Release

This change needs to be coordinated across this ticket, and the Gutenberg repo.

Note: See TracTickets for help on using tickets.