From d9e724974f6c7d1ca0756f4c85240fc919130393 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Sat, 2 May 2009 00:21:16 +0000 Subject: [PATCH] Add action "in_widget_form" allowing plugins to add extra fields, don't show "Save" button if a widget doesn't have settings form, fixes #9651 git-svn-id: https://develop.svn.wordpress.org/trunk@11155 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/widgets.php | 4 ++-- wp-includes/widgets.php | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/wp-admin/includes/widgets.php b/wp-admin/includes/widgets.php index 771294b73c..cf2a2b81e9 100644 --- a/wp-admin/includes/widgets.php +++ b/wp-admin/includes/widgets.php @@ -166,7 +166,7 @@ function wp_widget_control( $sidebar_args ) { unset($wp_registered_widgets[$widget_id]['_callback']); $widget_title = wp_specialchars( strip_tags( $sidebar_args['widget_name'] ) ); - $has_form = 0; + $has_form = 'noform'; echo $sidebar_args['before_widget']; ?>
@@ -195,7 +195,7 @@ function wp_widget_control( $sidebar_args ) {
- +
diff --git a/wp-includes/widgets.php b/wp-includes/widgets.php index 945af1ecc0..eb3e3ca994 100644 --- a/wp-includes/widgets.php +++ b/wp-includes/widgets.php @@ -65,7 +65,7 @@ class WP_Widget { */ function form($instance) { echo '

' . __('There are no options for this widget.') . '

'; - return false; + return 'noform'; } // Functions you'll need to call. @@ -259,8 +259,14 @@ class WP_Widget { // filters the widget admin form before displaying, return false to stop displaying it $instance = apply_filters('widget_form_callback', $instance, $this); - if ( false !== $instance ) - $this->form($instance); + + $return = null; + if ( false !== $instance ) { + $return = $this->form($instance); + if ( 'noform' !== $return ) + do_action_ref_array( 'in_widget_form', array(&$this) ); // add extra fields in the widget form + } + return $return; } /** Helper function: Registers a single instance. */