Changeset 42343 for trunk/src/wp-admin/update.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/update.php
r41797 r42343 7 7 */ 8 8 9 if ( ! defined( 'IFRAME_REQUEST' ) && isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'update-selected', 'activate-plugin', 'update-selected-themes' ) ) ) 9 if ( ! defined( 'IFRAME_REQUEST' ) && isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'update-selected', 'activate-plugin', 'update-selected-themes' ) ) ) { 10 10 define( 'IFRAME_REQUEST', true ); 11 } 11 12 12 13 /** WordPress Administration Bootstrap */ … … 15 16 include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); 16 17 17 if ( isset( $_GET['action']) ) {18 $plugin = isset( $_REQUEST['plugin']) ? trim($_REQUEST['plugin']) : '';19 $theme = isset($_REQUEST['theme']) ? urldecode($_REQUEST['theme']) : '';20 $action = isset( $_REQUEST['action']) ? $_REQUEST['action'] : '';18 if ( isset( $_GET['action'] ) ) { 19 $plugin = isset( $_REQUEST['plugin'] ) ? trim( $_REQUEST['plugin'] ) : ''; 20 $theme = isset( $_REQUEST['theme'] ) ? urldecode( $_REQUEST['theme'] ) : ''; 21 $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : ''; 21 22 22 23 if ( 'update-selected' == $action ) { 23 if ( ! current_user_can( 'update_plugins' ) ) 24 if ( ! current_user_can( 'update_plugins' ) ) { 24 25 wp_die( __( 'Sorry, you are not allowed to update plugins for this site.' ) ); 26 } 25 27 26 28 check_admin_referer( 'bulk-update-plugins' ); 27 29 28 if ( isset( $_GET['plugins'] ) ) 29 $plugins = explode( ',', stripslashes( $_GET['plugins']) );30 elseif ( isset( $_POST['checked'] ) )30 if ( isset( $_GET['plugins'] ) ) { 31 $plugins = explode( ',', stripslashes( $_GET['plugins'] ) ); 32 } elseif ( isset( $_POST['checked'] ) ) { 31 33 $plugins = (array) $_POST['checked']; 32 else34 } else { 33 35 $plugins = array(); 34 35 $plugins = array_map('urldecode', $plugins); 36 37 $url = 'update.php?action=update-selected&plugins=' . urlencode(implode(',', $plugins)); 36 } 37 38 $plugins = array_map( 'urldecode', $plugins ); 39 40 $url = 'update.php?action=update-selected&plugins=' . urlencode( implode( ',', $plugins ) ); 38 41 $nonce = 'bulk-update-plugins'; 39 42 … … 47 50 48 51 } elseif ( 'upgrade-plugin' == $action ) { 49 if ( ! current_user_can('update_plugins') ) 50 wp_die(__('Sorry, you are not allowed to update plugins for this site.')); 51 52 check_admin_referer('upgrade-plugin_' . $plugin); 53 54 $title = __('Update Plugin'); 55 $parent_file = 'plugins.php'; 52 if ( ! current_user_can( 'update_plugins' ) ) { 53 wp_die( __( 'Sorry, you are not allowed to update plugins for this site.' ) ); 54 } 55 56 check_admin_referer( 'upgrade-plugin_' . $plugin ); 57 58 $title = __( 'Update Plugin' ); 59 $parent_file = 'plugins.php'; 56 60 $submenu_file = 'plugins.php'; 57 61 58 62 wp_enqueue_script( 'updates' ); 59 require_once( ABSPATH . 'wp-admin/admin-header.php');63 require_once( ABSPATH . 'wp-admin/admin-header.php' ); 60 64 61 65 $nonce = 'upgrade-plugin_' . $plugin; 62 $url = 'update.php?action=upgrade-plugin&plugin=' . urlencode( $plugin ); 63 64 $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact('title', 'nonce', 'url', 'plugin') ) ); 65 $upgrader->upgrade($plugin); 66 67 include(ABSPATH . 'wp-admin/admin-footer.php'); 68 69 } elseif ('activate-plugin' == $action ) { 70 if ( ! current_user_can('update_plugins') ) 71 wp_die(__('Sorry, you are not allowed to update plugins for this site.')); 72 73 check_admin_referer('activate-plugin_' . $plugin); 74 if ( ! isset($_GET['failure']) && ! isset($_GET['success']) ) { 75 wp_redirect( admin_url('update.php?action=activate-plugin&failure=true&plugin=' . urlencode( $plugin ) . '&_wpnonce=' . $_GET['_wpnonce']) ); 66 $url = 'update.php?action=upgrade-plugin&plugin=' . urlencode( $plugin ); 67 68 $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'plugin' ) ) ); 69 $upgrader->upgrade( $plugin ); 70 71 include( ABSPATH . 'wp-admin/admin-footer.php' ); 72 73 } elseif ( 'activate-plugin' == $action ) { 74 if ( ! current_user_can( 'update_plugins' ) ) { 75 wp_die( __( 'Sorry, you are not allowed to update plugins for this site.' ) ); 76 } 77 78 check_admin_referer( 'activate-plugin_' . $plugin ); 79 if ( ! isset( $_GET['failure'] ) && ! isset( $_GET['success'] ) ) { 80 wp_redirect( admin_url( 'update.php?action=activate-plugin&failure=true&plugin=' . urlencode( $plugin ) . '&_wpnonce=' . $_GET['_wpnonce'] ) ); 76 81 activate_plugin( $plugin, '', ! empty( $_GET['networkwide'] ), true ); 77 wp_redirect( admin_url( 'update.php?action=activate-plugin&success=true&plugin=' . urlencode( $plugin ) . '&_wpnonce=' . $_GET['_wpnonce']) );82 wp_redirect( admin_url( 'update.php?action=activate-plugin&success=true&plugin=' . urlencode( $plugin ) . '&_wpnonce=' . $_GET['_wpnonce'] ) ); 78 83 die(); 79 84 } 80 iframe_header( __('Plugin Reactivation'), true ); 81 if ( isset($_GET['success']) ) 82 echo '<p>' . __('Plugin reactivated successfully.') . '</p>'; 83 84 if ( isset($_GET['failure']) ){ 85 echo '<p>' . __('Plugin failed to reactivate due to a fatal error.') . '</p>'; 85 iframe_header( __( 'Plugin Reactivation' ), true ); 86 if ( isset( $_GET['success'] ) ) { 87 echo '<p>' . __( 'Plugin reactivated successfully.' ) . '</p>'; 88 } 89 90 if ( isset( $_GET['failure'] ) ) { 91 echo '<p>' . __( 'Plugin failed to reactivate due to a fatal error.' ) . '</p>'; 86 92 87 93 error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR ); 88 @ini_set( 'display_errors', true); //Ensure that Fatal errors are displayed.94 @ini_set( 'display_errors', true ); //Ensure that Fatal errors are displayed. 89 95 wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin ); 90 96 include( WP_PLUGIN_DIR . '/' . $plugin ); … … 93 99 } elseif ( 'install-plugin' == $action ) { 94 100 95 if ( ! current_user_can( 'install_plugins') )101 if ( ! current_user_can( 'install_plugins' ) ) { 96 102 wp_die( __( 'Sorry, you are not allowed to install plugins on this site.' ) ); 103 } 97 104 98 105 include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. 99 106 100 107 check_admin_referer( 'install-plugin_' . $plugin ); 101 $api = plugins_api( 'plugin_information', array( 102 'slug' => $plugin, 103 'fields' => array( 104 'short_description' => false, 105 'sections' => false, 106 'requires' => false, 107 'rating' => false, 108 'ratings' => false, 109 'downloaded' => false, 110 'last_updated' => false, 111 'added' => false, 112 'tags' => false, 113 'compatibility' => false, 114 'homepage' => false, 115 'donate_link' => false, 116 ), 117 ) ); 108 $api = plugins_api( 109 'plugin_information', array( 110 'slug' => $plugin, 111 'fields' => array( 112 'short_description' => false, 113 'sections' => false, 114 'requires' => false, 115 'rating' => false, 116 'ratings' => false, 117 'downloaded' => false, 118 'last_updated' => false, 119 'added' => false, 120 'tags' => false, 121 'compatibility' => false, 122 'homepage' => false, 123 'donate_link' => false, 124 ), 125 ) 126 ); 118 127 119 128 if ( is_wp_error( $api ) ) { 120 121 } 122 123 $title = __('Plugin Installation');124 $parent_file = 'plugins.php';129 wp_die( $api ); 130 } 131 132 $title = __( 'Plugin Installation' ); 133 $parent_file = 'plugins.php'; 125 134 $submenu_file = 'plugin-install.php'; 126 require_once( ABSPATH . 'wp-admin/admin-header.php');127 128 $title = sprintf( __( 'Installing Plugin: %s'), $api->name . ' ' . $api->version );135 require_once( ABSPATH . 'wp-admin/admin-header.php' ); 136 137 $title = sprintf( __( 'Installing Plugin: %s' ), $api->name . ' ' . $api->version ); 129 138 $nonce = 'install-plugin_' . $plugin; 130 $url = 'update.php?action=install-plugin&plugin=' . urlencode( $plugin ); 131 if ( isset($_GET['from']) ) 132 $url .= '&from=' . urlencode(stripslashes($_GET['from'])); 139 $url = 'update.php?action=install-plugin&plugin=' . urlencode( $plugin ); 140 if ( isset( $_GET['from'] ) ) { 141 $url .= '&from=' . urlencode( stripslashes( $_GET['from'] ) ); 142 } 133 143 134 144 $type = 'web'; //Install plugin type, From Web or an Upload. 135 145 136 $upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact( 'title', 'url', 'nonce', 'plugin', 'api') ) );137 $upgrader->install( $api->download_link);138 139 include( ABSPATH . 'wp-admin/admin-footer.php');146 $upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact( 'title', 'url', 'nonce', 'plugin', 'api' ) ) ); 147 $upgrader->install( $api->download_link ); 148 149 include( ABSPATH . 'wp-admin/admin-footer.php' ); 140 150 141 151 } elseif ( 'upload-plugin' == $action ) { … … 145 155 } 146 156 147 check_admin_referer( 'plugin-upload');148 149 $file_upload = new File_Upload_Upgrader( 'pluginzip', 'package');150 151 $title = __('Upload Plugin');152 $parent_file = 'plugins.php';157 check_admin_referer( 'plugin-upload' ); 158 159 $file_upload = new File_Upload_Upgrader( 'pluginzip', 'package' ); 160 161 $title = __( 'Upload Plugin' ); 162 $parent_file = 'plugins.php'; 153 163 $submenu_file = 'plugin-install.php'; 154 require_once( ABSPATH . 'wp-admin/admin-header.php');155 156 $title = sprintf( __( 'Installing Plugin from uploaded file: %s'), esc_html( basename( $file_upload->filename ) ) );164 require_once( ABSPATH . 'wp-admin/admin-header.php' ); 165 166 $title = sprintf( __( 'Installing Plugin from uploaded file: %s' ), esc_html( basename( $file_upload->filename ) ) ); 157 167 $nonce = 'plugin-upload'; 158 $url = add_query_arg(array('package' => $file_upload->id), 'update.php?action=upload-plugin');159 $type = 'upload'; //Install plugin type, From Web or an Upload.160 161 $upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact( 'type', 'title', 'nonce', 'url') ) );162 $result = $upgrader->install( $file_upload->package );163 164 if ( $result || is_wp_error( $result) )168 $url = add_query_arg( array( 'package' => $file_upload->id ), 'update.php?action=upload-plugin' ); 169 $type = 'upload'; //Install plugin type, From Web or an Upload. 170 171 $upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact( 'type', 'title', 'nonce', 'url' ) ) ); 172 $result = $upgrader->install( $file_upload->package ); 173 174 if ( $result || is_wp_error( $result ) ) { 165 175 $file_upload->cleanup(); 166 167 include(ABSPATH . 'wp-admin/admin-footer.php'); 176 } 177 178 include( ABSPATH . 'wp-admin/admin-footer.php' ); 168 179 169 180 } elseif ( 'upgrade-theme' == $action ) { 170 181 171 if ( ! current_user_can('update_themes') ) 172 wp_die(__('Sorry, you are not allowed to update themes for this site.')); 173 174 check_admin_referer('upgrade-theme_' . $theme); 182 if ( ! current_user_can( 'update_themes' ) ) { 183 wp_die( __( 'Sorry, you are not allowed to update themes for this site.' ) ); 184 } 185 186 check_admin_referer( 'upgrade-theme_' . $theme ); 175 187 176 188 wp_enqueue_script( 'updates' ); 177 189 178 $title = __('Update Theme');179 $parent_file = 'themes.php';190 $title = __( 'Update Theme' ); 191 $parent_file = 'themes.php'; 180 192 $submenu_file = 'themes.php'; 181 require_once( ABSPATH . 'wp-admin/admin-header.php');193 require_once( ABSPATH . 'wp-admin/admin-header.php' ); 182 194 183 195 $nonce = 'upgrade-theme_' . $theme; 184 $url = 'update.php?action=upgrade-theme&theme=' . urlencode( $theme );185 186 $upgrader = new Theme_Upgrader( new Theme_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'theme') ) );187 $upgrader->upgrade( $theme);188 189 include( ABSPATH . 'wp-admin/admin-footer.php');196 $url = 'update.php?action=upgrade-theme&theme=' . urlencode( $theme ); 197 198 $upgrader = new Theme_Upgrader( new Theme_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'theme' ) ) ); 199 $upgrader->upgrade( $theme ); 200 201 include( ABSPATH . 'wp-admin/admin-footer.php' ); 190 202 } elseif ( 'update-selected-themes' == $action ) { 191 if ( ! current_user_can( 'update_themes' ) ) 203 if ( ! current_user_can( 'update_themes' ) ) { 192 204 wp_die( __( 'Sorry, you are not allowed to update themes for this site.' ) ); 205 } 193 206 194 207 check_admin_referer( 'bulk-update-themes' ); 195 208 196 if ( isset( $_GET['themes'] ) ) 197 $themes = explode( ',', stripslashes( $_GET['themes']) );198 elseif ( isset( $_POST['checked'] ) )209 if ( isset( $_GET['themes'] ) ) { 210 $themes = explode( ',', stripslashes( $_GET['themes'] ) ); 211 } elseif ( isset( $_POST['checked'] ) ) { 199 212 $themes = (array) $_POST['checked']; 200 else213 } else { 201 214 $themes = array(); 202 203 $themes = array_map('urldecode', $themes); 204 205 $url = 'update.php?action=update-selected-themes&themes=' . urlencode(implode(',', $themes)); 215 } 216 217 $themes = array_map( 'urldecode', $themes ); 218 219 $url = 'update.php?action=update-selected-themes&themes=' . urlencode( implode( ',', $themes ) ); 206 220 $nonce = 'bulk-update-themes'; 207 221 … … 215 229 } elseif ( 'install-theme' == $action ) { 216 230 217 if ( ! current_user_can( 'install_themes') )231 if ( ! current_user_can( 'install_themes' ) ) { 218 232 wp_die( __( 'Sorry, you are not allowed to install themes on this site.' ) ); 233 } 219 234 220 235 include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); //for themes_api.. 221 236 222 237 check_admin_referer( 'install-theme_' . $theme ); 223 $api = themes_api('theme_information', array('slug' => $theme, 'fields' => array('sections' => false, 'tags' => false) ) ); //Save on a bit of bandwidth. 238 $api = themes_api( 239 'theme_information', array( 240 'slug' => $theme, 241 'fields' => array( 242 'sections' => false, 243 'tags' => false, 244 ), 245 ) 246 ); //Save on a bit of bandwidth. 224 247 225 248 if ( is_wp_error( $api ) ) { … … 227 250 } 228 251 229 $title = __('Install Themes');230 $parent_file = 'themes.php';252 $title = __( 'Install Themes' ); 253 $parent_file = 'themes.php'; 231 254 $submenu_file = 'themes.php'; 232 require_once( ABSPATH . 'wp-admin/admin-header.php');233 234 $title = sprintf( __( 'Installing Theme: %s'), $api->name . ' ' . $api->version );255 require_once( ABSPATH . 'wp-admin/admin-header.php' ); 256 257 $title = sprintf( __( 'Installing Theme: %s' ), $api->name . ' ' . $api->version ); 235 258 $nonce = 'install-theme_' . $theme; 236 $url = 'update.php?action=install-theme&theme=' . urlencode( $theme );237 $type = 'web'; //Install theme type, From Web or an Upload.238 239 $upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact( 'title', 'url', 'nonce', 'plugin', 'api') ) );240 $upgrader->install( $api->download_link);241 242 include( ABSPATH . 'wp-admin/admin-footer.php');259 $url = 'update.php?action=install-theme&theme=' . urlencode( $theme ); 260 $type = 'web'; //Install theme type, From Web or an Upload. 261 262 $upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact( 'title', 'url', 'nonce', 'plugin', 'api' ) ) ); 263 $upgrader->install( $api->download_link ); 264 265 include( ABSPATH . 'wp-admin/admin-footer.php' ); 243 266 244 267 } elseif ( 'upload-theme' == $action ) { … … 248 271 } 249 272 250 check_admin_referer( 'theme-upload');251 252 $file_upload = new File_Upload_Upgrader( 'themezip', 'package');253 254 $title = __('Upload Theme');255 $parent_file = 'themes.php';273 check_admin_referer( 'theme-upload' ); 274 275 $file_upload = new File_Upload_Upgrader( 'themezip', 'package' ); 276 277 $title = __( 'Upload Theme' ); 278 $parent_file = 'themes.php'; 256 279 $submenu_file = 'theme-install.php'; 257 280 258 require_once( ABSPATH . 'wp-admin/admin-header.php');259 260 $title = sprintf( __( 'Installing Theme from uploaded file: %s'), esc_html( basename( $file_upload->filename ) ) );281 require_once( ABSPATH . 'wp-admin/admin-header.php' ); 282 283 $title = sprintf( __( 'Installing Theme from uploaded file: %s' ), esc_html( basename( $file_upload->filename ) ) ); 261 284 $nonce = 'theme-upload'; 262 $url = add_query_arg(array('package' => $file_upload->id), 'update.php?action=upload-theme');263 $type = 'upload'; //Install plugin type, From Web or an Upload.264 265 $upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact( 'type', 'title', 'nonce', 'url') ) );266 $result = $upgrader->install( $file_upload->package );267 268 if ( $result || is_wp_error( $result) )285 $url = add_query_arg( array( 'package' => $file_upload->id ), 'update.php?action=upload-theme' ); 286 $type = 'upload'; //Install plugin type, From Web or an Upload. 287 288 $upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact( 'type', 'title', 'nonce', 'url' ) ) ); 289 $result = $upgrader->install( $file_upload->package ); 290 291 if ( $result || is_wp_error( $result ) ) { 269 292 $file_upload->cleanup(); 270 271 include(ABSPATH . 'wp-admin/admin-footer.php'); 293 } 294 295 include( ABSPATH . 'wp-admin/admin-footer.php' ); 272 296 273 297 } else {
Note: See TracChangeset
for help on using the changeset viewer.