Ticket #31532: 31532.diff
| File 31532.diff, 3.0 KB (added by , 11 years ago) |
|---|
-
src/wp-admin/admin-ajax.php
61 61 'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor', 62 62 'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs', 63 63 'save-user-color-scheme', 'update-widget', 'query-themes', 'parse-embed', 'set-attachment-thumbnail', 64 'parse-media-shortcode', 'destroy-sessions', 'install-plugin', ' update-plugin', 'press-this-save-post',65 'press-this- add-category',64 'parse-media-shortcode', 'destroy-sessions', 'install-plugin', 'activate-plugin', 'update-plugin', 65 'press-this-save-post', 'press-this-add-category', 66 66 ); 67 67 68 68 // Register core Ajax calls. -
src/wp-admin/includes/ajax-actions.php
2919 2919 wp_send_json_error( $status ); 2920 2920 } 2921 2921 2922 if ( is_multisite() ) { 2923 wp_send_json_success( $status ); 2924 } 2925 2922 2926 $plugin_status = install_plugin_install_status( $api ); 2927 $plugin = $plugin_status['file']; 2923 2928 2924 if ( ! is_multisite() ) { 2925 activate_plugin( $plugin_status['file'] ); 2929 $url = admin_url( 'admin-ajax.php' ); 2930 $args = array( 2931 /** This filter is documented in wp-includes/class-http.php */ 2932 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), 2933 'body' => array( 2934 'action' => 'activate-plugin', 2935 'nonce' => wp_create_nonce( 'ajax-activate-plugin_' . $plugin ), 2936 'plugin' => $plugin, 2937 ), 2938 'cookies' => array( 2939 LOGGED_IN_COOKIE => $_COOKIE[ LOGGED_IN_COOKIE ], 2940 ), 2941 ); 2942 2943 $response = wp_remote_post( $url, $args ); 2944 2945 if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { 2946 $status['error'] = __( 'Could not activate plugin.' ); 2947 wp_send_json_error( $status ); 2926 2948 } 2927 2949 2950 $body = wp_remote_retrieve_body( $response ); 2951 $activate_result = json_decode( $body ); 2952 2953 if ( null === $activate_result ) { 2954 $status['error'] = __( 'Could not activate plugin.' ); 2955 wp_send_json_error( $status ); 2956 } 2957 2958 if ( false === $activate_result->success ) { 2959 $status['error'] = $activate_result->data; 2960 wp_send_json_error( $status ); 2961 } 2962 2928 2963 wp_send_json_success( $status ); 2929 2964 } 2930 2965 2931 2966 /** 2967 * AJAX handler for activating a plugin. 2968 * 2969 * @since 4.2.0 2970 */ 2971 function wp_ajax_activate_plugin() { 2972 $plugin = $_POST['plugin']; 2973 2974 $verify = wp_verify_nonce( $_POST['nonce'], 'ajax-activate-plugin_' . $plugin ); 2975 2976 if ( ! $verify ) { 2977 wp_send_json_error( __( 'Could not activate plugin.' ) ); 2978 } 2979 2980 include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); 2981 2982 $result = activate_plugin( $plugin ); 2983 2984 if ( is_wp_error( $result ) ) { 2985 wp_send_json_error( $result->get_error_message() ); 2986 } 2987 2988 wp_send_json_success( true ); 2989 } 2990 2991 /** 2932 2992 * AJAX handler for updating a plugin. 2933 2993 * 2934 2994 * @since 4.2.0