defaults = array( 'title' => '', 'posts_cat' => '', 'posts_num' => 1, 'posts_offset' => 0, 'orderby' => '', 'order' => '', 'exclude_displayed' => 0, 'show_image' => 0, 'image_alignment' => '', 'image_size' => '', 'show_gravatar' => 0, 'gravatar_alignment' => '', 'gravatar_size' => '', 'show_title' => 0, 'show_byline' => 0, 'post_info' => '[post_date] ' . __( 'By', 'omega' ) . ' [post_author_posts_link] [post_comments]', 'show_content' => 'excerpt', 'content_limit' => '', 'more_text' => __( '[Read More...]', 'omega' ), 'extra_num' => '', 'extra_title' => '', 'more_from_category' => '', 'more_from_category_text' => __( 'More Posts from this Category', 'omega' ), ); $widget_ops = array( 'classname' => 'featured-content featuredpost', 'description' => __( 'Displays featured posts with thumbnails', 'omega' ), ); $control_ops = array( 'id_base' => 'featured-post', 'width' => 505, 'height' => 350, ); parent::__construct( 'featured-post', __( 'Featured Posts', 'omega' ), $widget_ops, $control_ops ); } /** * Echo the widget content. * * @since 0.9.1 * * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget. * @param array $instance The settings for the particular instance of the widget */ function widget( $args, $instance ) { global $wp_query, $_omega_displayed_ids; //$_omega_displayed_ids[] = get_the_ID(); extract( $args ); //* Merge with defaults $instance = wp_parse_args( (array) $instance, $this->defaults ); echo $before_widget; //* Set up the author bio if ( ! empty( $instance['title'] ) ) echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title; $query_args = array( 'post_type' => 'post', 'cat' => $instance['posts_cat'], 'showposts' => $instance['posts_num'], 'offset' => $instance['posts_offset'], 'orderby' => $instance['orderby'], 'order' => $instance['order'], ); //* Exclude displayed IDs from this loop? if ( $instance['exclude_displayed'] ) $query_args['post__not_in'] = (array) $_omega_displayed_ids; $wp_query = new WP_Query( $query_args ); if ( have_posts() ) : while ( have_posts() ) : the_post(); $_omega_displayed_ids[] = get_the_ID(); echo '
'; $image = omega_get_image( array( 'format' => 'html', 'size' => $instance['image_size'], ) ); if ( $instance['show_image'] && $image ) printf( '%s', get_permalink(), the_title_attribute( 'echo=0' ), esc_attr( $instance['image_alignment'] ), $image ); if ( ! empty( $instance['show_gravatar'] ) ) { echo ''; echo get_avatar( get_the_author_meta( 'ID' ), $instance['gravatar_size'] ); echo ''; } if ( $instance['show_title'] ) echo '
'; if ( ! empty( $instance['show_title'] ) ) { printf( '

%s

', get_permalink(), the_title_attribute( 'echo=0' ), get_the_title() ); } if ( ! empty( $instance['show_byline'] ) && ! empty( $instance['post_info'] ) ) printf( '', do_shortcode( $instance['post_info'] ) ); if ( $instance['show_title'] ) echo '
'; if ( ! empty( $instance['show_content'] ) ) { echo '
'; if ( 'excerpt' == $instance['show_content'] ) { the_excerpt(); } elseif ( 'content-limit' == $instance['show_content'] ) { the_content_limit( (int) $instance['content_limit'], esc_html( $instance['more_text'] ) ); } else { global $more; $orig_more = $more; $more = 0; the_content( esc_html( $instance['more_text'] ) ); $more = $orig_more; } echo '
'; } echo '
'; endwhile; endif; //* Restore original query wp_reset_query(); //* The EXTRA Posts (list) if ( ! empty( $instance['extra_num'] ) ) { if ( ! empty( $instance['extra_title'] ) ) echo $before_title . esc_html( $instance['extra_title'] ) . $after_title; $offset = intval( $instance['posts_num'] ) + intval( $instance['posts_offset'] ); $query_args = array( 'cat' => $instance['posts_cat'], 'showposts' => $instance['extra_num'], 'offset' => $offset, ); $wp_query = new WP_Query( $query_args ); $listitems = ''; if ( have_posts() ) { while ( have_posts() ) { the_post(); $_omega_displayed_ids[] = get_the_ID(); $listitems .= sprintf( '
  • %s
  • ', get_permalink(), the_title_attribute( 'echo=0' ), get_the_title() ); } if ( mb_strlen( $listitems ) > 0 ) printf( '', $listitems ); } //* Restore original query wp_reset_query(); } if ( ! empty( $instance['more_from_category'] ) && ! empty( $instance['posts_cat'] ) ) printf( '

    %3$s

    ', esc_url( get_category_link( $instance['posts_cat'] ) ), esc_attr( get_cat_name( $instance['posts_cat'] ) ), esc_html( $instance['more_from_category_text'] ) ); echo $after_widget; } /** * Update a particular instance. * * This function should check that $new_instance is set correctly. * The newly calculated value of $instance should be returned. * If "false" is returned, the instance won't be saved/updated. * * @since 0.9.1 * * @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 */ function update( $new_instance, $old_instance ) { $new_instance['title'] = strip_tags( $new_instance['title'] ); $new_instance['more_text'] = strip_tags( $new_instance['more_text'] ); $new_instance['post_info'] = wp_kses_post( $new_instance['post_info'] ); return $new_instance; } /** * Echo the settings update form. * * @since 0.9.1 * * @param array $instance Current settings */ function form( $instance ) { //* Merge with defaults $instance = wp_parse_args( (array) $instance, $this->defaults ); ?>

    $this->get_field_name( 'posts_cat' ), 'selected' => $instance['posts_cat'], 'orderby' => 'Name', 'hierarchical' => 1, 'show_option_all' => __( 'All Categories', 'omega' ), 'hide_empty' => '0', ); wp_dropdown_categories( $categories_args ); ?>

    />

    />

    />

    />

    />


    :

    />