Changeset 48899
- Timestamp:
- 08/27/2020 10:22:23 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-ms-themes-list-table.php
r48660 r48899 152 152 $themes[ $filter ][ $key ] = $themes['all'][ $key ]; 153 153 154 $theme_data = array( 155 'update_supported' => isset( $theme->update_supported ) ? $theme->update_supported : true, 156 ); 157 158 // Extra info if known. array_merge() ensures $theme_data has precedence if keys collide. 159 if ( isset( $current->response[ $key ] ) ) { 160 $theme_data = array_merge( (array) $current->response[ $key ], $theme_data ); 161 } elseif ( isset( $current->no_update[ $key ] ) ) { 162 $theme_data = array_merge( (array) $current->no_update[ $key ], $theme_data ); 163 } else { 164 $theme_data['update_supported'] = false; 165 } 166 167 $theme->update_supported = $theme_data['update_supported']; 168 169 /* 170 * Create the expected payload for the auto_update_theme filter, this is the same data 171 * as contained within $updates or $no_updates but used when the Theme is not known. 172 */ 173 $filter_payload = array( 174 'theme' => $key, 175 'new_version' => '', 176 'url' => '', 177 'package' => '', 178 'requires' => '', 179 'requires_php' => '', 180 ); 181 182 $filter_payload = array_merge( $filter_payload, array_intersect_key( $theme_data, $filter_payload ) ); 183 184 $type = 'theme'; 185 /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */ 186 $auto_update_forced = apply_filters( "auto_update_{$type}", null, (object) $filter_payload ); 187 188 if ( ! is_null( $auto_update_forced ) ) { 189 $theme->auto_update_forced = $auto_update_forced; 190 } 191 154 192 if ( $this->show_autoupdates ) { 155 if ( in_array( $key, $auto_updates, true ) ) { 156 $themes['auto-update-enabled'][ $key ] = $themes['all'][ $key ]; 193 $enabled = in_array( $key, $auto_updates, true ) && $theme->update_supported; 194 if ( isset( $theme->auto_update_forced ) ) { 195 $enabled = (bool) $theme->auto_update_forced; 196 } 197 198 if ( $enabled ) { 199 $themes['auto-update-enabled'][ $key ] = $theme; 157 200 } else { 158 $themes['auto-update-disabled'][ $key ] = $theme s['all'][ $key ];201 $themes['auto-update-disabled'][ $key ] = $theme; 159 202 } 160 203 } … … 729 772 $stylesheet = $theme->get_stylesheet(); 730 773 731 if ( in_array( $stylesheet, $auto_updates, true ) ) { 774 if ( isset( $theme->auto_update_forced ) ) { 775 if ( $theme->auto_update_forced ) { 776 // Forced on. 777 $text = __( 'Auto-updates enabled' ); 778 } else { 779 $text = __( 'Auto-updates disabled' ); 780 } 781 $action = 'unavailable'; 782 $time_class = ' hidden'; 783 } elseif ( empty( $theme->update_supported ) ) { 784 $text = ''; 785 $action = 'unavailable'; 786 $time_class = ' hidden'; 787 } elseif ( in_array( $stylesheet, $auto_updates, true ) ) { 732 788 $text = __( 'Disable auto-updates' ); 733 789 $action = 'disable'; … … 748 804 $url = add_query_arg( $query_args, 'themes.php' ); 749 805 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 ); 755 756 $html[] = '<span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span>'; 757 $html[] = '<span class="label">' . $text . '</span>'; 758 $html[] = '</a>'; 759 760 $available_updates = get_site_transient( 'update_themes' ); 806 if ( 'unavailable' === $action ) { 807 $html[] = '<span class="label">' . $text . '</span>'; 808 } else { 809 $html[] = sprintf( 810 '<a href="%s" class="toggle-auto-update aria-button-if-js" data-wp-action="%s">', 811 wp_nonce_url( $url, 'updates' ), 812 $action 813 ); 814 815 $html[] = '<span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span>'; 816 $html[] = '<span class="label">' . $text . '</span>'; 817 $html[] = '</a>'; 818 819 } 820 761 821 if ( isset( $available_updates->response[ $stylesheet ] ) ) { 762 822 $html[] = sprintf(
Note: See TracChangeset
for help on using the changeset viewer.