Make WordPress Core


Ignore:
Timestamp:
03/26/2015 02:29:52 AM (10 years ago)
Author:
jorbin
Message:

Remove Shiny Plugin Installs

See #31773, #29820

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ajax-actions.php

    r31829 r31897  
    28772877}
    28782878
    2879 /**
    2880  * AJAX handler for installing a plugin.
    2881  *
    2882  * @since 4.2.0
    2883  */
    2884 function wp_ajax_install_plugin() {
    2885     $status = array(
    2886         'install' => 'plugin',
    2887         'slug'    => sanitize_key( $_POST['slug'] ),
    2888     );
    2889 
    2890     if ( ! current_user_can( 'install_plugins' ) ) {
    2891         $status['error'] = __( 'You do not have sufficient permissions to install plugins on this site.' );
    2892         wp_send_json_error( $status );
    2893     }
    2894 
    2895     check_ajax_referer( 'updates' );
    2896 
    2897     include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
    2898     include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
    2899 
    2900     $api = plugins_api( 'plugin_information', array(
    2901         'slug'   => sanitize_key( $_POST['slug'] ),
    2902         'fields' => array( 'sections' => false )
    2903     ) );
    2904 
    2905     if ( is_wp_error( $api ) ) {
    2906         $status['error'] = $api->get_error_message();
    2907         wp_send_json_error( $status );
    2908     }
    2909 
    2910     $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
    2911     $result = $upgrader->install( $api->download_link );
    2912 
    2913     if ( is_wp_error( $result ) ) {
    2914         $status['error'] = $result->get_error_message();
    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 );
    2920     }
    2921 
    2922     $plugin_status = install_plugin_install_status( $api );
    2923 
    2924     if ( ! is_multisite() ) {
    2925         activate_plugin( $plugin_status['file'] );
    2926     }
    2927 
    2928     wp_send_json_success( $status );
    2929 }
    29302879
    29312880/**
Note: See TracChangeset for help on using the changeset viewer.