From 54ab43104638c485bb882a31903db04ab52b32d3 Mon Sep 17 00:00:00 2001 From: desrosj Date: Mon, 17 Dec 2018 19:08:51 +0000 Subject: [PATCH] Block Editor: Fix loading the script handling the "Manage Reusable Blocks" page. This ensures the "import from JSON" and "export JSON" buttons are shown properly. The script is loaded in the footer because it relies on the DOM being already there. Props noisysocks, mukesh27. Merges [43936] into trunk. Fixes #45396. Built from https://develop.svn.wordpress.org/trunk@44274 git-svn-id: http://core.svn.wordpress.org/trunk@44104 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit.php | 4 +++- wp-includes/blocks/latest-comments.php | 10 +++++----- wp-includes/version.php | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/wp-admin/edit.php b/wp-admin/edit.php index 20fb7e466f..a469bbd4b0 100644 --- a/wp-admin/edit.php +++ b/wp-admin/edit.php @@ -201,8 +201,10 @@ wp_enqueue_script( 'inline-edit-post' ); wp_enqueue_script( 'heartbeat' ); if ( 'wp_block' === $post_type ) { - wp_enqueue_script( 'wp-list-reusable-blocks' ); wp_enqueue_style( 'wp-list-reusable-blocks' ); + + // wp-list-reusable-blocks enhances the page's DOM and so needs to be loaded in the footer. + wp_enqueue_script( 'wp-list-reusable-blocks', '', array(), false, true ); } $title = $post_type_object->labels->name; diff --git a/wp-includes/blocks/latest-comments.php b/wp-includes/blocks/latest-comments.php index 557e3dce13..29e17e9de5 100644 --- a/wp-includes/blocks/latest-comments.php +++ b/wp-includes/blocks/latest-comments.php @@ -5,7 +5,7 @@ * @package WordPress */ -if ( ! function_exists( 'wp_latest_comments_draft_or_post_title' ) ) { +if ( ! function_exists( 'gutenberg_draft_or_post_title' ) ) { /** * Get the post title. * @@ -26,7 +26,7 @@ if ( ! function_exists( 'wp_latest_comments_draft_or_post_title' ) ) { * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. * @return string The post title if set; "(no title)" if no title is set. */ - function wp_latest_comments_draft_or_post_title( $post = 0 ) { + function gutenberg_draft_or_post_title( $post = 0 ) { $title = get_the_title( $post ); if ( empty( $title ) ) { $title = __( '(no title)' ); @@ -42,7 +42,7 @@ if ( ! function_exists( 'wp_latest_comments_draft_or_post_title' ) ) { * * @return string Returns the post content with latest comments added. */ -function render_block_core_latest_comments( $attributes = array() ) { +function gutenberg_render_block_core_latest_comments( $attributes = array() ) { // This filter is documented in wp-includes/widgets/class-wp-widget-recent-comments.php. $comments = get_comments( apply_filters( @@ -94,7 +94,7 @@ function render_block_core_latest_comments( $attributes = array() ) { // `_draft_or_post_title` calls `esc_html()` so we don't need to wrap that call in // `esc_html`. - $post_title = '' . wp_latest_comments_draft_or_post_title( $comment->comment_post_ID ) . ''; + $post_title = '' . gutenberg_draft_or_post_title( $comment->comment_post_ID ) . ''; $list_items_markup .= sprintf( /* translators: 1: author name (inside or tag, based on if they have a URL), 2: post title related to this comment */ @@ -179,6 +179,6 @@ register_block_type( 'enum' => array( 'center', 'left', 'right', 'wide', 'full', '' ), ), ), - 'render_callback' => 'render_block_core_latest_comments', + 'render_callback' => 'gutenberg_render_block_core_latest_comments', ) ); diff --git a/wp-includes/version.php b/wp-includes/version.php index aa609d545d..3c9fd73545 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.1-alpha-44273'; +$wp_version = '5.1-alpha-44274'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.