Make WordPress Core

Ticket #9701: 9701.diff

File 9701.diff, 1.4 KB (added by Denis-de-Bernardy, 16 years ago)
  • wp-includes/widgets.php

     
    11831183function unregister_widget_control($id) {
    11841184        return wp_unregister_widget_control($id);
    11851185}
     1186
     1187/**
     1188 * output an arbitrary widget
     1189 *
     1190 * @since 2.8
     1191 *
     1192 * @param string $widget the widget's class
     1193 * @param array $instance the arbitrary widget's instance
     1194 * @param array $args the arbitrary widget's sidebar args
     1195 * @return void
     1196 **/
     1197
     1198function the_widget($widget, $instance = array(), $args = array()) {
     1199        global $wp_widget_factory;
     1200       
     1201        if ( !is_a($wp_widget_factory->widgets[$widget], 'WP_Widget') )
     1202                return;
     1203       
     1204        if ( in_the_loop() ) {
     1205                $default_args = array('before_widget' => '<li class="widget $s">', 'after_widget' =>'</li>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>');
     1206        } else {
     1207                $default_args = array('before_widget' => '<div class="widget $s">', 'after_widget' =>'</div>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>');
     1208        }
     1209       
     1210        $args = wp_parse_args($args, $default_args);
     1211        $instance = wp_parse_args($instance);
     1212       
     1213        $args['before_widget'] = sprintf($args['before_widget'], $wp_widget_factory->widgets[$widget]->widget_options['classname']);
     1214       
     1215        $wp_widget_factory->widgets[$widget]->_set(-1);
     1216        $wp_widget_factory->widgets[$widget]->widget($args, $instance);
     1217}