Make WordPress Core

Ticket #43954: 43954.diff

File 43954.diff, 5.0 KB (added by iandunn, 8 years ago)

Rough WIP to introduce menu update bubble instead of admin notice

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

    diff --git src/wp-admin/includes/admin-filters.php src/wp-admin/includes/admin-filters.php
    index 68592b6d41..9d45dc63af 100644
    add_filter( 'wp_privacy_personal_data_export_page', 'wp_privacy_process_personal 
    138138add_action( 'wp_privacy_personal_data_export_file', 'wp_privacy_generate_personal_data_export_file', 10 );
    139139
    140140// 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' ), 20 );
    142142
    143143// Show a "postbox" with the text suggestions for a privacy policy.
    144144add_action( 'edit_form_after_title', array( 'WP_Privacy_Policy_Content', 'notice' ) );
  • src/wp-admin/includes/misc.php

    diff --git src/wp-admin/includes/misc.php src/wp-admin/includes/misc.php
    index ff8e78a98e..6aa69a8f30 100644
    final class WP_Privacy_Policy_Content { 
    13201320
    13211321                // The site doesn't have a privacy policy.
    13221322                if ( empty( $policy_page_id ) ) {
    1323                         return;
     1323                        return false;
    13241324                }
    13251325
    13261326                if ( ! current_user_can( 'edit_post', $policy_page_id ) ) {
    1327                         return;
     1327                        return false;
    13281328                }
    13291329
    1330                 // Also run when the option doesn't exist yet.
    1331                 if ( get_option( '_wp_privacy_text_change_check' ) === 'no-check' ) {
    1332                         return;
    1333                 }
     1330//              // Also run when the option doesn't exist yet.
     1331//              if ( get_option( '_wp_privacy_text_change_check' ) === 'no-check' ) {
     1332//                      return true;
     1333//              }
    13341334
    13351335                $old = (array) get_post_meta( $policy_page_id, '_wp_suggested_privacy_policy_content' );
    13361336                $new = self::$policy_content;
    final class WP_Privacy_Policy_Content { 
    13461346                // The == operator (equal, not identical) was used intentionally.
    13471347                // See http://php.net/manual/en/language.operators.array.php
    13481348                if ( $new != $old ) {
    1349                         // A plugin was activated or deactivated, or some policy text has changed.
    1350                         // Show a notice on all screens in wp-admin.
    1351                         add_action( 'admin_notices', array( 'WP_Privacy_Policy_Content', 'policy_text_changed_notice' ) );
     1349                        return true;
    13521350                } else {
    1353                         // Stop checking.
    1354                         update_option( '_wp_privacy_text_change_check', 'no-check' );
     1351                        return false;
    13551352                }
    13561353        }
    13571354
    final class WP_Privacy_Policy_Content { 
    13601357         *
    13611358         * @since 4.9.6
    13621359         */
    1363         public static function policy_text_changed_notice() {
     1360        public static function x_policy_text_changed_notice() {
     1361                return;
    13641362                global $post;
     1363
    13651364                $policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' );
     1365                $relevant_screens = array( 'privacy', 'edit-page' );
     1366                $current_screen   = get_current_screen();
     1367var_dump($current_screen);wp_die();
     1368                // if on privacy policy page, then show, b/c otherwise nothing on that page says it
     1369
     1370                if ( ! is_a( $current_screen, 'WP_Screen' ) ) {
     1371                        return;
     1372                }
     1373
     1374                if ( ! in_array( $current_screen->id, $relevant_screens, true ) ) {
     1375                        return;
     1376                }
    13661377
    13671378                ?>
    13681379                <div class="policy-text-updated notice notice-warning is-dismissible">
  • src/wp-admin/menu.php

    diff --git src/wp-admin/menu.php src/wp-admin/menu.php
    index 0ad302ebda..a66cc63127 100644
    if ( ! is_multisite() && defined( 'WP_ALLOW_MULTISITE' ) && WP_ALLOW_MULTISITE ) 
    263263        $submenu['tools.php'][50] = array( __( 'Network Setup' ), 'setup_network', 'network.php' );
    264264}
    265265
    266 $menu[80]                               = array( __( 'Settings' ), 'manage_options', 'options-general.php', '', 'menu-top menu-icon-settings', 'menu-settings', 'dashicons-admin-settings' );
     266$policy_change_notice = current_user_can( 'manage_privacy_options' ) && WP_Privacy_Policy_Content::text_change_check()
     267        ? " <span class='update-plugins count-1}'><span class='plugin-count'>" . number_format_i18n( 1 ) . '</span></span>'
     268        : '';
     269$menu[80]                               = array( __( 'Settings' . $policy_change_notice ), 'manage_options', 'options-general.php', '', 'menu-top menu-icon-settings', 'menu-settings', 'dashicons-admin-settings' );
    267270        $submenu['options-general.php'][10] = array( _x( 'General', 'settings screen' ), 'manage_options', 'options-general.php' );
    268271        $submenu['options-general.php'][15] = array( __( 'Writing' ), 'manage_options', 'options-writing.php' );
    269272        $submenu['options-general.php'][20] = array( __( 'Reading' ), 'manage_options', 'options-reading.php' );
    270273        $submenu['options-general.php'][25] = array( __( 'Discussion' ), 'manage_options', 'options-discussion.php' );
    271274        $submenu['options-general.php'][30] = array( __( 'Media' ), 'manage_options', 'options-media.php' );
    272275        $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' );
     276        $submenu['options-general.php'][45] = array( __( 'Privacy' ) . $policy_change_notice, 'manage_privacy_options', 'privacy.php' );
    274277
    275278$_wp_last_utility_menu = 80; // The index of the last top-level menu in the utility menu group
    276279