Opened 6 years ago
Last modified 6 years ago
#45558 new defect (bug)
Move _draft_or_post_title() from wp-admin/includes to wp-includes
Reported by: | swissspidy | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | 5.0 |
Component: | Editor | Keywords: | has-patch dev-feedback |
Focuses: | Cc: |
Description
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 https://github.com/WordPress/gutenberg/pull/12326 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:
- Move
_draft_or_post_title()
towp-includes/template.php
- In the
block-library
package in Gutenberg, renamewp_latest_comments_draft_or_post_title()
/gutenberg_draft_or_post_title()
fromlatest-comments.php
to_draft_or_post_title()
and add afunction_exists()
check. This way, nothing should break. - 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.
Benefits:
- No duplicated code.
- No
gutenberg_
prefixes in core
Attachments (1)
Change History (10)
#6
@
6 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:
↓ 8
@
6 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
@
6 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.
I'm a little concerned about moving such an old function.
Moving it from
wp-admin
towp-includes
means it's now defined everywhere, there's possibly ancient code that relies on it only being inwp-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()
.