From 154e0bd880b501ce309fbe23e05129352106a99b Mon Sep 17 00:00:00 2001 From: Miguel Fonseca Date: Wed, 21 Nov 2018 16:17:17 +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. git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43920 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/admin-filters.php | 2 +- src/wp-admin/includes/misc.php | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/includes/admin-filters.php b/src/wp-admin/includes/admin-filters.php index ba2cb7e2bd32..43a159038af1 100644 --- a/src/wp-admin/includes/admin-filters.php +++ b/src/wp-admin/includes/admin-filters.php @@ -144,7 +144,7 @@ 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/src/wp-admin/includes/misc.php b/src/wp-admin/includes/misc.php index caa923f1df5f..b3c4ec4a7c20 100644 --- a/src/wp-admin/includes/misc.php +++ b/src/wp-admin/includes/misc.php @@ -1540,10 +1540,13 @@ public static function get_suggested_policy_text() { * 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; }