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.
| Class | Description |
|---|---|
| WP_Widget | This class must be extended for each widget and WP_Widget::widget(), WP_Widget::update() and WP_Widget::form() need to be over-ridden. |
| WP_Widget_Factory | Singleton that registers and instantiates WP_Widget classes. |
Display dynamic sidebar.
By default it displays the default sidebar or 'sidebar-1'. The 'sidebar-1' is not named by the theme, the actual name is '1', but 'sidebar-' is added to the registered sidebars for the name. If you named your sidebar 'after-post', then the parameter $index will still be 'after-post', but the lookup will be for 'sidebar-after-post'.
It is confusing for the $index parameter, but just know that it should just work. When you register the sidebar in the theme, you will use the same name for this function or "Pay no heed to the man behind the curtain." Just accept it as an oddity of WordPress sidebar register and display.
Whether a sidebar is in use.
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.
Whether the dynamic sidebar is enabled and used by theme.
Builds the definition for a single sidebar and returns the ID.
The $args parameter takes either a string or an array with 'name' and 'id' contained in either usage. It will be noted that the values will be applied to all sidebars, so if creating more than one, it will be advised to allow for WordPress to create the defaults for you.
Example for string would be
name - The name of the sidebar, which presumably the title which will be displayed. id - The unique identifier by which the sidebar will be called by. before_widget - The content that will prepended to the widgets when they are displayed. after_widget - The content that will be appended to the widgets when they are displayed. before_title - The content that will be prepended to the title when displayed. after_title - the content that will be appended to the title when displayed.
<em>Content</em> is assumed to be HTML and should be formatted as such, but doesn't have to be.
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.
Register a widget
Registers a WP_Widget widget
Output an arbitrary widget as a template tag
Removes a sidebar from the list.
Unregister a widget
Unregisters a WP_Widget widget. Useful for unregistering default widgets. Run within a function hooked to the widgets_init action.
Convert the widget settings from single to multi-widget format.
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.
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}.
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.
Remove widget from sidebar.
Remove control callback for widget.
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.
Private
Documentation generated on Tue, 15 May 2012 23:18:35 +0000 by phpDocumentor 1.4.1