From 5ec1077a38fbd398c56e871e5c8106245bb549db Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Wed, 30 Sep 2015 03:21:26 +0000 Subject: [PATCH] Widgets: Introduce a `delete_widget` action, which fires after a widget has been marked for deletion. Props afercia for the initial patch. Fixes #27444. Built from https://develop.svn.wordpress.org/trunk@34714 git-svn-id: http://core.svn.wordpress.org/trunk@34678 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/ajax-actions.php | 4 ++++ wp-admin/widgets.php | 11 +++++++++++ wp-includes/version.php | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php index c380583207..bf04c22bce 100644 --- a/wp-admin/includes/ajax-actions.php +++ b/wp-admin/includes/ajax-actions.php @@ -1877,6 +1877,10 @@ function wp_ajax_save_widget() { $sidebar = array_diff( $sidebar, array($widget_id) ); $_POST = array('sidebar' => $sidebar_id, 'widget-' . $id_base => array(), 'the-widget-id' => $widget_id, 'delete_widget' => '1'); + + /** This action is documented in wp-admin/widgets.php */ + do_action( 'delete_widget', $widget_id, $sidebar_id, $id_base ); + } elseif ( $settings && preg_match( '/__i__|%i%/', key($settings) ) ) { if ( !$multi_number ) wp_die( $error ); diff --git a/wp-admin/widgets.php b/wp-admin/widgets.php index b72fd195e2..69b3161529 100644 --- a/wp-admin/widgets.php +++ b/wp-admin/widgets.php @@ -152,6 +152,17 @@ if ( isset($_POST['savewidget']) || isset($_POST['removewidget']) ) { $sidebar = array_diff( $sidebar, array($widget_id) ); $_POST = array('sidebar' => $sidebar_id, 'widget-' . $id_base => array(), 'the-widget-id' => $widget_id, 'delete_widget' => '1'); + + /** + * Fires immediately after a widget has been marked for deletion. + * + * @since 4.4.0 + * + * @param string $widget_id ID of the widget marked for deletion. + * @param string $sidebar_id ID of the sidebar the widget was deleted from. + * @param string $id_base ID base for the widget. + */ + do_action( 'delete_widget', $widget_id, $sidebar_id, $id_base ); } $_POST['widget-id'] = $sidebar; diff --git a/wp-includes/version.php b/wp-includes/version.php index c372acbeff..3edff20577 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34713'; +$wp_version = '4.4-alpha-34714'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.