| | 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 | */ |
| | 1622 | function _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 | } |