[ Index ]

WordPress Cross Reference

title

Body

[close]

/wp-includes/ -> widgets.php (summary)

API for creating dynamic sidebar without hardcoding functionality into themes. Includes both internal WordPress routines and theme use routines. This functionality was found in a plugin before WordPress 2.2 release which included it in the core from that point on.

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

Defines 2 classes

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

WP_Widget_Factory:: (29 methods):
  WP_Widget_Factory()
  register()
  unregister()
  _register_widgets()
  register_widget()
  unregister_widget()
  register_sidebars()
  register_sidebar()
  unregister_sidebar()
  wp_register_sidebar_widget()
  wp_widget_description()
  wp_sidebar_description()
  wp_unregister_sidebar_widget()
  wp_register_widget_control()
  _register_widget_update_callback()
  _register_widget_form_callback()
  wp_unregister_widget_control()
  dynamic_sidebar()
  is_active_widget()
  is_dynamic_sidebar()
  is_active_sidebar()
  wp_get_sidebars_widgets()
  wp_set_sidebars_widgets()
  wp_get_widget_defaults()
  wp_convert_widget_settings()
  the_widget()
  _get_widget_id_base()
  _wp_sidebars_changed()
  retrieve_widgets()


Class: WP_Widget  - X-Ref

This class must be extended for each widget and WP_Widget::widget(), WP_Widget::update()
and WP_Widget::form() need to be over-ridden.

widget($args, $instance)   X-Ref
No description

update($new_instance, $old_instance)   X-Ref
No description

form($instance)   X-Ref
No description

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

param: string $id_base Optional Base ID for the widget, lower case,
param: string $name Name for the widget displayed on the configuration page.
param: array $widget_options Optional Passed to wp_register_sidebar_widget()
param: array $control_options Optional Passed to wp_register_widget_control()

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


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 form() fields

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

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

_register()   X-Ref
No description

_set($number)   X-Ref
No description

_get_display_callback()   X-Ref
No description

_get_update_callback()   X-Ref
No description

_get_form_callback()   X-Ref
No description

display_callback( $args, $widget_args = 1 )   X-Ref
No description

update_callback( $widget_args = 1 )   X-Ref
No description

form_callback( $widget_args = 1 )   X-Ref
No description

_register_one($number = -1)   X-Ref
No description

save_settings($settings)   X-Ref
No description

get_settings()   X-Ref
No description

Class: WP_Widget_Factory  - X-Ref

Singleton that registers and instantiates WP_Widget classes.

WP_Widget_Factory()   X-Ref
No description

register($widget_class)   X-Ref
No description

unregister($widget_class)   X-Ref
No description

_register_widgets()   X-Ref
No description

register_widget($widget_class)   X-Ref
Register a widget

Registers a WP_Widget widget

param: string $widget_class The name of a class that extends WP_Widget

unregister_widget($widget_class)   X-Ref
Unregister a widget

Unregisters a WP_Widget widget. Useful for unregistering default widgets.
Run within a function hooked to the widgets_init action.

param: string $widget_class The name of a class that extends WP_Widget

register_sidebars($number = 1, $args = array()   X-Ref
Creates multiple sidebars.

If you wanted to quickly create multiple sidebars for a theme or internally.
This function will allow you to do so. If you don't pass the 'name' and/or
'id' in $args, then they will be built for you.

The default for the name is "Sidebar #", with '#' being replaced with the
number the sidebar is currently when greater than one. If first sidebar, the
name will be just "Sidebar". The default for id is "sidebar-" followed by the
number the sidebar creation is currently at. If the id is provided, and multiple
sidebars are being defined, the id will have "-2" appended, and so on.

param: int $number Number of sidebars to create.
param: string|array $args Builds Sidebar based off of 'name' and 'id' values.

register_sidebar($args = array()   X-Ref
Builds the definition for a single sidebar and returns the ID.

Accepts either a string or an array and then parses that against a set
of default arguments for the new sidebar. WordPress will automatically
generate a sidebar ID and name based on the current number of registered
sidebars if those arguments are not included.

When allowing for automatic generation of the name and ID parameters, keep
in mind that the incrementor for your sidebar can change over time depending
on what other plugins and themes are installed.

If theme support for 'widgets' has not yet been added when this function is
called, it will be automatically enabled through the use of add_theme_support()

Arguments passed as a string should be separated by '&':

e.g. 'name=Sidebar&id=my_prefix_sidebar'

The same arguments passed as an array:

array(
'name' => 'Sidebar',
'id'   => 'my_prefix_sidebar',
)

Arguments:
name          - The name or title of the sidebar displayed in the admin dashboard.
id            - The unique identifier by which the sidebar will be called.
before_widget - HTML content that will be prepended to each widget's HTML output
when assigned to this sidebar.
after_widget  - HTML content that will be appended to each widget's HTML output
when assigned to this sidebar.
before_title  - HTML content that will be prepended to the sidebar title when displayed.
after_title   - HTML content that will be appended to the sidebar title when displayed.

param: string|array $args Arguments for the sidebar being registered.
return: string Sidebar ID added to $wp_registered_sidebars global.

unregister_sidebar( $name )   X-Ref
Removes a sidebar from the list.

param: string $name The ID of the sidebar when it was added.

wp_register_sidebar_widget($id, $name, $output_callback, $options = array()   X-Ref
Register widget for use in sidebars.

The default widget option is 'classname' that can be override.

The function can also be used to unregister widgets when $output_callback
parameter is an empty string.

param: int|string $id Widget ID.
param: string $name Widget display title.
param: callback $output_callback Run when widget is called.
param: array|string $options Optional. Widget Options.
param: mixed $params,... Widget parameters to add to widget.
return: null Will return if $output_callback is empty after removing widget.

wp_widget_description( $id )   X-Ref
Retrieve description for widget.

When registering widgets, the options can also include 'description' that
describes the widget for display on the widget administration panel or
in the theme.

param: int|string $id Widget ID.
return: string Widget description, if available. Null on failure to retrieve description.

wp_sidebar_description( $id )   X-Ref
Retrieve description for a sidebar.

When registering sidebars a 'description' parameter can be included that
describes the sidebar for display on the widget administration panel.

param: int|string $id sidebar ID.
return: string Sidebar description, if available. Null on failure to retrieve description.

wp_unregister_sidebar_widget($id)   X-Ref
Remove widget from sidebar.

param: int|string $id Widget ID.

wp_register_widget_control($id, $name, $control_callback, $options = array()   X-Ref
Registers widget control callback for customizing options.

The options contains the 'height', 'width', and 'id_base' keys. The 'height'
option is never used. The 'width' option is the width of the fully expanded
control form, but try hard to use the default width. The 'id_base' is for
multi-widgets (widgets which allow multiple instances such as the text
widget), an id_base must be provided. The widget id will end up looking like
{$id_base}-{$unique_number}.

param: int|string $id Sidebar ID.
param: string $name Sidebar display name.
param: callback $control_callback Run when sidebar is displayed.
param: array|string $options Optional. Widget options. See above long description.
param: mixed $params,... Optional. Additional parameters to add to widget.

_register_widget_update_callback($id_base, $update_callback, $options = array()   X-Ref
No description

_register_widget_form_callback($id, $name, $form_callback, $options = array()   X-Ref
No description

wp_unregister_widget_control($id)   X-Ref
Remove control callback for widget.

param: int|string $id Widget ID.

dynamic_sidebar($index = 1)   X-Ref
Display dynamic sidebar.

By default this displays the default sidebar or 'sidebar-1'. If your theme specifies the 'id' or
'name' parameter for its registered sidebars you can pass an id or name as the $index parameter.
Otherwise, you can pass in a numerical index to display the sidebar at that index.

param: int|string $index Optional, default is 1. Index, name or ID of dynamic sidebar.
return: bool True, if widget sidebar was found and called. False if not found or not called.

is_active_widget($callback = false, $widget_id = false, $id_base = false, $skip_inactive = true)   X-Ref
Whether widget is displayed on the front-end.

Either $callback or $id_base can be used
$id_base is the first argument when extending WP_Widget class
Without the optional $widget_id parameter, returns the ID of the first sidebar
in which the first instance of the widget with the given callback or $id_base is found.
With the $widget_id parameter, returns the ID of the sidebar where
the widget with that callback/$id_base AND that ID is found.

NOTE: $widget_id and $id_base are the same for single widgets. To be effective
this function has to run after widgets have initialized, at action 'init' or later.

param: string $callback Optional, Widget callback to check.
param: int $widget_id Optional, but needed for checking. Widget ID.
param: string $id_base Optional, the base ID of a widget created by extending WP_Widget.
param: bool $skip_inactive Optional, whether to check in 'wp_inactive_widgets'.
return: mixed false if widget is not active or id of sidebar in which the widget is active.

is_dynamic_sidebar()   X-Ref
Whether the dynamic sidebar is enabled and used by theme.

return: bool True, if using widgets. False, if not using widgets.

is_active_sidebar( $index )   X-Ref
Whether a sidebar is in use.

param: mixed $index Sidebar name, id or number to check.
return: bool true if the sidebar is in use, false otherwise.

wp_get_sidebars_widgets($deprecated = true)   X-Ref
Retrieve full list of sidebars and their widgets.

Will upgrade sidebar widget list, if needed. Will also save updated list, if
needed.

param: bool $deprecated Not used (deprecated).
return: array Upgraded list of widgets to version 3 array format when called from the admin.

wp_set_sidebars_widgets( $sidebars_widgets )   X-Ref
Set the sidebar widget option to update sidebars.

param: array $sidebars_widgets Sidebar widgets and their settings.

wp_get_widget_defaults()   X-Ref
Retrieve default registered sidebars list.

return: array

wp_convert_widget_settings($base_name, $option_name, $settings)   X-Ref
Convert the widget settings from single to multi-widget format.

return: array

the_widget($widget, $instance = array()   X-Ref
Output an arbitrary widget as a template tag

param: string $widget the widget's PHP class name (see default-widgets.php)
param: array $instance the widget's instance settings
param: array $args the widget's sidebar args
return: void

_get_widget_id_base($id)   X-Ref
Private


_wp_sidebars_changed()   X-Ref
Handle sidebars config after theme change


retrieve_widgets($theme_changed = false)   X-Ref
No description



Generated: Tue Mar 25 01:41:18 2014 WordPress honlapkészítés: online1.hu