diff --git a/wp-admin/includes/class-wp-ms-themes-list-table.php b/wp-admin/includes/class-wp-ms-themes-list-table.php
index f67c7bd693..d6f28324f6 100644
a
|
b
|
class WP_MS_Themes_List_Table extends WP_List_Table { |
151 | 151 | $filter = $theme->is_allowed( $allowed_where, $this->site_id ) ? 'enabled' : 'disabled'; |
152 | 152 | $themes[ $filter ][ $key ] = $themes['all'][ $key ]; |
153 | 153 | |
| 154 | $theme_data = array(); |
| 155 | // Extra info if known. array_merge() ensures $theme_data has precedence if keys collide. |
| 156 | if ( isset( $current->response[ $key ] ) ) { |
| 157 | $theme_data = array_merge( (array) $current->response[ $key ], array( 'update_supported' => isset( $theme->update_supported ) ? $theme->update_supported : true ) ); |
| 158 | } elseif ( isset( $current->no_update[ $key ] ) ) { |
| 159 | $theme_data = array_merge( (array) $current->no_update[ $key ], array( 'update_supported' => isset( $theme->update_supported ) ? $theme->update_supported : true ) ); |
| 160 | } else { |
| 161 | $theme_data['update_supported'] = false; |
| 162 | } |
| 163 | $theme->update_supported = $theme_data['update_supported']; |
| 164 | |
| 165 | /* |
| 166 | * Create the expected payload for the auto_update_theme filter, this is the same data |
| 167 | * as contained within $updates or $no_updates but used when the Theme is not known. |
| 168 | */ |
| 169 | $filter_payload = array( |
| 170 | 'theme' => $key, |
| 171 | 'new_version' => '', |
| 172 | 'url' => '', |
| 173 | 'package' => '', |
| 174 | 'requires' => '', |
| 175 | 'requires_php' => '', |
| 176 | ); |
| 177 | |
| 178 | $filter_payload = array_merge( $filter_payload, array_intersect_key( $theme_data, $filter_payload ) ); |
| 179 | |
| 180 | $type = 'theme'; |
| 181 | /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */ |
| 182 | $auto_update_forced = apply_filters( "auto_update_{$type}", null, (object) $filter_payload ); |
| 183 | |
| 184 | if ( ! is_null( $auto_update_forced ) ) { |
| 185 | $theme->auto_update_forced = $auto_update_forced; |
| 186 | } |
| 187 | |
154 | 188 | if ( $this->show_autoupdates ) { |
155 | | if ( in_array( $key, $auto_updates, true ) ) { |
156 | | $themes['auto-update-enabled'][ $key ] = $themes['all'][ $key ]; |
| 189 | $enabled = in_array( $key, $auto_updates, true ) && $theme->update_supported; |
| 190 | if ( isset( $theme->auto_update_forced ) ) { |
| 191 | $enabled = (bool) $theme->auto_update_forced; |
| 192 | } |
| 193 | |
| 194 | if ( $enabled ) { |
| 195 | $themes['auto-update-enabled'][ $key ] = $theme; |
157 | 196 | } else { |
158 | | $themes['auto-update-disabled'][ $key ] = $themes['all'][ $key ]; |
| 197 | $themes['auto-update-disabled'][ $key ] = $theme; |
159 | 198 | } |
160 | 199 | } |
161 | 200 | } |
… |
… |
class WP_MS_Themes_List_Table extends WP_List_Table { |
728 | 767 | |
729 | 768 | $stylesheet = $theme->get_stylesheet(); |
730 | 769 | |
731 | | if ( in_array( $stylesheet, $auto_updates, true ) ) { |
| 770 | if ( isset( $theme->auto_update_forced ) ) { |
| 771 | if ( $theme->auto_update_forced ) { |
| 772 | // Forced on. |
| 773 | $text = __( 'Auto-updates enabled' ); |
| 774 | } else { |
| 775 | $text = __( 'Auto-updates disabled' ); |
| 776 | } |
| 777 | $action = 'unavailable'; |
| 778 | $time_class = ' hidden'; |
| 779 | } elseif ( empty( $theme->update_supported ) ) { |
| 780 | $text = ''; |
| 781 | $action = 'unavailable'; |
| 782 | $time_class = ' hidden'; |
| 783 | } elseif ( in_array( $stylesheet, $auto_updates, true ) ) { |
732 | 784 | $text = __( 'Disable auto-updates' ); |
733 | 785 | $action = 'disable'; |
734 | 786 | $time_class = ''; |
… |
… |
class WP_MS_Themes_List_Table extends WP_List_Table { |
747 | 799 | |
748 | 800 | $url = add_query_arg( $query_args, 'themes.php' ); |
749 | 801 | |
750 | | $html[] = sprintf( |
751 | | '<a href="%s" class="toggle-auto-update aria-button-if-js" data-wp-action="%s">', |
752 | | wp_nonce_url( $url, 'updates' ), |
753 | | $action |
754 | | ); |
| 802 | if ( 'unavailable' === $action ) { |
| 803 | $html[] = '<span class="label">' . $text . '</span>'; |
| 804 | } else { |
| 805 | $html[] = sprintf( |
| 806 | '<a href="%s" class="toggle-auto-update aria-button-if-js" data-wp-action="%s">', |
| 807 | wp_nonce_url( $url, 'updates' ), |
| 808 | $action |
| 809 | ); |
755 | 810 | |
756 | | $html[] = '<span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span>'; |
757 | | $html[] = '<span class="label">' . $text . '</span>'; |
758 | | $html[] = '</a>'; |
| 811 | $html[] = '<span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span>'; |
| 812 | $html[] = '<span class="label">' . $text . '</span>'; |
| 813 | $html[] = '</a>'; |
| 814 | |
| 815 | } |
759 | 816 | |
760 | | $available_updates = get_site_transient( 'update_themes' ); |
761 | 817 | if ( isset( $available_updates->response[ $stylesheet ] ) ) { |
762 | 818 | $html[] = sprintf( |
763 | 819 | '<div class="auto-update-time%s">%s</div>', |