'sample-widget', 'description' => __('Display...', 'sample-widget')); /* Widget control settings. */ //$control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'example-widget' ); $control_ops = array('width' => '100%', 'height' => '100%', 'id_base' => 'sample-widget'); /* Create the widget. */ //TODO replace sample-widget with widget slug/name $this->WP_Widget('sample-widget', __('Recent-Post(thumbs)', 'sample-widget'), $widget_ops, $control_ops); } /** * Now to display the widget on the screen. */ function widget($args, $instance) { extract($args); /* Our variables from the widget settings. */ $title = apply_filters('widget_title', $instance['title']); $show_desc = $instance['desc']; //$show_sex = isset( $instance['show_sex'] ) ? $instance['show_sex'] : false; /* Before widget (defined by themes). */ echo $before_widget; echo "
"; echo $after_widget; } /** * Update the widget settings. */ function update($new_instance, $old_instance) { $instance = $old_instance; /* Strip tags for title and name to remove HTML (important for text inputs). */ $instance['title'] = strip_tags($new_instance['title']); $instance['desc'] = strip_tags($new_instance['desc']); //$instance['thumbs'] = strip_tags($new_instance['thumbs']); return $instance; } /** * Displays the widget settings controls on the widget panel. * Make use of the get_field_id() and get_field_name() function * when creating your form elements. This handles the confusing stuff. */ function form($instance) { /* Set up some default widget settings. */ //TODO change title Sample widget to widget name $defaults = array('title' => __('Sample Widget', 'bj'), 'desc' => '',); $instance = wp_parse_args((array) $instance, $defaults); ?>
/>