Make WordPress Core

Ticket #50822: 50822.2.diff

File 50822.2.diff, 10.9 KB (added by pbiron, 5 years ago)
  • src/wp-admin/includes/class-wp-debug-data.php

    diff --git a/src/wp-admin/includes/class-wp-debug-data.php b/src/wp-admin/includes/class-wp-debug-data.php
    index 24ca2bdfd2..c5eabca9b6 100644
    a b class WP_Debug_Data { 
    905905                // List all available plugins.
    906906                $plugins        = get_plugins();
    907907                $plugin_updates = get_plugin_updates();
     908                $transient      = get_site_transient( 'update_plugins' );
     909
    908910                $auto_updates   = array();
    909911
    910912                $auto_updates_enabled = wp_is_auto_update_enabled_for_type( 'plugin' );
    class WP_Debug_Data { 
    947949                        }
    948950
    949951                        if ( $auto_updates_enabled ) {
    950                                 if ( in_array( $plugin_path, $auto_updates, 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                                }
     973
     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;
     979                                } else {
     980                                        $enabled = in_array( $plugin_path, $auto_updates, true );
     981                                }
     982
     983                                if ( $enabled ) {
    951984                                        $auto_updates_string = __( 'Auto-updates enabled' );
    952                                         $enabled             = true;
    953 
    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 );
    965985                                } 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                        }
    class WP_Debug_Data { 
    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;
    class WP_Debug_Data { 
    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 {
    1088                                 $auto_updates_string = __( 'Disabled' );
    1089                                 $enabled             = false;
     1123                                $enabled = in_array( $active_theme->stylesheet, $auto_updates, true );
     1124                        }
    10901125
    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 );
     1126                        if ( $enabled ) {
     1127                                $auto_updates_string = __( 'Enabled' );
     1128                        } else {
     1129                                $auto_updates_string = __( 'Disabled' );
    10931130                        }
    10941131
     1132                        /**
     1133                         * Filters the text string of the auto-updates setting for each theme in the Site Health debug data.
     1134                         *
     1135                         * @since 5.5.0
     1136                         *
     1137                         * @param string   $auto_updates_string The string output for the auto-updates column.
     1138                         * @param WP_Theme $theme               An object of theme data.
     1139                         * @param bool     $enabled             Whether auto-updates are enabled for this item.
     1140                         */
     1141                        $auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $active_theme, $enabled );
     1142
    10951143                        $info['wp-active-theme']['fields']['auto_update'] = array(
    10961144                                'label' => __( 'Auto-updates' ),
    10971145                                'value' => $auto_updates_string,
    class WP_Debug_Data { 
    11441192                                        'value' => get_template_directory(),
    11451193                                ),
    11461194                        );
     1195
    11471196                        if ( $auto_updates_enabled ) {
    1148                                 if ( in_array( $parent_theme->stylesheet, $auto_updates, true ) ) {
     1197                                if ( isset( $transient->response[ $parent_theme->stylesheet ] ) ) {
     1198                                        $item = $transient->response[ $parent_theme->stylesheet ];
     1199                                } elseif ( isset( $transient->no_update[ $parent_theme->stylesheet ] ) ) {
     1200                                        $item = $transient->no_update[ $parent_theme->stylesheet ];
     1201                                } else {
     1202                                        $item = (object) array(
     1203                                                'theme'        => $parent_theme->stylesheet,
     1204                                                'new_version'  => $parent_theme->version,
     1205                                                'url'          => '',
     1206                                                'package'      => '',
     1207                                                'requires'     => '',
     1208                                                'requires_php' => '',
     1209                                        );
     1210                                }
     1211
     1212                                /** This action is documented in wp-admin/includes/class-wp-automatic-updater.php */
     1213                                $auto_update_forced = apply_filters( 'auto_update_theme', null, $item );
     1214
     1215                                if ( ! is_null( $auto_update_forced ) ) {
     1216                                        $enabled = $auto_update_forced;
     1217                                } else {
     1218                                        $enabled = in_array( $parent_theme->stylesheet, $auto_updates, true );
     1219                                }
     1220
     1221                                if ( $enabled ) {
    11491222                                        $parent_theme_auto_update_string = __( 'Enabled' );
    11501223                                } else {
    11511224                                        $parent_theme_auto_update_string = __( 'Disabled' );
    11521225                                }
    11531226
     1227                                /**
     1228                                 * Filters the text string of the auto-updates setting for each theme in the Site Health debug data.
     1229                                 *
     1230                                 * @since 5.5.0
     1231                                 *
     1232                                 * @param string   $auto_updates_string The string output for the auto-updates column.
     1233                                 * @param WP_Theme $theme               An object of theme data.
     1234                                 * @param bool     $enabled             Whether auto-updates are enabled for this item.
     1235                                 */
     1236                                $parent_theme_auto_update_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $parent_theme, $enabled );
     1237
    11541238                                $info['wp-parent-theme']['fields']['auto_update'] = array(
    11551239                                        'label' => __( 'Auto-update' ),
    11561240                                        'value' => $parent_theme_auto_update_string,
    class WP_Debug_Data { 
    12071291                        }
    12081292
    12091293                        if ( $auto_updates_enabled ) {
    1210                                 if ( in_array( $theme_slug, $auto_updates, true ) ) {
    1211                                         $auto_updates_string = __( 'Auto-updates enabled' );
    1212                                         $enabled             = true;
     1294                                if ( isset( $transient->response[ $theme_slug ] ) ) {
     1295                                        $item = $transient->response[ $theme_slug ];
     1296                                } elseif ( isset( $transient->no_update[ $theme_slug ] ) ) {
     1297                                        $item = $transient->no_update[ $theme_slug ];
     1298                                } else {
     1299                                        $item = (object) array(
     1300                                                'theme'        => $theme_slug,
     1301                                                'new_version'  => $theme->version,
     1302                                                'url'          => '',
     1303                                                'package'      => '',
     1304                                                'requires'     => '',
     1305                                                'requires_php' => '',
     1306                                        );
     1307                                }
     1308
     1309                                /** This action is documented in wp-admin/includes/class-wp-automatic-updater.php */
     1310                                $auto_update_forced = apply_filters( 'auto_update_theme', null, $item );
    12131311
    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 );
     1312                                if ( ! is_null( $auto_update_forced ) ) {
     1313                                        $enabled = $auto_update_forced;
    12161314                                } else {
    1217                                         $auto_updates_string = __( 'Auto-updates disabled' );
    1218                                         $enabled             = false;
     1315                                        $enabled = in_array( $theme_slug, $auto_updates, true );
     1316                                }
    12191317
    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 );
     1318                                if ( $enabled ) {
     1319                                        $auto_updates_string = __( 'Auto-updates enabled' );
     1320                                } else {
     1321                                        $auto_updates_string = __( 'Auto-updates disabled' );
    12221322                                }
    12231323
     1324                                /**
     1325                                 * Filters the text string of the auto-updates setting for each theme in the Site Health debug data.
     1326                                 *
     1327                                 * @since 5.5.0
     1328                                 *
     1329                                 * @param string   $auto_updates_string The string output for the auto-updates column.
     1330                                 * @param WP_Theme $theme               An object of theme data.
     1331                                 * @param bool     $enabled             Whether auto-updates are enabled for this item.
     1332                                 */
     1333                                $auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $theme, $enabled );
     1334
    12241335                                $theme_version_string       .= ' | ' . $auto_updates_string;
    12251336                                $theme_version_string_debug .= ',' . $auto_updates_string;
    12261337                        }