WordPress.org

Make WordPress Core

Ticket #16923: 16923.diff

File 16923.diff, 3.4 KB (added by nacin, 3 years ago)
  • wp-admin/update.php

     
    146146 
    147147                include(ABSPATH . 'wp-admin/admin-footer.php'); 
    148148 
     149        } elseif ( 'sideload-plugin' == $action ) { 
     150 
     151                if ( ! current_user_can('install_plugins') ) 
     152                        wp_die(__('You do not have sufficient permissions to install plugins for this site.')); 
     153 
     154                check_admin_referer('plugin-sideload'); 
     155 
     156                $download_url = esc_url_raw( stripslashes( $_POST['pluginurl'] ) ); 
     157 
     158                $title = __('Plugin Install'); 
     159                $parent_file = 'plugins.php'; 
     160                $submenu_file = 'plugin-install.php'; 
     161                require_once(ABSPATH . 'wp-admin/admin-header.php'); 
     162 
     163                $title = sprintf( __('Installing Plugin from URL: %s'), $download_url ); 
     164                $nonce = 'plugin-sideload'; 
     165                $url = 'update.php?action=sideload-plugin&pluginurl=' . urlencode( stripslashes( $_POST['pluginurl'] ) ); 
     166 
     167                $type = 'web'; 
     168 
     169                $upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact('title', 'url', 'nonce') ) ); 
     170                $upgrader->install( $download_url ); 
     171 
     172                include(ABSPATH . 'wp-admin/admin-footer.php'); 
     173 
    149174        } elseif ( 'upgrade-theme' == $action ) { 
    150175 
    151176                if ( ! current_user_can('update_themes') ) 
  • wp-admin/includes/class-wp-plugin-install-list-table.php

     
    3030                if ( 'search' == $tab ) 
    3131                        $tabs['search'] = __( 'Search Results' ); 
    3232                $tabs['upload'] = __( 'Upload' ); 
     33                $tabs['url'] = __( 'From URL' ); 
    3334                $tabs['featured'] = _x( 'Featured','Plugin Installer' ); 
    3435                $tabs['popular']  = _x( 'Popular','Plugin Installer' ); 
    3536                $tabs['new']      = _x( 'Newest','Plugin Installer' ); 
  • wp-admin/includes/plugin-install.php

     
    136136/** 
    137137 * Upload from zip 
    138138 * @since 2.8.0 
    139  * 
    140  * @param string $page 
    141139 */ 
    142 function install_plugins_upload( $page = 1 ) { 
     140function install_plugins_upload() { 
    143141?> 
    144142        <h4><?php _e('Install a plugin in .zip format') ?></h4> 
    145143        <p class="install-help"><?php _e('If you have a plugin in a .zip format, you may install it by uploading it here.') ?></p> 
     
    151149        </form> 
    152150<?php 
    153151} 
    154 add_action('install_plugins_upload', 'install_plugins_upload', 10, 1); 
     152add_action('install_plugins_upload', 'install_plugins_upload'); 
    155153 
    156154/** 
     155 * Sideload from arbitrary URL 
     156 * @since 3.1.0 
     157 */ 
     158function install_plugins_url() { 
     159?> 
     160        <h4><?php _e('Install a plugin from a URL') ?></h4> 
     161        <p class="install-help"><?php _e('If you have the URL to a plugin in .zip format, you may install it by providing the URL here.') ?></p> 
     162        <form method="post" action="<?php echo self_admin_url('update.php?action=sideload-plugin') ?>"> 
     163                <?php wp_nonce_field( 'plugin-sideload' ) ?> 
     164                <label class="screen-reader-text" for="pluginzip"><?php _e('URL to Plugin zip file'); ?></label> 
     165                <input type="input" type="text" class="large-text" id="pluginurl" name="pluginurl" /> 
     166                <input type="submit" class="button" value="<?php esc_attr_e('Install Now') ?>" /> 
     167        </form> 
     168<?php 
     169} 
     170add_action('install_plugins_url', 'install_plugins_url'); 
     171 
     172/** 
    157173 * Display plugin content based on plugin list. 
    158174 * 
    159175 * @since 2.7.0