Warning: This function has been deprecated. Use wp_register_sidebar_widget() instead.
register_sidebar_widget() WordPress Function
The register_sidebar_widget() function allows you to register a sidebar widget for your Wordpress site. This function takes two parameters: the id of the sidebar widget and the name of the sidebar widget. Once you have registered a sidebar widget, you can then use the sidebar id to display the widget in your site's sidebar.
register_sidebar_widget( string|int $name, callable $output_callback, string $classname = '', mixed $params ) #
Register widget for sidebar with backward compatibility.
Description
Allows $name to be an array that accepts either three elements to grab the first element and the third for the name or just uses the first element of the array for the name.
Passes to wp_register_sidebar_widget() after argument list and backward compatibility is complete.
See also
Parameters
- $name
(string|int)(Required)Widget ID.
- $output_callback
(callable)(Required)Run when widget is called.
- $classname
(string)(Optional) Classname widget option.
Default value: ''
- $params
(mixed)(Optional)Widget parameters.
Source
File: wp-includes/deprecated.php
function register_sidebar_widget($name, $output_callback, $classname = '', ...$params) {
_deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_sidebar_widget()' );
// Compat.
if ( is_array( $name ) ) {
if ( count( $name ) === 3 ) {
$name = sprintf( $name[0], $name[2] );
} else {
$name = $name[0];
}
}
$id = sanitize_title( $name );
$options = array();
if ( ! empty( $classname ) && is_string( $classname ) ) {
$options['classname'] = $classname;
}
wp_register_sidebar_widget( $id, $name, $output_callback, $options, ...$params );
}
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
| Version | Description |
|---|---|
| 2.8.0 | Use wp_register_sidebar_widget() |
| 2.2.0 | Introduced. |