Plugins: Rename the delete_plugin action hook (introduced in [35094]) to deleted_plugin as it fires ''following'' a plugin deletion attempt.

Further, introduce a new `delete_plugin` action hook, to be fired ''before'' a plugin deletion attempt. Both changes bring parity with other such transactional hooks in core that fire before and after certain actions, including on plugin activation/deactivation and install/uninstall, among others.

Props johnjamesjacoby.
Fixes #26904.

Built from https://develop.svn.wordpress.org/trunk@35669


git-svn-id: http://core.svn.wordpress.org/trunk@35633 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Drew Jaynes 2015-11-18 17:58:26 +00:00
parent 8919d9a88a
commit 283b7d0a66
2 changed files with 12 additions and 2 deletions

View File

@ -816,7 +816,17 @@ function delete_plugins( $plugins, $deprecated = '' ) {
uninstall_plugin($plugin_file);
}
/**
* Fires immediately before a plugin deletion attempt.
*
* @since 4.4.0
*
* @param string $plugin_file Plugin file name.
*/
do_action( 'delete_plugin', $plugin_file );
$this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin_file ) );
// If plugin is in its own directory, recursively delete the directory.
if ( strpos( $plugin_file, '/' ) && $this_plugin_dir != $plugins_dir ) { //base check on if plugin includes directory separator AND that it's not the root plugin folder
$deleted = $wp_filesystem->delete( $this_plugin_dir, true );
@ -832,7 +842,7 @@ function delete_plugins( $plugins, $deprecated = '' ) {
* @param string $plugin_file Plugin file name.
* @param bool $deleted Whether the plugin deletion was successful.
*/
do_action( 'delete_plugin', $plugin_file, $deleted );
do_action( 'deleted_plugin', $plugin_file, $deleted );
if ( ! $deleted ) {
$errors[] = $plugin_file;

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-beta4-35668';
$wp_version = '4.4-beta4-35669';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.