register_sidebar_widget

Register widget for sidebar with backward compatibility.

Description

register_sidebar_widget( (string) $name, (callable) $output_callback, (string) $classname = '' ); 

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.

Parameters (3)

0. $name (string)
Widget ID.
1. $output_callback (callable)
Run when widget is called.
2. $classname — Optional. (string) => ''
Classname widget option. Default empty.

Usage

  1. if ( !function_exists( 'register_sidebar_widget' ) ) { 
  2. require_once ABSPATH . WPINC . '/deprecated.php'; 
  3.  
  4. // Widget ID. 
  5. $name = ''; 
  6.  
  7. // Run when widget is called. 
  8. $output_callback = null; 
  9.  
  10. // Optional. Classname widget option. Default empty. 
  11. $classname = ''; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = register_sidebar_widget($name, $output_callback, $classname); 
  15.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/deprecated.php  
  1. function register_sidebar_widget($name, $output_callback, $classname = '') { 
  2. _deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_sidebar_widget()' ); 
  3. // Compat 
  4. if ( is_array($name) ) { 
  5. if ( count($name) == 3 ) 
  6. $name = sprintf($name[0], $name[2]); 
  7. else 
  8. $name = $name[0]; 
  9.  
  10. $id = sanitize_title($name); 
  11. $options = array(); 
  12. if ( !empty($classname) && is_string($classname) ) 
  13. $options['classname'] = $classname; 
  14. $params = array_slice(func_get_args(), 2); 
  15. $args = array($id, $name, $output_callback, $options); 
  16. if ( !empty($params) ) 
  17. $args = array_merge($args, $params); 
  18.  
  19. call_user_func_array('wp_register_sidebar_widget', $args);