'', 'beauty_studio_widget_title' => '', 'post_advanced_option' => 'recent', 'beauty_studio_post_cat' => -1, 'beauty_studio_post_tag' => -1, 'post_number' => 4, 'content_from' => 'excerpt', 'content_words' => 21, 'column_number' => 4, 'display_type' => 'column', 'orderby' => 'date', 'order' => 'DESC', 'enable_prev_next' => 1, 'beauty_studio_img_size' => 'large', 'background_options' => 'default' ); function __construct() { parent::__construct( /*Base ID of your widget*/ 'beauty_studio_posts_col', /*Widget name will appear in UI*/ esc_html__('AT Posts Column', 'beauty-studio'), /*Widget description*/ array( 'description' => esc_html__( 'Show posts from selected category with advanced options', 'beauty-studio' ) ) ); } /*Widget Backend*/ public function form( $instance ) { $instance = wp_parse_args( (array) $instance, $this->defaults); $unique_id = esc_attr( $instance['unique_id'] ); $title = esc_attr( $instance['beauty_studio_widget_title'] ); $post_advanced_option = esc_attr( $instance['post_advanced_option'] ); $beauty_studio_post_cat = esc_attr( $instance['beauty_studio_post_cat'] ); $beauty_studio_post_tag = esc_attr( $instance['beauty_studio_post_tag'] ); $post_number = absint( $instance['post_number'] ); $content_from = esc_attr( $instance['content_from'] ); $content_words = intval( $instance['content_words'] ); $column_number = absint( $instance['column_number'] ); $display_type = esc_attr( $instance['display_type'] ); $orderby = esc_attr( $instance['orderby'] ); $order = esc_attr( $instance['order'] ); $enable_prev_next = esc_attr( $instance['enable_prev_next'] ); $beauty_studio_img_size = esc_attr( $instance['beauty_studio_img_size'] ); $background_options = esc_attr( $instance['background_options'] ); ?>
false, 'orderby' => 'name', 'order' => 'asc', 'show_count' => 1, 'hide_empty' => 1, 'echo' => 1, 'selected' => $beauty_studio_post_cat, 'hierarchical' => 1, 'name' => $this->get_field_name('beauty_studio_post_cat'), 'id' => $this->get_field_id('beauty_studio_post_cat'), 'class' => 'widefat', 'taxonomy' => 'category', 'hide_if_empty' => false, ); wp_dropdown_categories( $beauty_studio_dropown_cat ); ?>
false, 'orderby' => 'name', 'order' => 'asc', 'show_count' => 1, 'hide_empty' => 1, 'echo' => 1, 'selected' => $beauty_studio_post_tag, 'hierarchical' => 1, 'name' => $this->get_field_name('beauty_studio_post_tag'), 'id' => $this->get_field_name('beauty_studio_post_tag'), 'class' => 'widefat', 'taxonomy' => 'post_tag', 'hide_if_empty' => false, ); wp_dropdown_categories( $beauty_studio_dropown_cat ); ?>
/>
defaults); $unique_id = !empty( $instance['unique_id'] ) ? esc_attr( $instance['unique_id'] ) : esc_attr( $this->id ); $beauty_studio_post_cat = esc_attr( $instance['beauty_studio_post_cat'] ); $beauty_studio_post_tag = esc_attr( $instance['beauty_studio_post_tag'] ); $title = !empty( $instance['beauty_studio_widget_title'] ) ? esc_attr( $instance['beauty_studio_widget_title'] ) : get_cat_name($beauty_studio_post_cat); $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); $post_advanced_option = esc_attr( $instance['post_advanced_option'] ); $post_number = absint( $instance['post_number'] ); $content_from = esc_attr( $instance['content_from'] ); $content_words = intval( $instance['content_words'] ); $column_number = absint( $instance['column_number'] ); $display_type = esc_attr( $instance['display_type'] ); $orderby = esc_attr( $instance['orderby'] ); $order = esc_attr( $instance['order'] ); $enable_prev_next = esc_attr( $instance['enable_prev_next'] ); $beauty_studio_img_size = esc_attr( $instance['beauty_studio_img_size'] ); $background_options = esc_attr( $instance['background_options'] ); $bg_gray_class = $background_options == 'gray'?'at-gray-bg':''; /** * 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'] = $beauty_studio_post_cat; break; case 'tag' : $query_args['tag'] = $beauty_studio_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'; } $beauty_studio_featured_query = new WP_Query( $query_args ); if ($beauty_studio_featured_query->have_posts()) : echo $args['before_widget']; $animation = "init-animate zoomIn"; ?> "; // Reset the global $the_post as this query will have stomped on it endif; wp_reset_postdata(); } } // Class Beauty_Studio_Posts_Col ends here }