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
This commit is contained in:
aduth 2019-04-12 18:19:51 +00:00
parent 79f8d9786d
commit 7f456cab7d
2 changed files with 48 additions and 22 deletions

View File

@ -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;
}
?>
<div class="notice notice-warning inline wp-pp-notice">
<p>
<?php
/* translators: 1: Privacy Policy guide URL, 2: additional link attributes, 3: accessibility text */
printf(
__( 'Need help putting together your new Privacy Policy page? <a href="%1$s" %2$s>Check out our guide%3$s</a> 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(
'<span class="screen-reader-text"> %s</span>',
/* translators: accessibility text */
__( '(opens in a new tab)' )
)
);
?>
</p>
</div>
<?php
$message = __( 'Need help putting together your new Privacy Policy page? Check out our guide for recommendations on what content to include, along with policies suggested by your plugins and theme.' );
$url = esc_url( admin_url( 'tools.php?wp-privacy-policy-guide=1' ) );
$label = __( 'View Privacy Policy Guide.' );
if ( get_current_screen()->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 {
?>
<div class="notice notice-warning inline wp-pp-notice">
<p>
<?php
echo $message;
printf(
/* translators: 1: Privacy Policy guide URL, 2: additional link attributes, 3: link text 4: accessibility text */
__( ' <a href="%1$s" %2$s>%3$s%4$s</a>' ),
$url,
'target="_blank"',
$label,
sprintf(
'<span class="screen-reader-text"> %s</span>',
/* translators: accessibility text */
__( '(opens in a new tab)' )
)
);
?>
</p>
</div>
<?php
}
}
/**

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.2-beta2-45173';
$wp_version = '5.2-beta2-45174';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.