Skip to content

Commit

Permalink
Privacy: Only link to menus panel in Customizer if selected privacy p…
Browse files Browse the repository at this point in the history
…age can be accessed there.

Props dlh.
Fixes #44117.


git-svn-id: https://develop.svn.wordpress.org/trunk@43343 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
westonruter committed Jun 14, 2018
1 parent 517cdca commit 802139d
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions src/wp-admin/privacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,33 @@
$privacy_policy_page_id = isset( $_POST['page_for_privacy_policy'] ) ? (int) $_POST['page_for_privacy_policy'] : 0;
update_option( 'wp_page_for_privacy_policy', $privacy_policy_page_id );

$privacy_page_updated_message = __( 'Privacy policy page updated successfully.' );

if ( $privacy_policy_page_id ) {
/*
* Don't always link to the menu customizer:
*
* - Unpublished pages can't be selected by default.
* - `WP_Customize_Nav_Menus::__construct()` checks the user's capabilities.
* - Themes might not "officially" support menus.
*/
if (
'publish' === get_post_status( $privacy_policy_page_id )
&& current_user_can( 'edit_theme_options' )
&& current_theme_supports( 'menus' )
) {
$privacy_page_updated_message = sprintf(
/* translators: %s: URL to Customizer -> Menus */
__( 'Privacy policy page updated successfully. Remember to <a href="%s">update your menus</a>!' ),
esc_url( add_query_arg( 'autofocus[panel]', 'nav_menus', admin_url( 'customize.php' ) ) )
);
}
}

add_settings_error(
'page_for_privacy_policy',
'page_for_privacy_policy',
sprintf(
/* translators: %s: URL to Customizer -> Menus */
__( 'Privacy policy page updated successfully. Remember to <a href="%s">update your menus</a>!' ),
'customize.php?autofocus[panel]=nav_menus'
),
$privacy_page_updated_message,
'updated'
);
} elseif ( 'create-privacy-page' === $action ) {
Expand Down

0 comments on commit 802139d

Please sign in to comment.