WordPress.org

Make WordPress Core

Ticket #15129: 15129.2.diff

File 15129.2.diff, 14.8 KB (added by PeteMall, 4 years ago)

Adds plugin update notifications, plugin install, plugin update to the network admin screen.

  • wp-admin/includes/plugin-install.php

     
    101101                $tags = array(); 
    102102                foreach ( (array)$api_tags as $tag ) 
    103103                        $tags[ $tag['name'] ] = (object) array( 
    104                                                                         'link' => esc_url( admin_url('plugin-install.php?tab=search&type=tag&s=' . urlencode($tag['name'])) ), 
     104                                                                        'link' => esc_url( self_admin_url('plugin-install.php?tab=search&type=tag&s=' . urlencode($tag['name'])) ), 
    105105                                                                        'name' => $tag['name'], 
    106106                                                                        'id' => sanitize_title_with_dashes($tag['name']), 
    107107                                                                        'count' => $tag['count'] ); 
     
    143143?> 
    144144        <h4><?php _e('Install a plugin in .zip format') ?></h4> 
    145145        <p class="install-help"><?php _e('If you have a plugin in a .zip format, you may install it by uploading it here.') ?></p> 
    146         <form method="post" enctype="multipart/form-data" action="<?php echo admin_url('update.php?action=upload-plugin') ?>"> 
     146        <form method="post" enctype="multipart/form-data" action="<?php echo self_admin_url('update.php?action=upload-plugin') ?>"> 
    147147                <?php wp_nonce_field( 'plugin-upload') ?> 
    148148                <label class="screen-reader-text" for="pluginzip"><?php _e('Plugin zip file'); ?></label> 
    149149                <input type="file" id="pluginzip" name="pluginzip" /> 
     
    195195                                $update_file = $file; 
    196196                                $version = $plugin->new_version; 
    197197                                if ( current_user_can('update_plugins') ) 
    198                                         $url = wp_nonce_url(admin_url('update.php?action=upgrade-plugin&plugin=' . $update_file), 'upgrade-plugin_' . $update_file); 
     198                                        $url = wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=' . $update_file), 'upgrade-plugin_' . $update_file); 
    199199                                break; 
    200200                        } 
    201201                } 
     
    206206                        $installed_plugin = get_plugins('/' . $api->slug); 
    207207                        if ( empty($installed_plugin) ) { 
    208208                                if ( current_user_can('install_plugins') ) 
    209                                         $url = wp_nonce_url(admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug); 
     209                                        $url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug); 
    210210                        } else { 
    211211                                $key = array_shift( $key = array_keys($installed_plugin) ); //Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers 
    212212                                if ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '=') ){ 
     
    226226                } else { 
    227227                        // "install" & no directory with that slug 
    228228                        if ( current_user_can('install_plugins') ) 
    229                                 $url = wp_nonce_url(admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug); 
     229                                $url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug); 
    230230                } 
    231231        } 
    232232        if ( isset($_GET['from']) ) 
  • wp-admin/includes/update.php

     
    190190        $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()); 
    191191        $plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags ); 
    192192 
    193         $details_url = admin_url('plugin-install.php?tab=plugin-information&plugin=' . $r->slug . '&TB_iframe=true&width=600&height=800'); 
     193        $details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $r->slug . '&TB_iframe=true&width=600&height=800'); 
    194194 
    195195        echo '<tr class="plugin-update-tr"><td colspan="3" class="plugin-update"><div class="update-message">'; 
    196196        if ( ! current_user_can('update_plugins') ) 
     
    198198        else if ( empty($r->package) ) 
    199199                printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>. <em>Automatic upgrade is unavailable for this plugin.</em>'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version ); 
    200200        else 
    201                 printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">upgrade automatically</a>.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version, wp_nonce_url('update.php?action=upgrade-plugin&plugin=' . $file, 'upgrade-plugin_' . $file) ); 
     201                printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">upgrade automatically</a>.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version, wp_nonce_url( self_admin_url('update.php?action=upgrade-plugin&plugin=') . $file, 'upgrade-plugin_' . $file) ); 
    202202 
    203203        do_action( "in_plugin_update_message-$file", $plugin_data, $r ); 
    204204 
  • wp-admin/includes/class-wp-upgrader.php

     
    12811281                else 
    12821282                        $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>'; 
    12831283 
    1284                 if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) 
     1284                if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) { 
    12851285                        $install_actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;networkwide=1&amp;plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin for all sites in this network') . '" target="_parent">' . __('Network Activate') . '</a>'; 
     1286                        unset( $install_actions['activate_plugin'] ); 
     1287                } 
    12861288 
    12871289                if ( 'import' == $from ) 
    12881290                        $install_actions['importers_page'] = '<a href="' . admin_url('import.php') . '" title="' . esc_attr__('Return to Importers') . '" target="_parent">' . __('Return to Importers') . '</a>'; 
    12891291                else if ( $this->type == 'web' ) 
    1290                         $install_actions['plugins_page'] = '<a href="' . admin_url('plugin-install.php') . '" title="' . esc_attr__('Return to Plugin Installer') . '" target="_parent">' . __('Return to Plugin Installer') . '</a>'; 
     1292                        $install_actions['plugins_page'] = '<a href="' . self_admin_url('plugin-install.php') . '" title="' . esc_attr__('Return to Plugin Installer') . '" target="_parent">' . __('Return to Plugin Installer') . '</a>'; 
    12911293                else 
    1292                         $install_actions['plugins_page'] = '<a href="' . admin_url('plugins.php') . '" title="' . esc_attr__('Return to Plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>'; 
     1294                        $install_actions['plugins_page'] = '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Return to Plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>'; 
    12931295 
    12941296 
    12951297                if ( ! $this->result || is_wp_error($this->result) ) { 
  • wp-admin/update.php

     
    5454                $title = __('Upgrade Plugin'); 
    5555                $parent_file = 'plugins.php'; 
    5656                $submenu_file = 'plugins.php'; 
    57                 require_once('./admin-header.php'); 
     57                require_once(ABSPATH . 'wp-admin/admin-header.php'); 
    5858 
    5959                $nonce = 'upgrade-plugin_' . $plugin; 
    6060                $url = 'update.php?action=upgrade-plugin&plugin=' . $plugin; 
     
    6262                $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact('title', 'nonce', 'url', 'plugin') ) ); 
    6363                $upgrader->upgrade($plugin); 
    6464 
    65                 include('./admin-footer.php'); 
     65                include(ABSPATH . 'wp-admin/admin-footer.php'); 
    6666 
    6767        } elseif ('activate-plugin' == $action ) { 
    6868                if ( ! current_user_can('update_plugins') ) 
     
    107107                $title = __('Plugin Install'); 
    108108                $parent_file = 'plugins.php'; 
    109109                $submenu_file = 'plugin-install.php'; 
    110                 require_once('./admin-header.php'); 
     110                require_once(ABSPATH . 'wp-admin/admin-header.php'); 
    111111 
    112112                $title = sprintf( __('Installing Plugin: %s'), $api->name . ' ' . $api->version ); 
    113113                $nonce = 'install-plugin_' . $plugin; 
     
    120120                $upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) ); 
    121121                $upgrader->install($api->download_link); 
    122122 
    123                 include('./admin-footer.php'); 
     123                include(ABSPATH . 'wp-admin/admin-footer.php'); 
    124124 
    125125        } elseif ( 'upload-plugin' == $action ) { 
    126126 
     
    134134                $title = __('Upload Plugin'); 
    135135                $parent_file = 'plugins.php'; 
    136136                $submenu_file = 'plugin-install.php'; 
    137                 require_once('./admin-header.php'); 
     137                require_once(ABSPATH . 'wp-admin/admin-header.php'); 
    138138 
    139139                $title = sprintf( __('Installing Plugin from uploaded file: %s'), basename( $file_upload->filename ) ); 
    140140                $nonce = 'plugin-upload'; 
     
    144144                $upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact('type', 'title', 'nonce', 'url') ) ); 
    145145                $upgrader->install( $file_upload->package ); 
    146146 
    147                 include('./admin-footer.php'); 
     147                include(ABSPATH . 'wp-admin/admin-footer.php'); 
    148148 
    149149        } elseif ( 'upgrade-theme' == $action ) { 
    150150 
     
    158158                $title = __('Upgrade Theme'); 
    159159                $parent_file = 'themes.php'; 
    160160                $submenu_file = 'themes.php'; 
    161                 require_once('./admin-header.php'); 
     161                require_once(ABSPATH . 'wp-admin/admin-header.php'); 
    162162 
    163163                $nonce = 'upgrade-theme_' . $theme; 
    164164                $url = 'update.php?action=upgrade-theme&theme=' . $theme; 
     
    166166                $upgrader = new Theme_Upgrader( new Theme_Upgrader_Skin( compact('title', 'nonce', 'url', 'theme') ) ); 
    167167                $upgrader->upgrade($theme); 
    168168 
    169                 include('./admin-footer.php'); 
     169                include(ABSPATH . 'wp-admin/admin-footer.php'); 
    170170        } elseif ( 'update-selected-themes' == $action ) { 
    171171                if ( ! current_user_can( 'update_themes' ) ) 
    172172                        wp_die( __( 'You do not have sufficient permissions to update themes for this site.' ) ); 
     
    211211                $title = __('Install Themes'); 
    212212                $parent_file = 'themes.php'; 
    213213                $submenu_file = 'themes.php'; 
    214                 require_once('./admin-header.php'); 
     214                require_once(ABSPATH . 'wp-admin/admin-header.php'); 
    215215 
    216216                $title = sprintf( __('Installing Theme: %s'), $api->name . ' ' . $api->version ); 
    217217                $nonce = 'install-theme_' . $theme; 
     
    221221                $upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) ); 
    222222                $upgrader->install($api->download_link); 
    223223 
    224                 include('./admin-footer.php'); 
     224                include(ABSPATH . 'wp-admin/admin-footer.php'); 
    225225 
    226226        } elseif ( 'upload-theme' == $action ) { 
    227227 
     
    237237                $submenu_file = 'theme-install.php'; 
    238238                add_thickbox(); 
    239239                wp_enqueue_script('theme-preview'); 
    240                 require_once('./admin-header.php'); 
     240                require_once(ABSPATH . 'wp-admin/admin-header.php'); 
    241241 
    242242                $title = sprintf( __('Installing Theme from uploaded file: %s'), basename( $file_upload->filename ) ); 
    243243                $nonce = 'theme-upload'; 
     
    247247                $upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('type', 'title', 'nonce', 'url') ) ); 
    248248                $upgrader->install( $file_upload->package ); 
    249249 
    250                 include('./admin-footer.php'); 
     250                include(ABSPATH . 'wp-admin/admin-footer.php'); 
    251251 
    252252        } else { 
    253253                do_action('update-custom_' . $action); 
  • wp-admin/plugin-install.php

     
    3535        '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' 
    3636); 
    3737 
    38 include('./admin-header.php'); 
     38include(ABSPATH . 'wp-admin/admin-header.php'); 
    3939?> 
    4040<div class="wrap"> 
    4141<?php screen_icon(); ?> 
     
    4747<?php do_action('install_plugins_' . $tab, $paged); ?> 
    4848</div> 
    4949<?php 
    50 include('./admin-footer.php'); 
     50include(ABSPATH . 'wp-admin/admin-footer.php'); 
    5151 
  • wp-admin/network/plugin-install.php

     
     1<?php 
     2 
     3require_once( './admin.php' ); 
     4 
     5require( '../plugin-install.php' ); 
     6 No newline at end of file 
  • wp-admin/network/update.php

     
     1<?php 
     2 
     3require_once( './admin.php' ); 
     4 
     5require( '../update.php' ); 
  • wp-admin/network/menu.php

     
    99$menu[5] = array(__('Sites'), 'manage_sites', 'sites.php', '', 'menu-top menu-icon-site', 'menu-site', 'div'); 
    1010$menu[10] = array(__('Users'), 'manage_network_users', 'users.php', '', 'menu-top menu-icon-users', 'menu-users', 'div'); 
    1111$menu[15] = array(__('Themes'), 'manage_network_themes', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'div'); 
    12 $menu[20] = array(__('Plugins'), 'manage_network_plugins', 'plugins.php', '', 'menu-top menu-icon-plugins', 'menu-plugins', 'div'); 
     12 
     13$plugin_update_count = 0;  
     14$update_plugins = get_site_transient( 'update_plugins' );  
     15if ( !empty($update_plugins->response) )  
     16        $plugin_update_count = count( $update_plugins->response );  
     17$menu[20] = array(sprintf( __('Plugins %s'), "<span class='update-plugins count-$plugin_update_count'><span class='plugin-count'>" . number_format_i18n($plugin_update_count) . "</span></span>" ), 'manage_network_plugins', 'plugins.php', '', 'menu-top menu-icon-plugins', 'menu-plugins', 'div'); 
     18$submenu['plugins.php'][5]  = array( __('Plugins'), 'manage_network_plugins', 'plugins.php' ); 
     19$submenu['plugins.php'][10] = array( _x('Add New', 'plugin editor'), 'install_plugins', 'plugin-install.php' ); 
     20$submenu['plugins.php'][15] = array( _x('Editor', 'plugin editor'), 'edit_plugins', 'plugin-editor.php' ); 
     21 
     22 
    1323$menu[25] = array(__('Settings'), 'manage_network_options', 'settings.php', '', 'menu-top menu-icon-settings', 'menu-settings', 'div'); 
    1424$menu[30] = array(__('Update'), 'manage_network', 'upgrade.php', '', 'menu-top menu-icon-tools', 'menu-update', 'div'); 
    1525 
    1626$menu[99] = array( '', 'read', 'separator-last', '', 'wp-menu-separator-last' ); 
    1727 
    18 $compat = array(); 
    19 $submenu = array(); 
    20  
    21 $submenu['plugins.php'][5]  = array( __('Plugins'), 'manage_network_plugins', 'plugins.php' );  
    22 $submenu['plugins.php'][15] = array( _x('Editor', 'plugin editor'), 'edit_plugins', 'plugin-editor.php' ); 
    23  
    24 $submenu['themes.php'][5]  = array( __('Themes'), 'manage_network_themes', 'themes.php' );  
     28$submenu['themes.php'][5]  = array( __('Themes'), 'manage_network_themes', 'themes.php' ); 
    2529$submenu['themes.php'][15] = array( _x('Editor', 'plugin editor'), 'edit_themes', 'theme-editor.php' ); 
    2630 
    2731require_once(ABSPATH . 'wp-admin/includes/menu.php');