"widget" function not being called
-
I created a custom plugin/widget following tutorial instruction. It shows up fine in control panel, but when I add it to the “Primary Widget Area”, it doesn’t show up. The rendering function “widget” is not being called. Is there any thing I need to do to enable it?
class CustomWidget extends WP_Widget{ /** * Declares our class. * */ function CustomWidget(){ $widget_ops = array('classname' => '_custom_widget', 'description' => __( "Custom Widget for Food") ); $control_ops = array('width' => 250, 'height' => 400, 'id_base' => '-custom-widget'); $this->WP_Widget('CustomWidget', ' Custom Widget', $widget_ops, $control_ops); } /** * Displays the Widget * */ function widget($args, $instance){ die; extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title']); $menu_order = $instance['menu_order']; $show_siblings = $instance['show_siblings']; $exclude = $instance['exclude']; echo $before_widget; echo $before_title; echo 'Title!!!'; echo $after_title; echo 'Content!!!'; echo $after_widget; } /** * Saves the widget's settings. * */ function update($new_instance, $old_instance){ $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); return $instance; } /** * Creates the edit form for the widget. * */ function form($instance){ //Defaults $instance = wp_parse_args( (array) $instance, array('title'=>'', 'lineOne'=>'Hello', 'lineTwo'=>'World') ); $title = htmlspecialchars($instance['title']); $menu_order = htmlspecialchars($instance['menu_order']); $show_siblings = htmlspecialchars($instance['show_siblings']); $exclude = htmlspecialchars($instance['exclude']); echo 'No options yet<BR><BR>'; } } add_action( 'widgets_init', create_function( '', 'register_widget("CustomWidget");' ) );
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘"widget" function not being called’ is closed to new replies.