Make WordPress Core

Ticket #46098: 46098.2.diff

File 46098.2.diff, 2.8 KB (added by xkon, 4 years ago)
  • src/wp-admin/includes/misc.php

    diff --git a/src/wp-admin/includes/misc.php b/src/wp-admin/includes/misc.php
    index d0dc33b913..44045a47f3 100644
    a b final class WP_Privacy_Policy_Content { 
    16191619         * @param WP_Post|null $post The currently edited post. Default null.
    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 ) ) {
    16251629                        return;
    final class WP_Privacy_Policy_Content { 
    16311635
    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>
    1641                         <?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"',
     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',
    16471654                                sprintf(
    1648                                         '<span class="screen-reader-text"> %s</span>',
    1649                                         /* translators: accessibility text */
    1650                                         __( '(opens in a new tab)' )
    1651                                 )
     1655                                        'wp.data.dispatch( "core/notices" ).createWarningNotice( "%s", { actions: [ %s ], isDismissible: false } )',
     1656                                        $message,
     1657                                        wp_json_encode( $action )
     1658                                ),
     1659                                'after'
    16521660                        );
     1661                } else {
    16531662                        ?>
    1654                         </p>
    1655                 </div>
    1656                 <?php
    1657 
     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>
     1682                        <?php
     1683                }
    16581684        }
    16591685
    16601686        /**