'recent-thumbs-widget', 'description' => __('Display recent post, page, or post types with thumbnails', 'recent-thumbs-widget')); /* Widget control settings. */ //$control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'example-widget' ); $control_ops = array('width' => '100%', 'height' => '100%', 'id_base' => 'recent-thumbs-widget'); /* Create the widget. */ $this->WP_Widget('recent-thumbs-widget', __('Recent Post Plus', 'recent-thumbs-widget'), $widget_ops, $control_ops); } /** * How 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']); $page = $instance['page']; //$thumbs = $instance['thumbs']; $qty = $instance['qty']; $show_desc = $instance['desc']; $desc_words = $instance['desc_words']; $thumb_size = $instance['thumb_size']; //$show_sex = isset( $instance['show_sex'] ) ? $instance['show_sex'] : false; /* Before widget (defined by themes). */ echo $before_widget; echo "
"; /* Display the widget title if one was input (before and after defined by themes). */ if ($title) echo $before_title . $title . $after_title; //echo $page; //cwp_layout::tpl_part($slug, $name); $q_args = array( 'meta_key' => '_thumbnail_id', 'showposts' => $qty, 'post_type' => $page, ); $t_query = new WP_Query($q_args); if ($t_query->have_posts()): while ($t_query->have_posts()): $t_query->the_post(); ?>

"; 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['page'] = strip_tags($new_instance['page']); $instance['qty'] = strip_tags($new_instance['qty']); $instance['thumb_size'] = strip_tags($new_instance['thumb_size']); $instance['desc'] = strip_tags($new_instance['desc']); $instance['desc_words'] = strip_tags($new_instance['desc_words']); //$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. */ $defaults = array('title' => __('Recent Post', 'recent-thumbs-widget'), 'page' => '', 'qty' => 5, 'desc_words' => 10, 'desc' => 'OFF','thumb_size' => 'recent-thumb'); $instance = wp_parse_args((array) $instance, $defaults); ?>

/>