'widget_recent_entries', /* description as it appears in admin */ 'description' => __('Display a list of recent post entries with a specific illustration.')); parent::__construct('illustrated-recent-posts', __('Illustrated Recent Posts'), $widget_ops); } /* PURE */ function find_first_image($content) { $first_img = ''; $output = preg_match_all('//i', $content, $matches); if (!($output === false)) { $first_img = $matches[1][0]; } return $first_img; } function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? 'Recent Posts' : $instance['title'], $instance, $this->id_base); $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false; if (empty($instance['number']) || (!($number = absint($instance['number'])))) { $number = 5; } if(!($c = $instance["cats"])) { $c = ''; } $irpw_args=array( 'showposts' => $count, 'category__in'=> $c, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ); $irp_widget = new WP_Query($irpw_args); echo $before_widget; while ($irp_widget->have_posts()) { $irp_widget->the_post(); $first_image = find_first_image($post->post_content); ?>

/

get_field_id('cats') .'[]" name="'. $this->get_field_name('cats') .'[]"'; $isChecked = function($c) use ($cats_instance) { $is_a_cat = function($ic) use ($c) { return ($ic == $c->term_id); }; return (count(array_filter($cats_instance, $is_a_cat)) > 0); }; $reduce_categories = function($result, $c) use ($isChecked, $option_base) { $checked = ($isChecked($c)) ? ' checked="checked"' : ''; if ($result == NULL) { return $option_base . $checked . ' value="' . $c->term_id.'" /> ' . $c->cat_name . '
'; } return $result . $option_base . $checked . ' value="' . $c->term_id.'" /> ' . $c->cat_name . '
'; }; ?>