From ba1c444bf37e714787667791c65754dcdb63916b Mon Sep 17 00:00:00 2001 From: mcsf Date: Wed, 21 Nov 2018 16:18:49 +0000 Subject: [PATCH] Block Editor: Show privacy help notice on Privacy Policy page. When editing a page set to be the Privacy Policy page, display a help notice containing a link to the Privacy Policy guide. This changeset ports this functionality to the new Block Editor. Props desrosj. Fixes #45057. Built from https://develop.svn.wordpress.org/branches/5.0@43920 git-svn-id: http://core.svn.wordpress.org/branches/5.0@43752 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/admin-filters.php | 2 +- wp-admin/includes/misc.php | 7 +++++-- wp-includes/blocks/archives.php | 14 +++++++------- wp-includes/blocks/categories.php | 2 +- wp-includes/blocks/latest-comments.php | 6 +++--- wp-includes/blocks/latest-posts.php | 2 +- wp-includes/version.php | 2 +- 7 files changed, 19 insertions(+), 16 deletions(-) diff --git a/wp-admin/includes/admin-filters.php b/wp-admin/includes/admin-filters.php index ba2cb7e2bd..43a159038a 100644 --- a/wp-admin/includes/admin-filters.php +++ b/wp-admin/includes/admin-filters.php @@ -144,7 +144,7 @@ add_action( 'wp_privacy_personal_data_erased', '_wp_privacy_send_erasure_fulfill add_action( 'admin_init', array( 'WP_Privacy_Policy_Content', 'text_change_check' ), 100 ); // Show a "postbox" with the text suggestions for a privacy policy. -add_action( 'edit_form_after_title', array( 'WP_Privacy_Policy_Content', 'notice' ) ); +add_action( 'admin_notices', array( 'WP_Privacy_Policy_Content', 'notice' ) ); // Add the suggested policy text from WordPress. add_action( 'admin_init', array( 'WP_Privacy_Policy_Content', 'add_suggested_content' ), 1 ); diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php index caa923f1df..b3c4ec4a7c 100644 --- a/wp-admin/includes/misc.php +++ b/wp-admin/includes/misc.php @@ -1540,10 +1540,13 @@ final class WP_Privacy_Policy_Content { * Add a notice with a link to the guide when editing the privacy policy page. * * @since 4.9.6 + * @since 5.0.0 The $post parameter is now optional. * - * @param WP_Post $post The currently edited post. + * @param WP_Post|null $post The currently edited post. Default null. */ - public static function notice( $post ) { + public static function notice( $post = null ) { + $post = get_post( $post ); + if ( ! ( $post instanceof WP_Post ) ) { return; } diff --git a/wp-includes/blocks/archives.php b/wp-includes/blocks/archives.php index c94a4645d9..85186ce612 100644 --- a/wp-includes/blocks/archives.php +++ b/wp-includes/blocks/archives.php @@ -32,7 +32,7 @@ function render_block_core_archives( $attributes ) { $class .= ' wp-block-archives-dropdown'; $dropdown_id = esc_attr( uniqid( 'wp-block-archives-' ) ); - $title = __( 'Archives' ); + $title = __( 'Archives', 'default' ); /** This filter is documented in wp-includes/widgets/class-wp-widget-archives.php */ $dropdown_args = apply_filters( @@ -50,19 +50,19 @@ function render_block_core_archives( $attributes ) { switch ( $dropdown_args['type'] ) { case 'yearly': - $label = __( 'Select Year' ); + $label = __( 'Select Year', 'default' ); break; case 'monthly': - $label = __( 'Select Month' ); + $label = __( 'Select Month', 'default' ); break; case 'daily': - $label = __( 'Select Day' ); + $label = __( 'Select Day', 'default' ); break; case 'weekly': - $label = __( 'Select Week' ); + $label = __( 'Select Week', 'default' ); break; default: - $label = __( 'Select Post' ); + $label = __( 'Select Post', 'default' ); break; } @@ -101,7 +101,7 @@ function render_block_core_archives( $attributes ) { $block_content = sprintf( '
%2$s
', $classnames, - __( 'No archives to show.' ) + __( 'No archives to show.', 'default' ) ); } else { diff --git a/wp-includes/blocks/categories.php b/wp-includes/blocks/categories.php index 38de4bd517..478d457920 100644 --- a/wp-includes/blocks/categories.php +++ b/wp-includes/blocks/categories.php @@ -27,7 +27,7 @@ function render_block_core_categories( $attributes ) { if ( ! empty( $attributes['displayAsDropdown'] ) ) { $id = 'wp-block-categories-' . $block_id; $args['id'] = $id; - $args['show_option_none'] = __( 'Select Category' ); + $args['show_option_none'] = __( 'Select Category', 'default' ); $wrapper_markup = '
%2$s
'; $items_markup = wp_dropdown_categories( $args ); $type = 'dropdown'; diff --git a/wp-includes/blocks/latest-comments.php b/wp-includes/blocks/latest-comments.php index 05797c029e..b06cccd6c0 100644 --- a/wp-includes/blocks/latest-comments.php +++ b/wp-includes/blocks/latest-comments.php @@ -29,7 +29,7 @@ if ( ! function_exists( 'gutenberg_draft_or_post_title' ) ) { function gutenberg_draft_or_post_title( $post = 0 ) { $title = get_the_title( $post ); if ( empty( $title ) ) { - $title = __( '(no title)' ); + $title = __( '(no title)', 'default' ); } return esc_html( $title ); } @@ -98,7 +98,7 @@ function gutenberg_render_block_core_latest_comments( $attributes = array() ) { $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 */ - __( '%1$s on %2$s' ), + __( '%1$s on %2$s', 'default' ), $author_markup, $post_title ); @@ -143,7 +143,7 @@ function gutenberg_render_block_core_latest_comments( $attributes = array() ) { ) : sprintf( '
%2$s
', $classnames, - __( 'No comments to show.' ) + __( 'No comments to show.', 'default' ) ); return $block_content; diff --git a/wp-includes/blocks/latest-posts.php b/wp-includes/blocks/latest-posts.php index 72b395a06c..5a582957c6 100644 --- a/wp-includes/blocks/latest-posts.php +++ b/wp-includes/blocks/latest-posts.php @@ -33,7 +33,7 @@ function render_block_core_latest_posts( $attributes ) { $title = get_the_title( $post_id ); if ( ! $title ) { - $title = __( '(Untitled)' ); + $title = __( '(Untitled)', 'default' ); } $list_items_markup .= sprintf( '
  • %2$s', diff --git a/wp-includes/version.php b/wp-includes/version.php index ac96387ce8..a0fd0a70bc 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '5.0-beta5-43919'; +$wp_version = '5.0-beta5-43920'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.