[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/ -> class-wp-widget.php (summary)

Widget API: WP_Widget base class

File Size: 641 lines (18 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

WP_Widget:: (19 methods):
  widget()
  update()
  form()
  __construct()
  WP_Widget()
  get_field_name()
  get_field_id()
  _register()
  _set()
  _get_display_callback()
  _get_update_callback()
  _get_form_callback()
  is_preview()
  display_callback()
  update_callback()
  form_callback()
  _register_one()
  save_settings()
  get_settings()


Class: WP_Widget  - X-Ref

Core base class extended to register widgets.

This class must be extended for each widget, and WP_Widget::widget() must be overridden.

If adding widget options, WP_Widget::update() and WP_Widget::form() should also be overridden.

widget( $args, $instance )   X-Ref
Echoes the widget content.

Subclasses should override this function to generate their widget code.

param: array $args     Display arguments including 'before_title', 'after_title',
param: array $instance The settings for the particular instance of the widget.

update( $new_instance, $old_instance )   X-Ref
Updates a particular instance of a widget.

This function should check that `$new_instance` is set correctly. The newly-calculated
value of `$instance` should be returned. If false is returned, the instance won't be
saved/updated.

param: array $new_instance New settings for this instance as input by the user via
param: array $old_instance Old settings for this instance.
return: array Settings to save or bool false to cancel saving.

form( $instance )   X-Ref
Outputs the settings update form.

param: array $instance The settings for the particular instance of the widget.
return: string|void Default return is 'noform'.

__construct( $id_base, $name, $widget_options = array()   X-Ref
PHP5 constructor.

param: string $id_base         Base ID for the widget, lowercase and unique. If left empty,
param: string $name            Name for the widget displayed on the configuration page.
param: array  $widget_options  Optional. Widget options. See wp_register_sidebar_widget() for
param: array  $control_options Optional. Widget control options. See wp_register_widget_control() for

WP_Widget( $id_base, $name, $widget_options = array()   X-Ref
PHP4 constructor.

param: string $id_base         Base ID for the widget, lowercase and unique. If left empty,
param: string $name            Name for the widget displayed on the configuration page.
param: array  $widget_options  Optional. Widget options. See wp_register_sidebar_widget() for
param: array  $control_options Optional. Widget control options. See wp_register_widget_control() for

get_field_name( $field_name )   X-Ref
Constructs name attributes for use in form() fields

This function should be used in form() methods to create name attributes for fields
to be saved by update()

param: string $field_name Field name.
return: string Name attribute for `$field_name`.

get_field_id( $field_name )   X-Ref
Constructs id attributes for use in WP_Widget::form() fields.

This function should be used in form() methods to create id attributes
for fields to be saved by WP_Widget::update().

param: string $field_name Field name.
return: string ID attribute for `$field_name`.

_register()   X-Ref
Register all widget instances of this widget class.


_set( $number )   X-Ref
Sets the internal order number for the widget instance.

param: int $number The unique order number of this widget instance compared to other

_get_display_callback()   X-Ref
Retrieves the widget display callback.

return: callable Display callback.

_get_update_callback()   X-Ref
Retrieves the widget update callback.

return: callable Update callback.

_get_form_callback()   X-Ref
Retrieves the form callback.

return: callable Form callback.

is_preview()   X-Ref
Determines whether the current request is inside the Customizer preview.

If true -- the current request is inside the Customizer preview, then
the object cache gets suspended and widgets should check this to decide
whether they should store anything persistently to the object cache,
to transients, or anywhere else.

return: bool True if within the Customizer preview, false if not.

display_callback( $args, $widget_args = 1 )   X-Ref
Generates the actual widget content (Do NOT override).

Finds the instance and calls WP_Widget::widget().

param: array     $args        Display arguments. See WP_Widget::widget() for information
param: int|array $widget_args {

update_callback( $deprecated = 1 )   X-Ref
Handles changed settings (Do NOT override).

param: int $deprecated Not used.

form_callback( $widget_args = 1 )   X-Ref
Generates the widget control form (Do NOT override).

param: int|array $widget_args {
return: string|null

_register_one( $number = -1 )   X-Ref
Registers an instance of the widget class.

param: int $number Optional. The unique order number of this widget instance

save_settings( $settings )   X-Ref
Saves the settings for all instances of the widget class.

param: array $settings Multi-dimensional array of widget instance settings.

get_settings()   X-Ref
Retrieves the settings for all instances of the widget class.

return: array Multi-dimensional array of widget instance settings.



Generated : Tue Dec 24 08:20:01 2024 Cross-referenced by PHPXref