[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

Widget API: WP_Widget base class

File Size: 599 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.

Sub-classes should over-ride 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.
since: 2.8.0

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.
since: 2.8.0

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

param: array $instance Current settings.
return: string Default return is 'noform'.
since: 2.8.0

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

param: string $id_base         Optional 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 information
param: array  $control_options Optional. Widget control options. See wp_register_widget_control() for
since: 2.8.0

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

param: string $id_base         Optional 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 information
param: array  $control_options Optional. Widget control options. See wp_register_widget_control() for
since: 2.8.0

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
since: 2.8.0
since: 4.4.0 Array format field names are now accepted.

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`.
since: 2.8.0
since: 4.4.0 Array format field IDs are now accepted.

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

since: 2.8.0

_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
since: 2.8.0

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

return: callable Display callback.
since: 2.8.0

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

return: callable Update callback.
since: 2.8.0

_get_form_callback()   X-Ref
Retrieves the form callback.

return: callable Form callback.
since: 2.8.0

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.
since: 3.9.0

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 {
since: 2.8.0

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

param: int $deprecated Not used.
since: 2.8.0

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

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

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

param: integer $number Optional. The unique order number of this widget instance
since: 2.8.0

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.
since: 2.8.0

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

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



Generated: Tue Sep 17 01:00:03 2019 Cross-referenced by PHPXref 0.7.1