Advertisements

the_widget

Definition:
function the_widget($widget, $instance = array() {}

Output an arbitrary widget as a template tag

Parameters

  • string $widget: the widget’s PHP class name (see default-widgets.php)
  • array $instance: the widget’s instance settings
  • array $args: the widget’s sidebar args

Defined actions

  • the_widget
    do_action( 'the_widget', $widget, $instance, $args );

Source code

function the_widget($widget, $instance = array(), $args = array()) {

	global $wp_widget_factory;



	$widget_obj = $wp_widget_factory->widgets[$widget];

	if ( !is_a($widget_obj, 'WP_Widget') )

		return;



	$before_widget = sprintf('<div class="widget %s">', $widget_obj->widget_options['classname'] );

	$default_args = array( 'before_widget' => $before_widget, 'after_widget' => "</div>", 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>' );



	$args = wp_parse_args($args, $default_args);

	$instance = wp_parse_args($instance);



	do_action( 'the_widget', $widget, $instance, $args );



	$widget_obj->_set(-1);

	$widget_obj->widget($args, $instance);

}

3061

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: