WordPress.org

Make WordPress Core


Ignore:
Timestamp:
04/20/2009 10:58:50 AM (11 years ago)
Author:
azaozz
Message:

Add and edit widget when js is disabled, see #9511

File:
1 edited

Legend:

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

    r10991 r11009  
    2424class WP_Widget {
    2525
    26     var $id_base;           // Root id for all widgets of this type.
     26    var $id_base;           // Root id for all widgets of this type.
    2727    var $name;              // Name for this widget type.
    2828    var $widget_options;    // Option array passed to wp_register_sidebar_widget()
     
    6262    /** Echo the settings update form
    6363     *
    64      * @param array $instance Current settings 
     64     * @param array $instance Current settings
    6565     */
    6666    function form($instance) {
    6767        echo '<p>' . __('There are no options for this widget.') . '</p>';
     68        return false;
    6869    }
    6970
     
    8889    function __construct( $id_base, $name, $widget_options = array(), $control_options = array() ) {
    8990        $this->id_base = $id_base;
     91    //  $this->id_base = str_replace( 'wp_widget_', '', strtolower(get_class($this)) );
    9092        $this->name = $name;
    9193        $this->option_name = 'widget_' . $id_base;
    9294        $this->widget_options = wp_parse_args( $widget_options, array('classname' => $this->option_name) );
    9395        $this->control_options = wp_parse_args( $control_options, array('id_base' => $this->id_base) );
    94 
    95         //add_action( 'widgets_init', array( &$this, '_register' ) );
    9696    }
    9797
     
    208208                }
    209209            } else {
    210                 foreach ( (array) $_POST['widget-' . $this->id_base] as $number => $new_instance ) {
     210                if ( isset($_POST['widget-' . $this->id_base]) && is_array($_POST['widget-' . $this->id_base]) ) {
     211                    $settings = $_POST['widget-' . $this->id_base];
     212                } else {
     213                    $num = $_POST['multi_number'] ? (int) $_POST['multi_number'] : (int) $_POST['widget_number'];
     214                    $settings = array( $num => array() );
     215                }
     216
     217                foreach ( $settings as $number => $new_instance ) {
    211218                    $new_instance = stripslashes_deep($new_instance);
    212219                    $this->_set($number);
     
    245252        }
    246253
    247         $this->form($instance);
     254        return $this->form($instance);
    248255    }
    249256
Note: See TracChangeset for help on using the changeset viewer.