Make WordPress Core

Changeset 45174


Ignore:
Timestamp:
04/12/2019 06:18:59 PM (5 years ago)
Author:
aduth
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/misc.php

    r44987 r45174  
    16201620     */
    16211621    public static function notice( $post = null ) {
    1622         $post = get_post( $post );
     1622        if ( is_null( $post ) ) {
     1623            global $post;
     1624        } else {
     1625            $post = get_post( $post );
     1626        }
    16231627
    16241628        if ( ! ( $post instanceof WP_Post ) ) {
     
    16321636        $policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' );
    16331637
    1634         if ( ! $policy_page_id || $policy_page_id != $post->ID ) {
     1638        if ( ! $policy_page_id || $policy_page_id !== $post->ID ) {
    16351639            return;
    16361640        }
    16371641
    1638         ?>
    1639         <div class="notice notice-warning inline wp-pp-notice">
    1640             <p>
     1642        $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.' );
     1643        $url     = esc_url( admin_url( 'tools.php?wp-privacy-policy-guide=1' ) );
     1644        $label   = __( 'View Privacy Policy Guide.' );
     1645
     1646        if ( get_current_screen()->is_block_editor() ) {
     1647            wp_enqueue_script( 'wp-notices' );
     1648            $action = array(
     1649                'url'   => $url,
     1650                'label' => $label,
     1651            );
     1652            wp_add_inline_script(
     1653                'wp-notices',
     1654                sprintf(
     1655                    'wp.data.dispatch( "core/notices" ).createWarningNotice( "%s", { actions: [ %s ], isDismissible: false } )',
     1656                    $message,
     1657                    wp_json_encode( $action )
     1658                ),
     1659                'after'
     1660            );
     1661        } else {
     1662            ?>
     1663            <div class="notice notice-warning inline wp-pp-notice">
     1664                <p>
     1665                <?php
     1666                echo $message;
     1667                printf(
     1668                    /* translators: 1: Privacy Policy guide URL, 2: additional link attributes, 3: link text 4: accessibility text */
     1669                    __( ' <a href="%1$s" %2$s>%3$s%4$s</a>' ),
     1670                    $url,
     1671                    'target="_blank"',
     1672                    $label,
     1673                    sprintf(
     1674                        '<span class="screen-reader-text"> %s</span>',
     1675                        /* translators: accessibility text */
     1676                        __( '(opens in a new tab)' )
     1677                    )
     1678                );
     1679                ?>
     1680                </p>
     1681            </div>
    16411682            <?php
    1642             /* translators: 1: Privacy Policy guide URL, 2: additional link attributes, 3: accessibility text */
    1643             printf(
    1644                 __( '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.' ),
    1645                 esc_url( admin_url( 'tools.php?wp-privacy-policy-guide=1' ) ),
    1646                 'target="_blank"',
    1647                 sprintf(
    1648                     '<span class="screen-reader-text"> %s</span>',
    1649                     /* translators: accessibility text */
    1650                     __( '(opens in a new tab)' )
    1651                 )
    1652             );
    1653             ?>
    1654             </p>
    1655         </div>
    1656         <?php
    1657 
     1683        }
    16581684    }
    16591685
Note: See TracChangeset for help on using the changeset viewer.