- var $id_base; // Root id for all widgets of this type.
- var $name; // Name for this widget type.
- var $widget_options; // Option array passed to wp_register_sidebar_widget()
- var $control_options; // Option array passed to wp_register_widget_control()
+ public $id_base; // Root id for all widgets of this type.
+ public $name; // Name for this widget type.
+ public $widget_options; // Option array passed to wp_register_sidebar_widget()
+ public $control_options; // Option array passed to wp_register_widget_control()
- var $number = false; // Unique ID number of the current instance.
- var $id = false; // Unique ID string of the current instance (id_base-number)
- var $updated = false; // Set true when we update the data after a POST submit - makes sure we don't do it twice.
+ public $number = false; // Unique ID number of the current instance.
+ public $id = false; // Unique ID string of the current instance (id_base-number)
+ public $updated = false; // Set true when we update the data after a POST submit - makes sure we don't do it twice.
* @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
* @param array $instance The settings for the particular instance of the widget
*/
* @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
* @param array $instance The settings for the particular instance of the widget
*/
* @param array $old_instance Old settings for this instance
* @return array Settings to save or bool false to cancel saving
*/
* @param array $old_instance Old settings for this instance
* @return array Settings to save or bool false to cancel saving
*/
* - width: required if more than 250px
* - height: currently not used but may be needed in the future
*/
* - width: required if more than 250px
* - height: currently not used but may be needed in the future
*/
- function __construct( $id_base, $name, $widget_options = array(), $control_options = array() ) {
+ public function __construct( $id_base, $name, $widget_options = array(), $control_options = array() ) {
$this->id_base = empty($id_base) ? preg_replace( '/(wp_)?widget_/', '', strtolower(get_class($this)) ) : strtolower($id_base);
$this->name = $name;
$this->option_name = 'widget_' . $this->id_base;
$this->id_base = empty($id_base) ? preg_replace( '/(wp_)?widget_/', '', strtolower(get_class($this)) ) : strtolower($id_base);
$this->name = $name;
$this->option_name = 'widget_' . $this->id_base;
- function WP_Widget( $id_base, $name, $widget_options = array(), $control_options = array() ) {
+ public function WP_Widget( $id_base, $name, $widget_options = array(), $control_options = array() ) {
WP_Widget::__construct( $id_base, $name, $widget_options, $control_options );
}
WP_Widget::__construct( $id_base, $name, $widget_options, $control_options );
}
return 'widget-' . $this->id_base . '-' . $this->number . '-' . $field_name;
}
// Private Functions. Don't worry about these.
return 'widget-' . $this->id_base . '-' . $this->number . '-' . $field_name;
}
// Private Functions. Don't worry about these.
/** Generate the actual widget content.
* Just finds the instance and calls widget().
* Do NOT over-ride this function. */
/** Generate the actual widget content.
* Just finds the instance and calls widget().
* Do NOT over-ride this function. */
if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) {
// Delete the settings for this instance of the widget
if ( isset($_POST['the-widget-id']) )
if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) {
// Delete the settings for this instance of the widget
if ( isset($_POST['the-widget-id']) )
wp_register_sidebar_widget( $this->id, $this->name, $this->_get_display_callback(), $this->widget_options, array( 'number' => $number ) );
_register_widget_update_callback( $this->id_base, $this->_get_update_callback(), $this->control_options, array( 'number' => -1 ) );
_register_widget_form_callback( $this->id, $this->name, $this->_get_form_callback(), $this->control_options, array( 'number' => $number ) );
}
wp_register_sidebar_widget( $this->id, $this->name, $this->_get_display_callback(), $this->widget_options, array( 'number' => $number ) );
_register_widget_update_callback( $this->id_base, $this->_get_update_callback(), $this->control_options, array( 'number' => -1 ) );
_register_widget_form_callback( $this->id, $this->name, $this->_get_form_callback(), $this->control_options, array( 'number' => $number ) );
}
$settings['_multiwidget'] = 1;
update_option( $this->option_name, $settings );
}
$settings['_multiwidget'] = 1;
update_option( $this->option_name, $settings );
}
$settings = get_option($this->option_name);
if ( false === $settings && isset($this->alt_option_name) )
$settings = get_option($this->option_name);
if ( false === $settings && isset($this->alt_option_name) )
add_action( 'widgets_init', array( $this, '_register_widgets' ), 100 );
}
add_action( 'widgets_init', array( $this, '_register_widgets' ), 100 );
}
global $wp_registered_widgets;
$keys = array_keys($this->widgets);
$registered = array_keys($wp_registered_widgets);
global $wp_registered_widgets;
$keys = array_keys($this->widgets);
$registered = array_keys($wp_registered_widgets);
if ( !in_array( $sidebar, $registered_sidebar_keys ) ) {
$_sidebars_widgets['orphaned_widgets_' . ++$orphaned] = $widgets;
if ( !in_array( $sidebar, $registered_sidebar_keys ) ) {
$_sidebars_widgets['orphaned_widgets_' . ++$orphaned] = $widgets;