Make WordPress Core

Ticket #44100: 44100.2.diff

File 44100.2.diff, 3.9 KB (added by allendav, 7 years ago)

Added is-dismissible

  • src/wp-admin/includes/admin-filters.php

     
    4747
    4848// Privacy tools
    4949add_action( 'admin_menu', '_wp_privacy_hook_requests_page' );
     50add_action( 'admin_notices', '_wp_privacy_unpublished_policy_nag' );
    5051
    5152// Prerendering.
    5253if ( ! is_customize_preview() ) {
  • src/wp-admin/includes/user.php

     
    16111611        }
    16121612
    16131613}
     1614
     1615/**
     1616 * Adds a notice to the privacy settings page and the privacy page edit page
     1617 * if the currently selected privacy page is not published
     1618 *
     1619 * @since 4.9.7
     1620 * @access private
     1621 */
     1622function _wp_privacy_unpublished_policy_nag() {
     1623        global $pagenow;
     1624
     1625        $privacy_policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' );
     1626        if ( empty( $privacy_policy_page_id ) ) {
     1627                return;
     1628        }
     1629
     1630        $privacy_policy_page = get_post( $privacy_policy_page_id );
     1631        if ( 'draft' != $privacy_policy_page->post_status ) {
     1632                return;
     1633        }
     1634
     1635        $edit_href = add_query_arg(
     1636                array(
     1637                        'post'   => $privacy_policy_page_id,
     1638                        'action' => 'edit',
     1639                ),
     1640                admin_url( 'post.php' )
     1641        );
     1642
     1643        $choose_href = admin_url( 'privacy.php' );
     1644
     1645        $notice = sprintf(
     1646                /* translators: 1: URL to edit page, 2: URL to choose page */
     1647                __( 'The currently selected Privacy Policy page is a draft. Please <a href="%1$s">edit</a> and publish it or <a href="%2$s">choose</a> a different page.' ),
     1648                $edit_href,
     1649                $choose_href
     1650        );
     1651
     1652        if ( $pagenow === 'privacy.php' ) {
     1653                $notice = sprintf(
     1654                        /* translators: URL to edit page */
     1655                        __( 'The currently selected Privacy Policy page is a draft. Please <a href="%s">edit</a> and publish it or choose a different page.' ),
     1656                        $edit_href
     1657                );
     1658        } else if ( $pagenow === 'post.php' ) {
     1659                $post_id = isset( $_GET['post'] ) ? (int) sanitize_text_field( $_GET['post'] ) : '';
     1660                $action  = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : '';
     1661
     1662                if ( ( 'edit' === $action ) && ( $privacy_policy_page_id === $post_id ) ) {
     1663                        $notice = sprintf(
     1664                                /* translators: URL to choose page */
     1665                                __( 'This Privacy Policy page is a draft. Please publish it or <a href="%s">choose</a> a different page.' ),
     1666                                $choose_href
     1667                        );
     1668                }
     1669        }
     1670
     1671        ?>
     1672        <div class="notice notice-warning is-dismissible">
     1673                <p>
     1674                        <?php echo wp_kses_post( $notice ); ?>
     1675                </p>
     1676        </div>
     1677        <?php
     1678}
  • src/wp-admin/privacy.php

     
    1313        wp_die( __( 'Sorry, you are not allowed to manage privacy on this site.' ) );
    1414}
    1515
     16/**
     17 * Adds (Draft) to draft page titles in the privacy page dropdown
     18 * to make it clearer when the admin is choosing an unpublished page.
     19 *
     20 * @since 4.9.7
     21 */
     22function _wp_privacy_settings_screen_filter_pages( $title, $page ) {
     23        if ( 'draft' === $page->post_status ) {
     24                /* translators: %s: Page Title */
     25                $title = sprintf( __( '%s (Draft)' ), $title );
     26        }
     27        return $title;
     28}
     29
    1630$action = isset( $_POST['action'] ) ? $_POST['action'] : '';
    1731
    1832if ( ! empty( $action ) ) {
     
    187201                                                </label>
    188202                                                <input type="hidden" name="action" value="set-privacy-page" />
    189203                                                <?php
     204                                                add_filter( 'list_pages', '_wp_privacy_settings_screen_filter_pages', 10, 2 );
    190205                                                wp_dropdown_pages(
    191206                                                        array(
    192207                                                                'name'              => 'page_for_privacy_policy',
     
    196211                                                                'post_status'       => array( 'draft', 'publish' ),
    197212                                                        )
    198213                                                );
     214                                                remove_filter( 'list_pages', '_wp_privacy_settings_screen_filter_pages', 10, 2 );
    199215
    200216                                                wp_nonce_field( 'set-privacy-page' );
    201217