Widgets: Introduce a `delete_widget` action, which fires after a widget has been marked for deletion.

Props afercia for the initial patch.
Fixes #27444.


git-svn-id: https://develop.svn.wordpress.org/trunk@34714 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Drew Jaynes 2015-09-30 03:20:41 +00:00
parent 30a165a1a5
commit a774dfbb08
2 changed files with 15 additions and 0 deletions

View File

@ -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 );

View File

@ -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;