4 * |
4 * |
5 * @package WordPress |
5 * @package WordPress |
6 * @subpackage Administration |
6 * @subpackage Administration |
7 */ |
7 */ |
8 |
8 |
|
9 if ( ! defined( 'IFRAME_REQUEST' ) && isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'update-selected', 'activate-plugin', 'update-selected-themes' ) ) ) |
|
10 define( 'IFRAME_REQUEST', true ); |
|
11 |
9 /** WordPress Administration Bootstrap */ |
12 /** WordPress Administration Bootstrap */ |
10 require_once('admin.php'); |
13 require_once('./admin.php'); |
11 |
14 |
12 include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
15 include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
13 |
16 |
14 if ( isset($_GET['action']) ) { |
17 if ( isset($_GET['action']) ) { |
15 $plugin = isset($_REQUEST['plugin']) ? trim($_REQUEST['plugin']) : ''; |
18 $plugin = isset($_REQUEST['plugin']) ? trim($_REQUEST['plugin']) : ''; |
16 $theme = isset($_REQUEST['theme']) ? urldecode($_REQUEST['theme']) : ''; |
19 $theme = isset($_REQUEST['theme']) ? urldecode($_REQUEST['theme']) : ''; |
17 $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
20 $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
18 |
21 |
19 if ( 'upgrade-plugin' == $action ) { |
22 if ( 'update-selected' == $action ) { |
|
23 if ( ! current_user_can( 'update_plugins' ) ) |
|
24 wp_die( __( 'You do not have sufficient permissions to update plugins for this site.' ) ); |
|
25 |
|
26 check_admin_referer( 'bulk-update-plugins' ); |
|
27 |
|
28 if ( isset( $_GET['plugins'] ) ) |
|
29 $plugins = explode( ',', stripslashes($_GET['plugins']) ); |
|
30 elseif ( isset( $_POST['checked'] ) ) |
|
31 $plugins = (array) $_POST['checked']; |
|
32 else |
|
33 $plugins = array(); |
|
34 |
|
35 $plugins = array_map('urldecode', $plugins); |
|
36 |
|
37 $url = 'update.php?action=update-selected&plugins=' . urlencode(implode(',', $plugins)); |
|
38 $nonce = 'bulk-update-plugins'; |
|
39 |
|
40 wp_enqueue_script('jquery'); |
|
41 iframe_header(); |
|
42 |
|
43 $upgrader = new Plugin_Upgrader( new Bulk_Plugin_Upgrader_Skin( compact( 'nonce', 'url' ) ) ); |
|
44 $upgrader->bulk_upgrade( $plugins ); |
|
45 |
|
46 iframe_footer(); |
|
47 |
|
48 } elseif ( 'upgrade-plugin' == $action ) { |
20 if ( ! current_user_can('update_plugins') ) |
49 if ( ! current_user_can('update_plugins') ) |
21 wp_die(__('You do not have sufficient permissions to update plugins for this blog.')); |
50 wp_die(__('You do not have sufficient permissions to update plugins for this site.')); |
22 |
51 |
23 check_admin_referer('upgrade-plugin_' . $plugin); |
52 check_admin_referer('upgrade-plugin_' . $plugin); |
24 |
53 |
25 $title = __('Upgrade Plugin'); |
54 $title = __('Update Plugin'); |
26 $parent_file = 'plugins.php'; |
55 $parent_file = 'plugins.php'; |
27 $submenu_file = 'plugins.php'; |
56 $submenu_file = 'plugins.php'; |
28 require_once('admin-header.php'); |
57 require_once(ABSPATH . 'wp-admin/admin-header.php'); |
29 |
58 |
30 $nonce = 'upgrade-plugin_' . $plugin; |
59 $nonce = 'upgrade-plugin_' . $plugin; |
31 $url = 'update.php?action=upgrade-plugin&plugin=' . $plugin; |
60 $url = 'update.php?action=upgrade-plugin&plugin=' . $plugin; |
32 |
61 |
33 $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact('title', 'nonce', 'url', 'plugin') ) ); |
62 $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact('title', 'nonce', 'url', 'plugin') ) ); |
34 $upgrader->upgrade($plugin); |
63 $upgrader->upgrade($plugin); |
35 |
64 |
36 include('admin-footer.php'); |
65 include(ABSPATH . 'wp-admin/admin-footer.php'); |
37 |
66 |
38 } elseif ('activate-plugin' == $action ) { |
67 } elseif ('activate-plugin' == $action ) { |
39 if ( ! current_user_can('update_plugins') ) |
68 if ( ! current_user_can('update_plugins') ) |
40 wp_die(__('You do not have sufficient permissions to update plugins for this blog.')); |
69 wp_die(__('You do not have sufficient permissions to update plugins for this site.')); |
41 |
70 |
42 check_admin_referer('activate-plugin_' . $plugin); |
71 check_admin_referer('activate-plugin_' . $plugin); |
43 if( ! isset($_GET['failure']) && ! isset($_GET['success']) ) { |
72 if ( ! isset($_GET['failure']) && ! isset($_GET['success']) ) { |
44 wp_redirect( 'update.php?action=activate-plugin&failure=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce'] ); |
73 wp_redirect( admin_url('update.php?action=activate-plugin&failure=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce']) ); |
45 activate_plugin($plugin); |
74 activate_plugin( $plugin, '', ! empty( $_GET['networkwide'] ), true ); |
46 wp_redirect( 'update.php?action=activate-plugin&success=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce'] ); |
75 wp_redirect( admin_url('update.php?action=activate-plugin&success=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce']) ); |
47 die(); |
76 die(); |
48 } |
77 } |
49 iframe_header( __('Plugin Reactivation'), true ); |
78 iframe_header( __('Plugin Reactivation'), true ); |
50 if( isset($_GET['success']) ) |
79 if ( isset($_GET['success']) ) |
51 echo '<p>' . __('Plugin reactivated successfully.') . '</p>'; |
80 echo '<p>' . __('Plugin reactivated successfully.') . '</p>'; |
52 |
81 |
53 if( isset($_GET['failure']) ){ |
82 if ( isset($_GET['failure']) ){ |
54 echo '<p>' . __('Plugin failed to reactivate due to a fatal error.') . '</p>'; |
83 echo '<p>' . __('Plugin failed to reactivate due to a fatal error.') . '</p>'; |
55 |
84 |
56 if ( defined('E_RECOVERABLE_ERROR') ) |
85 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 ); |
57 error_reporting(E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR); |
|
58 else |
|
59 error_reporting(E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING); |
|
60 |
|
61 @ini_set('display_errors', true); //Ensure that Fatal errors are displayed. |
86 @ini_set('display_errors', true); //Ensure that Fatal errors are displayed. |
62 include(WP_PLUGIN_DIR . '/' . $plugin); |
87 include(WP_PLUGIN_DIR . '/' . $plugin); |
63 } |
88 } |
64 iframe_footer(); |
89 iframe_footer(); |
65 } elseif ( 'install-plugin' == $action ) { |
90 } elseif ( 'install-plugin' == $action ) { |
66 |
91 |
67 if ( ! current_user_can('install_plugins') ) |
92 if ( ! current_user_can('install_plugins') ) |
68 wp_die(__('You do not have sufficient permissions to install plugins for this blog.')); |
93 wp_die(__('You do not have sufficient permissions to install plugins for this site.')); |
69 |
94 |
70 include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api.. |
95 include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api.. |
71 |
96 |
72 check_admin_referer('install-plugin_' . $plugin); |
97 check_admin_referer('install-plugin_' . $plugin); |
73 $api = plugins_api('plugin_information', array('slug' => $plugin, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth. |
98 $api = plugins_api('plugin_information', array('slug' => $plugin, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth. |
76 wp_die($api); |
101 wp_die($api); |
77 |
102 |
78 $title = __('Plugin Install'); |
103 $title = __('Plugin Install'); |
79 $parent_file = 'plugins.php'; |
104 $parent_file = 'plugins.php'; |
80 $submenu_file = 'plugin-install.php'; |
105 $submenu_file = 'plugin-install.php'; |
81 require_once('admin-header.php'); |
106 require_once(ABSPATH . 'wp-admin/admin-header.php'); |
82 |
107 |
83 $title = sprintf( __('Installing Plugin: %s'), $api->name . ' ' . $api->version ); |
108 $title = sprintf( __('Installing Plugin: %s'), $api->name . ' ' . $api->version ); |
84 $nonce = 'install-plugin_' . $plugin; |
109 $nonce = 'install-plugin_' . $plugin; |
85 $url = 'update.php?action=install-plugin&plugin=' . $plugin; |
110 $url = 'update.php?action=install-plugin&plugin=' . $plugin; |
|
111 if ( isset($_GET['from']) ) |
|
112 $url .= '&from=' . urlencode(stripslashes($_GET['from'])); |
|
113 |
86 $type = 'web'; //Install plugin type, From Web or an Upload. |
114 $type = 'web'; //Install plugin type, From Web or an Upload. |
87 |
115 |
88 $upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) ); |
116 $upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) ); |
89 $upgrader->install($api->download_link); |
117 $upgrader->install($api->download_link); |
90 |
118 |
91 include('admin-footer.php'); |
119 include(ABSPATH . 'wp-admin/admin-footer.php'); |
92 |
120 |
93 } elseif ( 'upload-plugin' == $action ) { |
121 } elseif ( 'upload-plugin' == $action ) { |
94 |
122 |
95 if ( ! current_user_can('install_plugins') ) |
123 if ( ! current_user_can('install_plugins') ) |
96 wp_die(__('You do not have sufficient permissions to install plugins for this blog.')); |
124 wp_die(__('You do not have sufficient permissions to install plugins for this site.')); |
97 |
125 |
98 check_admin_referer('plugin-upload'); |
126 check_admin_referer('plugin-upload'); |
99 |
127 |
100 $file_upload = new File_Upload_Upgrader('pluginzip', 'package'); |
128 $file_upload = new File_Upload_Upgrader('pluginzip', 'package'); |
101 |
129 |
102 $title = __('Upload Plugin'); |
130 $title = __('Upload Plugin'); |
103 $parent_file = 'plugins.php'; |
131 $parent_file = 'plugins.php'; |
104 $submenu_file = 'plugin-install.php'; |
132 $submenu_file = 'plugin-install.php'; |
105 require_once('admin-header.php'); |
133 require_once(ABSPATH . 'wp-admin/admin-header.php'); |
106 |
134 |
107 $title = sprintf( __('Installing Plugin from uploaded file: %s'), basename( $file_upload->filename ) ); |
135 $title = sprintf( __('Installing Plugin from uploaded file: %s'), basename( $file_upload->filename ) ); |
108 $nonce = 'plugin-upload'; |
136 $nonce = 'plugin-upload'; |
109 $url = add_query_arg(array('package' => $file_upload->filename ), 'update.php?action=upload-plugin'); |
137 $url = add_query_arg(array('package' => $file_upload->id), 'update.php?action=upload-plugin'); |
110 $type = 'upload'; //Install plugin type, From Web or an Upload. |
138 $type = 'upload'; //Install plugin type, From Web or an Upload. |
111 |
139 |
112 $upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact('type', 'title', 'nonce', 'url') ) ); |
140 $upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact('type', 'title', 'nonce', 'url') ) ); |
113 $upgrader->install( $file_upload->package ); |
141 $result = $upgrader->install( $file_upload->package ); |
114 |
142 |
115 include('admin-footer.php'); |
143 if ( $result || is_wp_error($result) ) |
|
144 $file_upload->cleanup(); |
|
145 |
|
146 include(ABSPATH . 'wp-admin/admin-footer.php'); |
116 |
147 |
117 } elseif ( 'upgrade-theme' == $action ) { |
148 } elseif ( 'upgrade-theme' == $action ) { |
118 |
149 |
119 if ( ! current_user_can('update_themes') ) |
150 if ( ! current_user_can('update_themes') ) |
120 wp_die(__('You do not have sufficient permissions to update themes for this blog.')); |
151 wp_die(__('You do not have sufficient permissions to update themes for this site.')); |
121 |
152 |
122 check_admin_referer('upgrade-theme_' . $theme); |
153 check_admin_referer('upgrade-theme_' . $theme); |
123 |
154 |
124 add_thickbox(); |
155 wp_enqueue_script( 'customize-loader' ); |
125 wp_enqueue_script('theme-preview'); |
156 |
126 $title = __('Upgrade Theme'); |
157 $title = __('Update Theme'); |
127 $parent_file = 'themes.php'; |
158 $parent_file = 'themes.php'; |
128 $submenu_file = 'themes.php'; |
159 $submenu_file = 'themes.php'; |
129 require_once('admin-header.php'); |
160 require_once(ABSPATH . 'wp-admin/admin-header.php'); |
130 |
161 |
131 $nonce = 'upgrade-theme_' . $theme; |
162 $nonce = 'upgrade-theme_' . $theme; |
132 $url = 'update.php?action=upgrade-theme&theme=' . $theme; |
163 $url = 'update.php?action=upgrade-theme&theme=' . $theme; |
133 |
164 |
134 $upgrader = new Theme_Upgrader( new Theme_Upgrader_Skin( compact('title', 'nonce', 'url', 'theme') ) ); |
165 $upgrader = new Theme_Upgrader( new Theme_Upgrader_Skin( compact('title', 'nonce', 'url', 'theme') ) ); |
135 $upgrader->upgrade($theme); |
166 $upgrader->upgrade($theme); |
136 |
167 |
137 include('admin-footer.php'); |
168 include(ABSPATH . 'wp-admin/admin-footer.php'); |
138 |
169 } elseif ( 'update-selected-themes' == $action ) { |
|
170 if ( ! current_user_can( 'update_themes' ) ) |
|
171 wp_die( __( 'You do not have sufficient permissions to update themes for this site.' ) ); |
|
172 |
|
173 check_admin_referer( 'bulk-update-themes' ); |
|
174 |
|
175 if ( isset( $_GET['themes'] ) ) |
|
176 $themes = explode( ',', stripslashes($_GET['themes']) ); |
|
177 elseif ( isset( $_POST['checked'] ) ) |
|
178 $themes = (array) $_POST['checked']; |
|
179 else |
|
180 $themes = array(); |
|
181 |
|
182 $themes = array_map('urldecode', $themes); |
|
183 |
|
184 $url = 'update.php?action=update-selected-themes&themes=' . urlencode(implode(',', $themes)); |
|
185 $nonce = 'bulk-update-themes'; |
|
186 |
|
187 wp_enqueue_script('jquery'); |
|
188 iframe_header(); |
|
189 |
|
190 $upgrader = new Theme_Upgrader( new Bulk_Theme_Upgrader_Skin( compact( 'nonce', 'url' ) ) ); |
|
191 $upgrader->bulk_upgrade( $themes ); |
|
192 |
|
193 iframe_footer(); |
139 } elseif ( 'install-theme' == $action ) { |
194 } elseif ( 'install-theme' == $action ) { |
140 |
195 |
141 if ( ! current_user_can('install_themes') ) |
196 if ( ! current_user_can('install_themes') ) |
142 wp_die(__('You do not have sufficient permissions to install themes for this blog.')); |
197 wp_die(__('You do not have sufficient permissions to install themes for this site.')); |
143 |
198 |
144 include_once ABSPATH . 'wp-admin/includes/theme-install.php'; //for themes_api.. |
199 include_once ABSPATH . 'wp-admin/includes/theme-install.php'; //for themes_api.. |
145 |
200 |
146 check_admin_referer('install-theme_' . $theme); |
201 check_admin_referer('install-theme_' . $theme); |
147 $api = themes_api('theme_information', array('slug' => $theme, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth. |
202 $api = themes_api('theme_information', array('slug' => $theme, 'fields' => array('sections' => false, 'tags' => false) ) ); //Save on a bit of bandwidth. |
148 |
203 |
149 if ( is_wp_error($api) ) |
204 if ( is_wp_error($api) ) |
150 wp_die($api); |
205 wp_die($api); |
151 |
206 |
152 add_thickbox(); |
207 wp_enqueue_script( 'customize-loader' ); |
153 wp_enqueue_script('theme-preview'); |
208 |
154 $title = __('Install Themes'); |
209 $title = __('Install Themes'); |
155 $parent_file = 'themes.php'; |
210 $parent_file = 'themes.php'; |
156 $submenu_file = 'theme-install.php'; |
211 $submenu_file = 'themes.php'; |
157 require_once('admin-header.php'); |
212 require_once(ABSPATH . 'wp-admin/admin-header.php'); |
158 |
213 |
159 $title = sprintf( __('Installing theme: %s'), $api->name . ' ' . $api->version ); |
214 $title = sprintf( __('Installing Theme: %s'), $api->name . ' ' . $api->version ); |
160 $nonce = 'install-theme_' . $theme; |
215 $nonce = 'install-theme_' . $theme; |
161 $url = 'update.php?action=install-theme&theme=' . $theme; |
216 $url = 'update.php?action=install-theme&theme=' . $theme; |
162 $type = 'web'; //Install theme type, From Web or an Upload. |
217 $type = 'web'; //Install theme type, From Web or an Upload. |
163 |
218 |
164 $upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) ); |
219 $upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) ); |
165 $upgrader->install($api->download_link); |
220 $upgrader->install($api->download_link); |
166 |
221 |
167 include('admin-footer.php'); |
222 include(ABSPATH . 'wp-admin/admin-footer.php'); |
168 |
223 |
169 } elseif ( 'upload-theme' == $action ) { |
224 } elseif ( 'upload-theme' == $action ) { |
170 |
225 |
171 if ( ! current_user_can('install_themes') ) |
226 if ( ! current_user_can('install_themes') ) |
172 wp_die(__('You do not have sufficient permissions to install themes for this blog.')); |
227 wp_die(__('You do not have sufficient permissions to install themes for this site.')); |
173 |
228 |
174 check_admin_referer('theme-upload'); |
229 check_admin_referer('theme-upload'); |
175 |
230 |
176 $file_upload = new File_Upload_Upgrader('themezip', 'package'); |
231 $file_upload = new File_Upload_Upgrader('themezip', 'package'); |
|
232 |
|
233 wp_enqueue_script( 'customize-loader' ); |
177 |
234 |
178 $title = __('Upload Theme'); |
235 $title = __('Upload Theme'); |
179 $parent_file = 'themes.php'; |
236 $parent_file = 'themes.php'; |
180 $submenu_file = 'theme-install.php'; |
237 $submenu_file = 'theme-install.php'; |
181 add_thickbox(); |
238 |
182 wp_enqueue_script('theme-preview'); |
239 require_once(ABSPATH . 'wp-admin/admin-header.php'); |
183 require_once('admin-header.php'); |
|
184 |
240 |
185 $title = sprintf( __('Installing Theme from uploaded file: %s'), basename( $file_upload->filename ) ); |
241 $title = sprintf( __('Installing Theme from uploaded file: %s'), basename( $file_upload->filename ) ); |
186 $nonce = 'theme-upload'; |
242 $nonce = 'theme-upload'; |
187 $url = add_query_arg(array('package' => $file_upload->filename), 'update.php?action=upload-theme'); |
243 $url = add_query_arg(array('package' => $file_upload->id), 'update.php?action=upload-theme'); |
188 $type = 'upload'; //Install plugin type, From Web or an Upload. |
244 $type = 'upload'; //Install plugin type, From Web or an Upload. |
189 |
245 |
190 $upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('type', 'title', 'nonce', 'url') ) ); |
246 $upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('type', 'title', 'nonce', 'url') ) ); |
191 $upgrader->install( $file_upload->package ); |
247 $result = $upgrader->install( $file_upload->package ); |
192 |
248 |
193 include('admin-footer.php'); |
249 if ( $result || is_wp_error($result) ) |
|
250 $file_upload->cleanup(); |
|
251 |
|
252 include(ABSPATH . 'wp-admin/admin-footer.php'); |
194 |
253 |
195 } else { |
254 } else { |
196 do_action('update-custom_' . $action); |
255 do_action('update-custom_' . $action); |
197 } |
256 } |
198 } |
257 } |