Changeset 31811 for trunk/src/wp-admin/includes/ajax-actions.php
- Timestamp:
- 03/18/2015 03:17:59 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ajax-actions.php
r31755 r31811 2914 2914 $status['error'] = $result->get_error_message(); 2915 2915 wp_send_json_error( $status ); 2916 } else if ( is_null( $result ) ) { 2917 $status['errorCode'] = 'unable_to_connect_to_filesystem'; 2918 $status['error'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' ); 2919 wp_send_json_error( $status ); 2916 2920 } 2917 2921 … … 2934 2938 2935 2939 $status = array( 2936 'update' => 'plugin', 2937 'plugin' => $plugin, 2938 'slug' => sanitize_key( $_POST['slug'] ), 2940 'update' => 'plugin', 2941 'plugin' => $plugin, 2942 'slug' => sanitize_key( $_POST['slug'] ), 2943 'oldVersion' => '', 2944 'newVersion' => '', 2939 2945 ); 2946 $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); 2947 if ( $plugin_data['Version'] ) { 2948 $status['oldVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); 2949 } 2940 2950 2941 2951 if ( ! current_user_can( 'update_plugins' ) ) { … … 2957 2967 2958 2968 if ( is_array( $result ) ) { 2959 $result = $result[ $plugin ]; 2960 } 2961 2962 if ( is_wp_error( $result ) ) { 2969 $plugin_update_data = current( $result ); 2970 /* 2971 * If the `update_plugins` site transient is empty (e.g. when you update 2972 * two plugins in quick succession before the transient repopulates), 2973 * this may be the return. 2974 * 2975 * Preferably something can be done to ensure `update_plugins` isn't empty. 2976 * For now, surface some sort of error here. 2977 */ 2978 if ( $plugin_update_data === true ) { 2979 wp_send_json_error( $status ); 2980 } 2981 $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); 2982 if ( $plugin_data['Version'] ) { 2983 $status['newVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); 2984 } 2985 wp_send_json_success( $status ); 2986 } else if ( is_wp_error( $result ) ) { 2963 2987 $status['error'] = $result->get_error_message(); 2964 2988 wp_send_json_error( $status ); 2965 } 2966 2967 wp_send_json_success( $status ); 2989 } else if ( is_bool( $result ) && ! $result ) { 2990 $status['errorCode'] = 'unable_to_connect_to_filesystem'; 2991 $status['error'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' ); 2992 wp_send_json_error( $status ); 2993 } 2968 2994 } 2969 2995
Note: See TracChangeset
for help on using the changeset viewer.