Ticket #43954: 43954.2.diff
File 43954.2.diff, 9.4 KB (added by , 7 years ago) |
---|
-
src/wp-admin/css/forms.css
1089 1089 } 1090 1090 1091 1091 .tools-privacy-edit { 1092 margin: 2.3em 0;1092 margin: 1.5em 0; 1093 1093 } 1094 1094 1095 1095 .tools-privacy-policy-page span { -
src/wp-admin/includes/admin-filters.php
138 138 add_action( 'wp_privacy_personal_data_export_file', 'wp_privacy_generate_personal_data_export_file', 10 ); 139 139 140 140 // Privacy policy text changes check. 141 add_action( 'admin_init', array( 'WP_Privacy_Policy_Content', 'text_change_check' ), 20 );141 add_action( 'admin_init', array( 'WP_Privacy_Policy_Content', 'text_change_check' ), 100 ); 142 142 143 143 // Show a "postbox" with the text suggestions for a privacy policy. 144 144 add_action( 'edit_form_after_title', array( 'WP_Privacy_Policy_Content', 'notice' ) ); … … 146 146 // Add the suggested policy text from WordPress. 147 147 add_action( 'admin_init', array( 'WP_Privacy_Policy_Content', 'add_suggested_content' ), 1 ); 148 148 149 // Stop checking for text changes afterthe policy page is updated.149 // Update the cached policy info when the policy page is updated. 150 150 add_action( 'post_updated', array( 'WP_Privacy_Policy_Content', '_policy_page_updated' ) ); -
src/wp-admin/includes/misc.php
1320 1320 1321 1321 // The site doesn't have a privacy policy. 1322 1322 if ( empty( $policy_page_id ) ) { 1323 return ;1323 return false; 1324 1324 } 1325 1325 1326 1326 if ( ! current_user_can( 'edit_post', $policy_page_id ) ) { 1327 return ;1327 return false; 1328 1328 } 1329 1329 1330 // Also run when the option doesn't exist yet. 1331 if ( get_option( '_wp_privacy_text_change_check' ) === 'no-check' ) { 1332 return; 1330 $old = (array) get_post_meta( $policy_page_id, '_wp_suggested_privacy_policy_content' ); 1331 1332 // The users have never seen the Privacy Policy Guide screen (usually happens after fresh install or update). 1333 // No point to show warnings about updated content there. 1334 if ( empty( $old ) ) { 1335 return false; 1333 1336 } 1334 1337 1335 $old = (array) get_post_meta( $policy_page_id, '_wp_suggested_privacy_policy_content' ); 1338 $cached = get_option( '_wp_suggested_policy_text_has_changed' ); 1339 1340 // Too early to get the privacy info, use the cache. 1341 // This check also runs on the 'admin_init' action and will update the cache if needed. 1342 if ( ! did_action( 'admin_init' ) ) { 1343 return $cached === 'changed'; 1344 } 1345 1336 1346 $new = self::$policy_content; 1337 1347 1338 1348 // Remove the extra values added to the meta. 1339 1349 foreach ( $old as $key => $data ) { 1340 $old[ $key ] = array( 1341 'plugin_name' => $data['plugin_name'], 1342 'policy_text' => $data['policy_text'], 1343 ); 1350 if ( ! empty( $data['removed'] ) ) { 1351 unset( $old[ $key ] ); 1352 } else { 1353 $old[ $key ] = array( 1354 'plugin_name' => $data['plugin_name'], 1355 'policy_text' => $data['policy_text'], 1356 ); 1357 } 1344 1358 } 1345 1359 1346 1360 // The == operator (equal, not identical) was used intentionally. … … 1347 1361 // See http://php.net/manual/en/language.operators.array.php 1348 1362 if ( $new != $old ) { 1349 1363 // A plugin was activated or deactivated, or some policy text has changed. 1350 // Show a notice on all screens in wp-admin.1364 // Show a notice on the Edit Page screen when editing the policy page. 1351 1365 add_action( 'admin_notices', array( 'WP_Privacy_Policy_Content', 'policy_text_changed_notice' ) ); 1366 $state = 'changed'; 1352 1367 } else { 1353 // Stop checking. 1354 update_option( '_wp_privacy_text_change_check', 'no-check' ); 1368 $state = 'not-changed'; 1355 1369 } 1370 1371 if ( $cached !== $state ) { 1372 update_option( '_wp_suggested_policy_text_has_changed', $state ); 1373 } 1374 1375 return $state === 'changed'; 1356 1376 } 1357 1377 1358 1378 /** 1359 * Output a n admin noticewhen some privacy info has changed.1379 * Output a warning when some privacy info has changed. 1360 1380 * 1361 1381 * @since 4.9.6 1362 1382 */ 1363 1383 public static function policy_text_changed_notice() { 1364 1384 global $post; 1385 1386 $screen = get_current_screen()->id; 1365 1387 $policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' ); 1366 1388 1367 ?> 1368 <div class="policy-text-updated notice notice-warning is-dismissible"> 1369 <p><?php 1370 1371 _e( 'The suggested privacy policy text has changed.' ); 1372 1373 if ( empty( $post ) || $post->ID != $policy_page_id ) { 1374 ?> 1375 <a href="<?php echo get_edit_post_link( $policy_page_id ); ?>"><?php _e( 'Edit the privacy policy.' ); ?></a> 1376 <?php 1377 } 1378 1379 ?></p> 1380 </div> 1381 <?php 1389 if ( $screen === 'privacy' || ( $screen === 'page' && ! empty( $post ) && (int) $post->ID === $policy_page_id ) ) { 1390 ?> 1391 <div class="policy-text-updated notice notice-warning is-dismissible"> 1392 <p><?php _e( 'The suggested privacy policy text has changed. Please update your privacy policy.' ); ?></p> 1393 </div> 1394 <?php 1395 } 1382 1396 } 1383 1397 1384 1398 /** 1385 * Stop checking for changed privacy info when the policy page is updated.1399 * Update the cached policy info when the policy page is updated. 1386 1400 * 1387 1401 * @since 4.9.6 1388 1402 * @access private … … 1394 1408 return; 1395 1409 } 1396 1410 1397 // The policy page was updated.1398 // Stop checking for text changes.1399 update_option( '_wp_privacy_text_change_check', 'no-check' );1400 1401 1411 // Remove updated|removed status. 1402 1412 $old = (array) get_post_meta( $policy_page_id, '_wp_suggested_privacy_policy_content' ); 1403 1413 $done = array(); … … 1496 1506 foreach ( $new as $new_data ) { 1497 1507 if ( ! empty( $new_data['plugin_name'] ) && ! empty( $new_data['policy_text'] ) ) { 1498 1508 $new_data['added'] = $time; 1499 array_unshift( $checked, $new_data );1509 $checked[] = $new_data; 1500 1510 } 1501 1511 } 1502 1512 $update_cache = true; … … 1511 1521 'policy_text' => $old_data['policy_text'], 1512 1522 'removed' => $time, 1513 1523 ); 1514 array_unshift( $checked, $data ); 1524 1525 $checked[] = $data; 1515 1526 } 1516 1527 } 1517 1528 $update_cache = true; … … 1525 1536 } 1526 1537 } 1527 1538 1528 // Stop checking for changes after the page has been loaded.1529 if ( get_option( '_wp_privacy_text_change_check' ) !== 'no-check' ) {1530 update_option( '_wp_privacy_text_change_check', 'no-check' );1531 }1532 1533 1539 return $checked; 1534 1540 } 1535 1541 -
src/wp-admin/menu.php
263 263 $submenu['tools.php'][50] = array( __( 'Network Setup' ), 'setup_network', 'network.php' ); 264 264 } 265 265 266 $menu[80] = array( __( 'Settings' ), 'manage_options', 'options-general.php', '', 'menu-top menu-icon-settings', 'menu-settings', 'dashicons-admin-settings' ); 266 $change_notice = ''; 267 if ( current_user_can( 'manage_privacy_options' ) && WP_Privacy_Policy_Content::text_change_check() ) { 268 $change_notice = ' <span class="update-plugins 1"><span class="plugin-count">' . number_format_i18n( 1 ) . '</span></span>'; 269 } 270 271 $menu[80] = array( sprintf( __( 'Settings %s' ), $change_notice ), 'manage_options', 'options-general.php', '', 'menu-top menu-icon-settings', 'menu-settings', 'dashicons-admin-settings' ); 267 272 $submenu['options-general.php'][10] = array( _x( 'General', 'settings screen' ), 'manage_options', 'options-general.php' ); 268 273 $submenu['options-general.php'][15] = array( __( 'Writing' ), 'manage_options', 'options-writing.php' ); 269 274 $submenu['options-general.php'][20] = array( __( 'Reading' ), 'manage_options', 'options-reading.php' ); … … 270 275 $submenu['options-general.php'][25] = array( __( 'Discussion' ), 'manage_options', 'options-discussion.php' ); 271 276 $submenu['options-general.php'][30] = array( __( 'Media' ), 'manage_options', 'options-media.php' ); 272 277 $submenu['options-general.php'][40] = array( __( 'Permalinks' ), 'manage_options', 'options-permalink.php' ); 273 $submenu['options-general.php'][45] = array( __( 'Privacy'), 'manage_privacy_options', 'privacy.php' );278 $submenu['options-general.php'][45] = array( sprintf( __( 'Privacy %s' ), $change_notice ), 'manage_privacy_options', 'privacy.php' ); 274 279 275 280 $_wp_last_utility_menu = 80; // The index of the last top-level menu in the utility menu group 276 281 -
src/wp-includes/default-filters.php
562 562 // Capabilities 563 563 add_filter( 'user_has_cap', 'wp_maybe_grant_install_languages_cap', 1 ); 564 564 565 // Trigger the check for policy text changes after active plugins change.566 add_action( 'update_site_option_active_sitewide_plugins', '_wp_privacy_active_plugins_change' );567 add_action( 'update_option_active_plugins', '_wp_privacy_active_plugins_change' );568 569 565 unset( $filter, $action ); -
src/wp-includes/functions.php
6249 6249 } 6250 6250 6251 6251 /** 6252 * Trigger the check for policy text changes.6253 *6254 * @since 4.9.66255 * @access private6256 */6257 function _wp_privacy_active_plugins_change() {6258 update_option( '_wp_privacy_text_change_check', 'check' );6259 }6260 6261 /**6262 6252 * Schedule a `WP_Cron` job to delete expired export files. 6263 6253 * 6264 6254 * @since 4.9.6