mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
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: http://svn.automattic.com/wordpress/trunk@11155 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
31e805261c
commit
aae118f16c
@ -166,7 +166,7 @@ function wp_widget_control( $sidebar_args ) {
|
|||||||
unset($wp_registered_widgets[$widget_id]['_callback']);
|
unset($wp_registered_widgets[$widget_id]['_callback']);
|
||||||
|
|
||||||
$widget_title = wp_specialchars( strip_tags( $sidebar_args['widget_name'] ) );
|
$widget_title = wp_specialchars( strip_tags( $sidebar_args['widget_name'] ) );
|
||||||
$has_form = 0;
|
$has_form = 'noform';
|
||||||
|
|
||||||
echo $sidebar_args['before_widget']; ?>
|
echo $sidebar_args['before_widget']; ?>
|
||||||
<div class="widget-top">
|
<div class="widget-top">
|
||||||
@ -195,7 +195,7 @@ function wp_widget_control( $sidebar_args ) {
|
|||||||
|
|
||||||
<div class="widget-control-actions">
|
<div class="widget-control-actions">
|
||||||
<a class="button widget-control-remove alignleft" href="<?php echo $edit ? clean_url( add_query_arg( array( 'remove' => $id_format, 'key' => $key, '_wpnonce' => $nonce ) ) ) : '#remove'; ?>"><?php _e('Remove'); ?></a>
|
<a class="button widget-control-remove alignleft" href="<?php echo $edit ? clean_url( add_query_arg( array( 'remove' => $id_format, 'key' => $key, '_wpnonce' => $nonce ) ) ) : '#remove'; ?>"><?php _e('Remove'); ?></a>
|
||||||
<?php if ( false !== $has_form ) { ?>
|
<?php if ( 'noform' !== $has_form ) { ?>
|
||||||
<input type="submit" name="savewidget" class="button-primary widget-control-save alignright" value="<?php _e('Save'); ?>" />
|
<input type="submit" name="savewidget" class="button-primary widget-control-save alignright" value="<?php _e('Save'); ?>" />
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<br class="clear" />
|
<br class="clear" />
|
||||||
|
@ -65,7 +65,7 @@ class WP_Widget {
|
|||||||
*/
|
*/
|
||||||
function form($instance) {
|
function form($instance) {
|
||||||
echo '<p>' . __('There are no options for this widget.') . '</p>';
|
echo '<p>' . __('There are no options for this widget.') . '</p>';
|
||||||
return false;
|
return 'noform';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Functions you'll need to call.
|
// 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
|
// filters the widget admin form before displaying, return false to stop displaying it
|
||||||
$instance = apply_filters('widget_form_callback', $instance, $this);
|
$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. */
|
/** Helper function: Registers a single instance. */
|
||||||
|
Loading…
Reference in New Issue
Block a user