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. git-svn-id: https://develop.svn.wordpress.org/trunk@35669 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
8e439f1bd0
commit
6ad74f666e
@ -816,7 +816,17 @@ function delete_plugins( $plugins, $deprecated = '' ) {
|
|||||||
uninstall_plugin($plugin_file);
|
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 ) );
|
$this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin_file ) );
|
||||||
|
|
||||||
// If plugin is in its own directory, recursively delete the directory.
|
// 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
|
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 );
|
$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 string $plugin_file Plugin file name.
|
||||||
* @param bool $deleted Whether the plugin deletion was successful.
|
* @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 ) {
|
if ( ! $deleted ) {
|
||||||
$errors[] = $plugin_file;
|
$errors[] = $plugin_file;
|
||||||
|
Loading…
Reference in New Issue
Block a user