WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )
apply_filters( "hook_name", "what_to_filter" )
.Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
This hook occurs 11 times in this file.
Line | Code |
---|---|
202 |
|
203 | // Get the URL to the zip file |
204 | $r = $current->response[ $plugin ]; |
205 |
|
206 | if ( empty($r->package) ) |
207 | return new WP_Error('no_package', __('Upgrade package not available.')); |
208 |
|
209 | // Download the package |
210 | $package = $r->package; |
211 | apply_filters('update_feedback', sprintf(__('Downloading update from %s'), $package)); |
212 | $download_file = download_url($package); |
213 |
|
214 | if ( is_wp_error($download_file) ) |
215 | return new WP_Error('download_failed', __('Download failed.'), $download_file->get_error_message()); |
216 |
|
217 | $working_dir = $content_dir . 'upgrade/' . basename($plugin, '.php'); |
218 |
|
219 | // Clean up working directory |
220 | if ( $wp_filesystem->is_dir($working_dir) ) |
221 | $wp_filesystem->delete($working_dir, true); |
222 |
|
223 | apply_filters('update_feedback', __('Unpacking the update')); |
224 | // Unzip package to working directory |
225 | $result = unzip_file($download_file, $working_dir); |
226 |
|
227 | // Once extracted, delete the package |
228 | unlink($download_file); |
229 |
|
230 | if ( is_wp_error($result) ) { |
231 | $wp_filesystem->delete($working_dir, true); |
232 | return $result; |
233 | } |
234 |
|
235 | if ( is_plugin_active($plugin) ) { |
236 | //Deactivate the plugin silently, Prevent deactivation hooks from running. |
237 | apply_filters('update_feedback', __('Deactivating the plugin')); |
238 | deactivate_plugins($plugin, true); |
239 | } |
240 |
|
241 | // Remove the existing plugin. |
242 | apply_filters('update_feedback', __('Removing the old version of the plugin')); |
243 | $this_plugin_dir = trailingslashit( dirname($plugins_dir . $plugin) ); |
244 |
|
245 | // If plugin is in its own directory, recursively delete the directory. |
246 | if ( strpos($plugin, '/') && $this_plugin_dir != $plugins_dir ) //base check on if plugin includes directory seperator AND that its not the root plugin folder |
247 | $deleted = $wp_filesystem->delete($this_plugin_dir, true); |
248 | else |
249 | $deleted = $wp_filesystem->delete($plugins_dir . $plugin); |
250 |
|
251 | if ( ! $deleted ) { |
252 | $wp_filesystem->delete($working_dir, true); |
253 | return new WP_Error('delete_failed', __('Could not remove the old plugin')); |
254 | } |
255 |
|
256 | apply_filters('update_feedback', __('Installing the latest version')); |
257 | // Copy new version of plugin into place. |
258 | $result = copy_dir($working_dir, $plugins_dir); |
259 | if ( is_wp_error($result) ) { |
260 | $wp_filesystem->delete($working_dir, true); |
261 | return $result; |
262 | } |
263 |
|
264 | //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin |
265 | $filelist = array_keys( $wp_filesystem->dirlist($working_dir) ); |
Line | Code |
326 | return new WP_Error('fs_no_content_dir', __('Unable to locate WordPress Content directory (wp-content).')); |
327 |
|
328 | $themes_dir = trailingslashit( $themes_dir ); |
329 | $content_dir = trailingslashit( $content_dir ); |
330 |
|
331 | if ( empty($r->package) ) |
332 | return new WP_Error('no_package', __('Upgrade package not available.')); |
333 |
|
334 | // Download the package |
335 | apply_filters('update_feedback', sprintf(__('Downloading update from %s'), $r['package'])); |
336 | $download_file = download_url($r['package']); |
337 |
|
338 | if ( is_wp_error($download_file) ) |
339 | return new WP_Error('download_failed', __('Download failed.'), $download_file->get_error_message()); |
340 |
|
341 | $working_dir = $content_dir . 'upgrade/' . basename($theme_directory); |
342 |
|
343 | // Clean up working directory |
344 | if ( $wp_filesystem->is_dir($working_dir) ) |
345 | $wp_filesystem->delete($working_dir, true); |
346 |
|
347 | apply_filters('update_feedback', __('Unpacking the update')); |
348 | // Unzip package to working directory |
349 | $result = unzip_file($download_file, $working_dir); |
350 |
|
351 | // Once extracted, delete the package |
352 | unlink($download_file); |
353 |
|
354 | if ( is_wp_error($result) ) { |
355 | $wp_filesystem->delete($working_dir, true); |
356 | return $result; |
Line | Code |
359 | //TODO: Is theme currently active? If so, set default theme |
360 | /* |
361 | if ( is_plugin_active($plugin) ) { |
362 | //Deactivate the plugin silently, Prevent deactivation hooks from running. |
363 | apply_filters('update_feedback', __('Deactivating the plugin')); |
364 | deactivate_plugins($plugin, true); |
365 | }*/ |
366 |
|
367 | // Remove the existing plugin. |
368 | apply_filters('update_feedback', __('Removing the old version of the theme')); |
369 | $deleted = $wp_filesystem->delete($themes_dir . $theme_directory, true); |
370 |
|
371 | if ( ! $deleted ) { |
372 | $wp_filesystem->delete($working_dir, true); |
373 | return new WP_Error('delete_failed', __('Could not remove the old plugin')); |
374 | } |
375 |
|
376 | apply_filters('update_feedback', __('Installing the latest version')); |
377 | // Copy new version of plugin into place. |
378 | $result = copy_dir($working_dir, $themes_dir); |
379 | if ( is_wp_error($result) ) { |
380 | $wp_filesystem->delete($working_dir, true); |
381 | return $result; |
382 | } |
383 |
|
384 | //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin |
385 | //$filelist = array_keys( $wp_filesystem->dirlist($working_dir) ); |
Line | Code |
434 | return new WP_Error('fs_no_content_dir', __('Unable to locate WordPress Content directory (wp-content).')); |
435 |
|
436 | $wp_dir = trailingslashit( $wp_dir ); |
437 | $content_dir = trailingslashit( $content_dir ); |
438 |
|
439 | // Get the URL to the zip file |
440 | $package = $current->package; |
441 |
|
442 | // Download the package |
443 | apply_filters('update_feedback', sprintf(__('Downloading update from %s'), $package)); |
444 | $download_file = download_url($package); |
445 |
|
446 | if ( is_wp_error($download_file) ) |
447 | return new WP_Error('download_failed', __('Download failed.'), $download_file->get_error_message()); |
448 |
|
449 | $working_dir = $content_dir . 'upgrade/core'; |
450 | // Clean up working directory |
451 | if ( $wp_filesystem->is_dir($working_dir) ) { |
452 | $wp_filesystem->delete($working_dir, true); |
453 | } |
454 |
|
455 | apply_filters('update_feedback', __('Unpacking the core update')); |
456 | // Unzip package to working directory |
457 | $result = unzip_file($download_file, $working_dir); |
458 | // Once extracted, delete the package |
459 | unlink($download_file); |
460 |
|
461 | if ( is_wp_error($result) ) { |
462 | $wp_filesystem->delete($working_dir, true); |
463 | return $result; |
464 | } |