- Timestamp:
- 07/28/2020 04:30:48 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-plugins-list-table.php
r48451 r48669 204 204 // Extra info if known. array_merge() ensures $plugin_data has precedence if keys collide. 205 205 if ( isset( $plugin_info->response[ $plugin_file ] ) ) { 206 $plugin_data = array_merge( (array) $plugin_info->response[ $plugin_file ], $plugin_data ); 207 $plugins['all'][ $plugin_file ] = $plugin_data; 208 // Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade. 209 if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) { 210 $plugins['upgrade'][ $plugin_file ] = $plugin_data; 211 } 206 $plugin_data = array_merge( (array) $plugin_info->response[ $plugin_file ], array( 'auto-update-supported' => true ), $plugin_data ); 212 207 } elseif ( isset( $plugin_info->no_update[ $plugin_file ] ) ) { 213 $plugin_data = array_merge( (array) $plugin_info->no_update[ $plugin_file ], $plugin_data ); 214 $plugins['all'][ $plugin_file ] = $plugin_data; 215 // Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade. 216 if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) { 217 $plugins['upgrade'][ $plugin_file ] = $plugin_data; 218 } 208 $plugin_data = array_merge( (array) $plugin_info->no_update[ $plugin_file ], array( 'auto-update-supported' => true ), $plugin_data ); 209 } elseif ( empty( $plugin_data['auto-update-supported'] ) ) { 210 $plugin_data['auto-update-supported'] = false; 211 } 212 213 /* 214 * Create the payload that's used for the auto_update_plugin filter. 215 * This is the same data contained within $plugin_info->(response|no_update) however 216 * not all plugins will be contained in those keys, this avoids unexpected warnings. 217 */ 218 $filter_payload = array( 219 'id' => $plugin_file, 220 'slug' => '', 221 'plugin' => $plugin_file, 222 'new_version' => '', 223 'url' => '', 224 'package' => '', 225 'icons' => array(), 226 'banners' => array(), 227 'banners_rtl' => array(), 228 'tested' => '', 229 'requires_php' => '', 230 'compatibility' => new stdClass(), 231 ); 232 $filter_payload = (object) array_merge( $filter_payload, array_intersect_key( $plugin_data, $filter_payload ) ); 233 234 /** This action is documented in wp-admin/includes/class-wp-automatic-updater.php */ 235 $auto_update_forced = apply_filters( 'auto_update_plugin', null, $filter_payload ); 236 if ( ! is_null( $auto_update_forced ) ) { 237 $plugin_data['auto-update-forced'] = $auto_update_forced; 238 } 239 240 $plugins['all'][ $plugin_file ] = $plugin_data; 241 // Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade. 242 if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) { 243 $plugins['upgrade'][ $plugin_file ] = $plugin_data; 219 244 } 220 245 … … 1061 1086 $html = array(); 1062 1087 1063 if ( in_array( $plugin_file, $auto_updates, true ) ) { 1088 if ( isset( $plugin_data['auto-update-forced'] ) ) { 1089 if ( $plugin_data['auto-update-forced'] ) { 1090 // Forced on 1091 $text = __( 'Auto-updates enabled' ); 1092 } else { 1093 $text = __( 'Auto-updates disabled' ); 1094 } 1095 $action = 'unavailable'; 1096 $time_class = ' hidden'; 1097 } elseif ( ! $plugin_data['auto-update-supported'] ) { 1098 $text = ''; 1099 $action = 'unavailable'; 1100 $time_class = ' hidden'; 1101 } elseif ( in_array( $plugin_file, $auto_updates, true ) ) { 1064 1102 $text = __( 'Disable auto-updates' ); 1065 1103 $action = 'disable'; … … 1080 1118 $url = add_query_arg( $query_args, 'plugins.php' ); 1081 1119 1082 $html[] = sprintf( 1083 '<a href="%s" class="toggle-auto-update aria-button-if-js" data-wp-action="%s">', 1084 wp_nonce_url( $url, 'updates' ), 1085 $action 1086 ); 1087 1088 $html[] = '<span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span>'; 1089 $html[] = '<span class="label">' . $text . '</span>'; 1090 $html[] = '</a>'; 1091 1092 $available_updates = get_site_transient( 'update_plugins' ); 1093 1094 if ( isset( $available_updates->response[ $plugin_file ] ) ) { 1120 if ( 'unavailable' == $action ) { 1121 $html[] = '<span class="label">' . $text . '</span>'; 1122 } else { 1123 $html[] = sprintf( 1124 '<a href="%s" class="toggle-auto-update aria-button-if-js" data-wp-action="%s">', 1125 wp_nonce_url( $url, 'updates' ), 1126 $action 1127 ); 1128 1129 $html[] = '<span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span>'; 1130 $html[] = '<span class="label">' . $text . '</span>'; 1131 $html[] = '</a>'; 1132 } 1133 1134 if ( ! empty( $plugin_data['update'] ) ) { 1095 1135 $html[] = sprintf( 1096 1136 '<div class="auto-update-time%s">%s</div>',
Note: See TracChangeset
for help on using the changeset viewer.