Ticket #32198: 32198.diff
File 32198.diff, 2.7 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/ajax-actions.php
function wp_ajax_update_plugin() { 2958 2958 $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); 2959 2959 if ( $plugin_data['Version'] ) { 2960 2960 $status['oldVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); 2961 2961 } 2962 2962 2963 2963 if ( ! current_user_can( 'update_plugins' ) ) { 2964 2964 $status['error'] = __( 'You do not have sufficient permissions to update plugins on this site.' ); 2965 2965 wp_send_json_error( $status ); 2966 2966 } 2967 2967 2968 2968 check_ajax_referer( 'updates' ); 2969 2969 2970 2970 include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); 2971 2971 2972 2972 $current = get_site_transient( 'update_plugins' ); 2973 if ( empty( $current ) ) {2973 if ( empty( $current ) || empty( $current->response ) ) { 2974 2974 wp_update_plugins(); 2975 2975 } 2976 2976 2977 2977 $skin = new Automatic_Upgrader_Skin(); 2978 2978 $upgrader = new Plugin_Upgrader( $skin ); 2979 2979 $result = $upgrader->bulk_upgrade( array( $plugin ) ); 2980 2980 2981 2981 if ( is_array( $result ) && empty( $result[$plugin] ) && is_wp_error( $skin->result ) ) { 2982 2982 $result = $skin->result; 2983 2983 } 2984 2984 2985 2985 if ( is_array( $result ) && !empty( $result[ $plugin ] ) ) { 2986 2986 $plugin_update_data = current( $result ); 2987 2987 2988 2988 /* -
src/wp-includes/update.php
function wp_update_plugins( $extra_stats 259 259 // Update last_checked for current to prevent multiple blocking requests if request hangs 260 260 $current->last_checked = time(); 261 261 set_site_transient( 'update_plugins', $current ); 262 262 263 263 $to_send = compact( 'plugins', 'active' ); 264 264 265 265 /** 266 266 * Filter the locales requested for plugin translations. 267 267 * 268 268 * @since 3.7.0 269 269 * 270 270 * @param array $locales Plugin locale. Default is current locale of the site. 271 271 */ 272 272 $locales = apply_filters( 'plugins_update_check_locales', array( get_locale() ) ); 273 273 274 if ( defined( 'DOING_CRON' ) && DOING_CRON) {274 if ( ( defined( 'DOING_CRON' ) && DOING_CRON ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { 275 275 $timeout = 30; 276 276 } else { 277 277 // Three seconds, plus one extra second for every 10 plugins 278 278 $timeout = 3 + (int) ( count( $plugins ) / 10 ); 279 279 } 280 280 281 281 $options = array( 282 282 'timeout' => $timeout, 283 283 'body' => array( 284 284 'plugins' => wp_json_encode( $to_send ), 285 285 'translations' => wp_json_encode( $translations ), 286 286 'locale' => wp_json_encode( $locales ), 287 287 'all' => wp_json_encode( true ), 288 288 ), 289 289 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )