[wp-trac] [WordPress Trac] #45558: Move _draft_or_post_title() from wp-admin/includes to wp-includes

WordPress Trac noreply at wordpress.org
Sun Dec 9 21:47:24 UTC 2018


#45558: Move _draft_or_post_title() from wp-admin/includes to wp-includes
--------------------------+-------------------------
 Reporter:  swissspidy    |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  5.0.1
Component:  Editor        |    Version:
 Severity:  normal        |   Keywords:  needs-patch
  Focuses:                |
--------------------------+-------------------------
 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:

 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.

 Benefits:

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

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/45558>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list