defaults = array( 'title' => '', 'post_type' => '', 'image_size' => '', 'post_num' => 5, 'show_caption' => 'none' ); $widget_ops = array( 'classname' => 'flexslider_widget', 'description' => __( 'Featured Slider', 'acfs' ), ); $control_ops = array( 'id_base' => 'arconix-flexslider-widget' ); $this->WP_Widget( 'arconix-flexslider-widget', 'Arconix - FlexSlider', $widget_ops, $control_ops ); if ( is_active_widget( false, false, $this->id_base ) ) add_action( 'wp_head', array( $this, 'load_js' ), 99 ); } function load_js() { /*?> defaults ); /** Before widget (defined by themes) */ echo $before_widget; /** Title of widget (before and after defined by themes) */ if( ! empty( $instance['title'] ) ) echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title; $query_args = array( 'post_type' => $instance['post_type'], 'posts_per_page' => $instance['post_num'], 'meta_key' => '_thumbnail_id' /** Should pull only posts with featured images */ ); $flex_posts = new WP_Query( $query_args ); if ( $flex_posts->have_posts() ) { echo '
'; } /** After widget (defined by themes) */ echo $after_widget; } /** * Update a particular instance. * * @param array $new_instance New settings for this instance as input by the user via form() * @param array $old_instance Old settings for this instance * @return array Settings to save or bool false to cancel saving * @since 0.1 */ function update( $new_instance, $old_instance ) { $new_instance['title'] = strip_tags( $new_instance['title'] ); $new_instance['post_num'] = strip_tags( $new_instance['post_num'] ); return $new_instance; } /** * Widget form * * @param array $instance Current settings * @since 0.1 * @version 0.2 */ function form( $instance ) { /** Merge with defaults */ $instance = wp_parse_args( (array) $instance, $this->defaults ); ?>