Skip to content

Commit

Permalink
Display the privacy policy help notice with the admin_notices actio…
Browse files Browse the repository at this point in the history
…n hook.

The new editor does not support the `edit_form_after_title` action hook. Because WordPress Core uses this hook to output the notice, it is not printed to the screen.

After WordPress#11604 is merged, legacy style admin notices (`<div class="notice">...notice content...</div>`) will be consumed by the Notices API and displayed. This change ensures that when WordPress#11604 is merged the privacy policy notice will appear again when editing the privacy policy page.
  • Loading branch information
desrosj committed Nov 16, 2018
1 parent a2ecd1f commit d1fd713
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ function gutenberg_wpautop( $content ) {
remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'gutenberg_wpautop', 6 );


/**
* Check if we need to load the block warning in the Classic Editor.
*
Expand Down Expand Up @@ -304,3 +303,22 @@ function gutenberg_warn_classic_about_blocks() {
</script>
<?php
}

/**
* Display the privacy policy help notice.
*
* In Gutenberg, the `edit_form_after_title` hook is not supported. Because
* WordPress Core uses this hook to display this notice, it never displays.
* Outputting the notice on the `admin_notices` hook allows Gutenberg to
* consume the notice and display it with the Notices API.
*/
function gutenberg_show_privacy_policy_help_text() {
if ( is_gutenberg_page() ) {
remove_action( 'edit_form_after_title', array( 'WP_Privacy_Policy_Content', 'notice' ) );

global $post;

WP_Privacy_Policy_Content::notice( $post );
}
}
add_action( 'admin_notices', 'gutenberg_show_privacy_policy_help_text' );

0 comments on commit d1fd713

Please sign in to comment.