'', 'post_advanced_option' => 'recent', 'online_shop_post_cat' => -1, 'online_shop_post_tag' => -1, 'post_number' => 4, 'column_number' => 4, 'display_type' => 'column', 'orderby' => 'date', 'order' => 'DESC', 'view_all_option' => 'disable', 'all_link_text' => '', 'all_link_url' => '', 'enable_prev_next' => 1, 'online_shop_img_size' => 'large' ); function __construct() { parent::__construct( /*Base ID of your widget*/ 'online_shop_posts_col', /*Widget name will appear in UI*/ esc_html__('AT Posts Column', 'online-shop'), /*Widget description*/ array( 'description' => esc_html__( 'Show posts from selected category with advanced options', 'online-shop' ), ) ); } /*Widget Backend*/ public function form( $instance ) { $instance = wp_parse_args( (array) $instance, $this->defaults); $online_shop_widget_title = esc_attr( $instance['online_shop_widget_title'] ); $post_advanced_option = esc_attr( $instance[ 'post_advanced_option' ] ); $online_shop_post_cat = esc_attr( $instance['online_shop_post_cat'] ); $online_shop_post_tag = esc_attr( $instance['online_shop_post_tag'] ); $post_number = absint( $instance[ 'post_number' ] ); $column_number = absint( $instance[ 'column_number' ] ); $display_type = esc_attr( $instance[ 'display_type' ] ); $orderby = esc_attr( $instance[ 'orderby' ] ); $order = esc_attr( $instance[ 'order' ] ); $view_all_option = esc_attr( $instance[ 'view_all_option' ] ); $all_link_text = esc_attr( $instance['all_link_text'] ); $all_link_url = esc_url( $instance['all_link_url'] ); $enable_prev_next = esc_attr( $instance['enable_prev_next'] ); $online_shop_img_size = esc_attr( $instance['online_shop_img_size'] ); $choices = online_shop_get_image_sizes_options(); ?>
false, 'orderby' => 'name', 'order' => 'asc', 'show_count' => 1, 'hide_empty' => 1, 'echo' => 1, 'selected' => $online_shop_post_cat, 'hierarchical' => 1, 'name' => $this->get_field_name('online_shop_post_cat'), 'id' => $this->get_field_id('online_shop_post_cat'), 'class' => 'widefat', 'taxonomy' => 'category', 'hide_if_empty' => false, ); wp_dropdown_categories( $online_shop_dropown_cat ); ?>
false, 'orderby' => 'name', 'order' => 'asc', 'show_count' => 1, 'hide_empty' => 1, 'echo' => 1, 'selected' => $online_shop_post_tag, 'hierarchical' => 1, 'name' => $this->get_field_name('online_shop_post_tag'), 'id' => $this->get_field_name('online_shop_post_tag'), 'class' => 'widefat', 'taxonomy' => 'post_tag', 'hide_if_empty' => false, ); wp_dropdown_categories( $online_shop_dropown_cat ); ?>
/>
defaults); $online_shop_post_cat = esc_attr( $instance['online_shop_post_cat'] ); $online_shop_post_tag = esc_attr( $instance['online_shop_post_tag'] ); $online_shop_widget_title = !empty( $instance['online_shop_widget_title'] ) ? esc_attr( $instance['online_shop_widget_title'] ) : get_cat_name($online_shop_post_cat); $online_shop_widget_title = apply_filters( 'widget_title', $online_shop_widget_title, $instance, $this->id_base ); $post_advanced_option = esc_attr( $instance[ 'post_advanced_option' ] ); $post_number = absint( $instance[ 'post_number' ] ); $column_number = absint( $instance[ 'column_number' ] ); $display_type = esc_attr( $instance[ 'display_type' ] ); $orderby = esc_attr( $instance[ 'orderby' ] ); $order = esc_attr( $instance[ 'order' ] ); $view_all_option = esc_attr( $instance[ 'view_all_option' ] ); $all_link_text = esc_html( $instance[ 'all_link_text' ] ); $all_link_url = esc_url( $instance[ 'all_link_url' ] ); $enable_prev_next = esc_attr( $instance['enable_prev_next'] ); $online_shop_img_size = esc_attr( $instance['online_shop_img_size'] ); /** * Filter the arguments for the Recent Posts widget. * * @since 1.0.0 * * @see WP_Query * */ $sticky = get_option( 'sticky_posts' ); $query_args = array( 'posts_per_page' => $post_number, 'post_status' => 'publish', 'post_type' => 'post', 'no_found_rows' => 1, 'order' => $order, 'ignore_sticky_posts' => true, 'post__not_in' => $sticky ); switch ( $post_advanced_option ) { case 'cat' : $query_args['cat'] = $online_shop_post_cat; break; case 'tag' : $query_args['tag'] = $online_shop_post_tag; break; } switch ( $orderby ) { case 'ID' : case 'author' : case 'title' : case 'date' : case 'modified' : case 'rand' : case 'comment_count' : case 'menu_order' : $query_args['orderby'] = $orderby; break; default : $query_args['orderby'] = 'date'; } $online_shop_featured_query = new WP_Query( $query_args ); if ($online_shop_featured_query->have_posts()) : echo $args['before_widget']; if ( !empty( $online_shop_widget_title ) || 'disable' != $view_all_option || ( 1 == $enable_prev_next && 'carousel' == $display_type ) ){ if( -1 != $online_shop_post_cat ){ echo "