From 7f456cab7d2eda31c21b84bb45e2ad01be48f48f Mon Sep 17 00:00:00 2001 From: aduth Date: Fri, 12 Apr 2019 18:19:51 +0000 Subject: [PATCH] Privacy: Display help notice on block editor screen. Use the Notices data module when viewing the block editor screen for the assigned Privacy Policy page to display a help notice. Props garrett-eclipse, joen, xkon. Fixes #46098. Built from https://develop.svn.wordpress.org/trunk@45174 git-svn-id: http://core.svn.wordpress.org/trunk@44983 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/misc.php | 68 ++++++++++++++++++++++++++------------ wp-includes/version.php | 2 +- 2 files changed, 48 insertions(+), 22 deletions(-) diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php index d0dc33b913..44045a47f3 100644 --- a/wp-admin/includes/misc.php +++ b/wp-admin/includes/misc.php @@ -1619,7 +1619,11 @@ final class WP_Privacy_Policy_Content { * @param WP_Post|null $post The currently edited post. Default null. */ public static function notice( $post = null ) { - $post = get_post( $post ); + if ( is_null( $post ) ) { + global $post; + } else { + $post = get_post( $post ); + } if ( ! ( $post instanceof WP_Post ) ) { return; @@ -1631,30 +1635,52 @@ final class WP_Privacy_Policy_Content { $policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' ); - if ( ! $policy_page_id || $policy_page_id != $post->ID ) { + if ( ! $policy_page_id || $policy_page_id !== $post->ID ) { return; } - ?> -
-

- Check out our guide%3$s for recommendations on what content to include, along with policies suggested by your plugins and theme.' ), - esc_url( admin_url( 'tools.php?wp-privacy-policy-guide=1' ) ), - 'target="_blank"', - sprintf( - ' %s', - /* translators: accessibility text */ - __( '(opens in a new tab)' ) - ) - ); - ?> -

-
- is_block_editor() ) { + wp_enqueue_script( 'wp-notices' ); + $action = array( + 'url' => $url, + 'label' => $label, + ); + wp_add_inline_script( + 'wp-notices', + sprintf( + 'wp.data.dispatch( "core/notices" ).createWarningNotice( "%s", { actions: [ %s ], isDismissible: false } )', + $message, + wp_json_encode( $action ) + ), + 'after' + ); + } else { + ?> +
+

+ %3$s%4$s' ), + $url, + 'target="_blank"', + $label, + sprintf( + ' %s', + /* translators: accessibility text */ + __( '(opens in a new tab)' ) + ) + ); + ?> +

+
+