Make WordPress Core

Ticket #50822: 50822.3.diff

File 50822.3.diff, 10.2 KB (added by SergeyBiryukov, 5 years ago)
  • src/wp-admin/includes/class-wp-debug-data.php

     
    905905                // List all available plugins.
    906906                $plugins        = get_plugins();
    907907                $plugin_updates = get_plugin_updates();
    908                 $auto_updates   = array();
     908                $transient      = get_site_transient( 'update_plugins' );
    909909
     910                $auto_updates = array();
     911
    910912                $auto_updates_enabled = wp_is_auto_update_enabled_for_type( 'plugin' );
    911913
    912914                if ( $auto_updates_enabled ) {
     
    947949                        }
    948950
    949951                        if ( $auto_updates_enabled ) {
    950                                 if ( in_array( $plugin_path, $auto_updates, true ) ) {
    951                                         $auto_updates_string = __( 'Auto-updates enabled' );
    952                                         $enabled             = true;
     952                                if ( isset( $transient->response[ $plugin_path ] ) ) {
     953                                        $item = $transient->response[ $plugin_path ];
     954                                } elseif ( isset( $transient->no_update[ $plugin_path ] ) ) {
     955                                        $item = $transient->no_update[ $plugin_path ];
     956                                } else {
     957                                        $item = array(
     958                                                'id'            => $plugin_path,
     959                                                'slug'          => '',
     960                                                'plugin'        => $plugin_path,
     961                                                'new_version'   => '',
     962                                                'url'           => '',
     963                                                'package'       => '',
     964                                                'icons'         => array(),
     965                                                'banners'       => array(),
     966                                                'banners_rtl'   => array(),
     967                                                'tested'        => '',
     968                                                'requires_php'  => '',
     969                                                'compatibility' => new stdClass(),
     970                                        );
     971                                        $item = (object) array_merge( $item, array_intersect_key( $plugin, $item ) );
     972                                }
    953973
    954                                         /**
    955                                          * Filters the text string of the auto-updates setting for each plugin in the Site Health debug data.
    956                                          *
    957                                          * @since 5.5.0
    958                                          *
    959                                          * @param string $auto_updates_string The string output for the auto-updates column.
    960                                          * @param string $plugin_path         The path to the plugin file.
    961                                          * @param array  $plugin              An array of plugin data.
    962                                          * @param bool   $enabled             Whether auto-updates are enabled for this item.
    963                                          */
    964                                         $auto_updates_string = apply_filters( 'plugin_auto_update_debug_string', $auto_updates_string, $plugin_path, $plugin, $enabled );
     974                                /** This action is documented in wp-admin/includes/class-wp-automatic-updater.php */
     975                                $auto_update_forced = apply_filters( 'auto_update_plugin', null, $item );
     976
     977                                if ( ! is_null( $auto_update_forced ) ) {
     978                                        $enabled = $auto_update_forced;
    965979                                } else {
     980                                        $enabled = in_array( $plugin_path, $auto_updates, true );
     981                                }
     982
     983                                if ( $enabled ) {
     984                                        $auto_updates_string = __( 'Auto-updates enabled' );
     985                                } else {
    966986                                        $auto_updates_string = __( 'Auto-updates disabled' );
    967                                         $enabled             = false;
    968 
    969                                         /** This filter is documented in wp-admin/includes/class-wp-debug-data.php */
    970                                         $auto_updates_string = apply_filters( 'plugin_auto_update_debug_string', $auto_updates_string, $plugin_path, $plugin, $enabled );
    971987                                }
    972988
     989                                /**
     990                                 * Filters the text string of the auto-updates setting for each plugin in the Site Health debug data.
     991                                 *
     992                                 * @since 5.5.0
     993                                 *
     994                                 * @param string $auto_updates_string The string output for the auto-updates column.
     995                                 * @param string $plugin_path         The path to the plugin file.
     996                                 * @param array  $plugin              An array of plugin data.
     997                                 * @param bool   $enabled             Whether auto-updates are enabled for this item.
     998                                 */
     999                                $auto_updates_string = apply_filters( 'plugin_auto_update_debug_string', $auto_updates_string, $plugin_path, $plugin, $enabled );
     1000
    9731001                                $plugin_version_string       .= ' | ' . $auto_updates_string;
    9741002                                $plugin_version_string_debug .= ', ' . $auto_updates_string;
    9751003                        }
     
    9931021
    9941022                $active_theme  = wp_get_theme();
    9951023                $theme_updates = get_theme_updates();
     1024                $transient     = get_site_transient( 'update_themes' );
    9961025
    9971026                $active_theme_version       = $active_theme->version;
    9981027                $active_theme_version_debug = $active_theme_version;
     
    10701099                );
    10711100
    10721101                if ( $auto_updates_enabled ) {
    1073                         if ( in_array( $active_theme->stylesheet, $auto_updates, true ) ) {
    1074                                 $auto_updates_string = __( 'Enabled' );
    1075                                 $enabled             = true;
     1102                        if ( isset( $transient->response[ $active_theme->stylesheet ] ) ) {
     1103                                $item = $transient->response[ $active_theme->stylesheet ];
     1104                        } elseif ( isset( $transient->no_update[ $active_theme->stylesheet ] ) ) {
     1105                                $item = $transient->no_update[ $active_theme->stylesheet ];
     1106                        } else {
     1107                                $item = (object) array(
     1108                                        'theme'        => $active_theme->stylesheet,
     1109                                        'new_version'  => $active_theme->version,
     1110                                        'url'          => '',
     1111                                        'package'      => '',
     1112                                        'requires'     => '',
     1113                                        'requires_php' => '',
     1114                                );
     1115                        }
    10761116
    1077                                 /**
    1078                                  * Filters the text string of the auto-updates setting for each theme in the Site Health debug data.
    1079                                  *
    1080                                  * @since 5.5.0
    1081                                  *
    1082                                  * @param string   $auto_updates_string The string output for the auto-updates column.
    1083                                  * @param WP_Theme $theme               An object of theme data.
    1084                                  * @param bool     $enabled             Whether auto-updates are enabled for this item.
    1085                                  */
    1086                                 $auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $active_theme, $enabled );
     1117                        /** This action is documented in wp-admin/includes/class-wp-automatic-updater.php */
     1118                        $auto_update_forced = apply_filters( 'auto_update_theme', null, $item );
     1119
     1120                        if ( ! is_null( $auto_update_forced ) ) {
     1121                                $enabled = $auto_update_forced;
    10871122                        } else {
     1123                                $enabled = in_array( $active_theme->stylesheet, $auto_updates, true );
     1124                        }
     1125
     1126                        if ( $enabled ) {
     1127                                $auto_updates_string = __( 'Enabled' );
     1128                        } else {
    10881129                                $auto_updates_string = __( 'Disabled' );
    1089                                 $enabled             = false;
    1090 
    1091                                 /** This filter is documented in wp-admin/includes/class-wp-debug-data.php */
    1092                                 $auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $active_theme, $enabled );
    10931130                        }
    10941131
     1132                        /** This filter is documented in wp-admin/includes/class-wp-debug-data.php */
     1133                        $auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $active_theme, $enabled );
     1134
    10951135                        $info['wp-active-theme']['fields']['auto_update'] = array(
    10961136                                'label' => __( 'Auto-updates' ),
    10971137                                'value' => $auto_updates_string,
     
    11441184                                        'value' => get_template_directory(),
    11451185                                ),
    11461186                        );
     1187
    11471188                        if ( $auto_updates_enabled ) {
    1148                                 if ( in_array( $parent_theme->stylesheet, $auto_updates, true ) ) {
     1189                                if ( isset( $transient->response[ $parent_theme->stylesheet ] ) ) {
     1190                                        $item = $transient->response[ $parent_theme->stylesheet ];
     1191                                } elseif ( isset( $transient->no_update[ $parent_theme->stylesheet ] ) ) {
     1192                                        $item = $transient->no_update[ $parent_theme->stylesheet ];
     1193                                } else {
     1194                                        $item = (object) array(
     1195                                                'theme'        => $parent_theme->stylesheet,
     1196                                                'new_version'  => $parent_theme->version,
     1197                                                'url'          => '',
     1198                                                'package'      => '',
     1199                                                'requires'     => '',
     1200                                                'requires_php' => '',
     1201                                        );
     1202                                }
     1203
     1204                                /** This action is documented in wp-admin/includes/class-wp-automatic-updater.php */
     1205                                $auto_update_forced = apply_filters( 'auto_update_theme', null, $item );
     1206
     1207                                if ( ! is_null( $auto_update_forced ) ) {
     1208                                        $enabled = $auto_update_forced;
     1209                                } else {
     1210                                        $enabled = in_array( $parent_theme->stylesheet, $auto_updates, true );
     1211                                }
     1212
     1213                                if ( $enabled ) {
    11491214                                        $parent_theme_auto_update_string = __( 'Enabled' );
    11501215                                } else {
    11511216                                        $parent_theme_auto_update_string = __( 'Disabled' );
    11521217                                }
    11531218
     1219                                /** This filter is documented in wp-admin/includes/class-wp-debug-data.php */
     1220                                $parent_theme_auto_update_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $parent_theme, $enabled );
     1221
    11541222                                $info['wp-parent-theme']['fields']['auto_update'] = array(
    11551223                                        'label' => __( 'Auto-update' ),
    11561224                                        'value' => $parent_theme_auto_update_string,
     
    12071275                        }
    12081276
    12091277                        if ( $auto_updates_enabled ) {
    1210                                 if ( in_array( $theme_slug, $auto_updates, true ) ) {
    1211                                         $auto_updates_string = __( 'Auto-updates enabled' );
    1212                                         $enabled             = true;
     1278                                if ( isset( $transient->response[ $theme_slug ] ) ) {
     1279                                        $item = $transient->response[ $theme_slug ];
     1280                                } elseif ( isset( $transient->no_update[ $theme_slug ] ) ) {
     1281                                        $item = $transient->no_update[ $theme_slug ];
     1282                                } else {
     1283                                        $item = (object) array(
     1284                                                'theme'        => $theme_slug,
     1285                                                'new_version'  => $theme->version,
     1286                                                'url'          => '',
     1287                                                'package'      => '',
     1288                                                'requires'     => '',
     1289                                                'requires_php' => '',
     1290                                        );
     1291                                }
    12131292
    1214                                         /** This filter is documented in wp-admin/includes/class-wp-debug-data.php */
    1215                                         $auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $theme, $enabled );
     1293                                /** This action is documented in wp-admin/includes/class-wp-automatic-updater.php */
     1294                                $auto_update_forced = apply_filters( 'auto_update_theme', null, $item );
     1295
     1296                                if ( ! is_null( $auto_update_forced ) ) {
     1297                                        $enabled = $auto_update_forced;
    12161298                                } else {
     1299                                        $enabled = in_array( $theme_slug, $auto_updates, true );
     1300                                }
     1301
     1302                                if ( $enabled ) {
     1303                                        $auto_updates_string = __( 'Auto-updates enabled' );
     1304                                } else {
    12171305                                        $auto_updates_string = __( 'Auto-updates disabled' );
    1218                                         $enabled             = false;
    1219 
    1220                                         /** This filter is documented in wp-admin/includes/class-wp-debug-data.php */
    1221                                         $auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $theme, $enabled );
    12221306                                }
    12231307
     1308                                /**
     1309                                 * Filters the text string of the auto-updates setting for each theme in the Site Health debug data.
     1310                                 *
     1311                                 * @since 5.5.0
     1312                                 *
     1313                                 * @param string   $auto_updates_string The string output for the auto-updates column.
     1314                                 * @param WP_Theme $theme               An object of theme data.
     1315                                 * @param bool     $enabled             Whether auto-updates are enabled for this item.
     1316                                 */
     1317                                $auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $theme, $enabled );
     1318
    12241319                                $theme_version_string       .= ' | ' . $auto_updates_string;
    12251320                                $theme_version_string_debug .= ',' . $auto_updates_string;
    12261321                        }