Codex tools: Log in
Languages: English • 日本語 • (Add your language)
wp-includes/deprecated.php.
Use any of these functions instead.Contents |
Register widget for sidebar with backwards compatibility.
Provides backwards compatability to wp_register_sidebar_widget(). Registers callback as a widget output function with unique index name. This causes a draggable object containing name to appear in the admin interface.
A basic widget is simply a function that prints some HTML. To get a widget included in the widgets palette, you must register it via this function.
It is possible for theme authors to define replacement widgets within functions.php. Replace an existing widget by registering its name with a new callback. An empty callback will unregister a widget.
Because each widget has a unique name and a non-unique callback, the default markup before a widget looks like this:
<li id="{name}" class="{callback}">{callback output}</li>
When you register a widget you may pass a custom HTML class to replace callback. This is most useful for object-oriented widgets whose callbacks are passed as arrays.
<?php register_sidebar_widget( $name, $output_callback, $classname ); ?>
<?php
function my_widget {
// print some HTML for the widget to display here.
}
register_sidebar_widget("my_widget", "my_widget");
?>
Given a class my_widget whose method that prints the widget HTML is called display, you would use the following code:
<?php
class my_widget {
function display() {
// print some HTML for the widget to display here.
}
}
register_sidebar_widget('My Widget', array('my_widget', 'display')); // callback is mywidget::display
?>
register_sidebar_widget() is located in wp-includes/deprecated.php.
Widgets: is_active_widget(), the_widget(), register_widget(), unregister_widget(), wp_register_widget_control(), wp_unregister_widget_control(), wp_convert_widget_settings(), wp_get_widget_defaults(), wp_widget_description()