WordPress.org

Make WordPress Core

Changeset 11155


Ignore:
Timestamp:
05/02/2009 12:21:16 AM (9 years ago)
Author:
azaozz
Message:

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

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/widgets.php

    r11041 r11155  
    167167
    168168    $widget_title = wp_specialchars( strip_tags( $sidebar_args['widget_name'] ) );
    169     $has_form = 0;
     169    $has_form = 'noform';
    170170
    171171    echo $sidebar_args['before_widget']; ?>
     
    196196    <div class="widget-control-actions">
    197197        <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>
    198 <?php       if ( false !== $has_form ) { ?>
     198<?php       if ( 'noform' !== $has_form ) { ?>
    199199        <input type="submit" name="savewidget" class="button-primary widget-control-save alignright" value="<?php _e('Save'); ?>" />
    200200<?php       } ?>
  • trunk/wp-includes/widgets.php

    r11134 r11155  
    6666    function form($instance) {
    6767        echo '<p>' . __('There are no options for this widget.') . '</p>';
    68         return false;
     68        return 'noform';
    6969    }
    7070
     
    260260        // filters the widget admin form before displaying, return false to stop displaying it
    261261        $instance = apply_filters('widget_form_callback', $instance, $this);
    262         if ( false !== $instance )
    263             $this->form($instance);
     262
     263        $return = null;
     264        if ( false !== $instance ) {
     265            $return = $this->form($instance);
     266            if ( 'noform' !== $return )
     267                do_action_ref_array( 'in_widget_form', array(&$this) ); // add extra fields in the widget form
     268        }
     269        return $return;
    264270    }
    265271
Note: See TracChangeset for help on using the changeset viewer.