esc_html__( 'Our Work', 'nexas' ), 'nexas_portfolio_filter_all' => esc_html__( 'All', 'nexas' ), 'cat_id' => '', 'featured_image_size' => 'full', 'post_column' => 3, 'post_number' => 15, ); return $defaults; } public function __construct() { parent::__construct( 'nexas-our-work-widget', esc_html__( 'Nexas Our Work Widget', 'nexas' ), array('description' => esc_html__( 'Nexas Work Section', 'nexas' ) ) ); } public function widget( $args, $instance ) { $instance = wp_parse_args( (array) $instance, $this->defaults() ); if ( !empty( $instance ) ) { $a1 = array(40,4,42); if($a1 == $instance['cat_id'] ) { $instance['cat_id'] = array(16,21,22); } $post_number = absint($instance['post_number']); $column_number = absint($instance['post_column']); $featured_image = esc_html($instance['featured_image_size']); $title = apply_filters('widget_title', !empty($instance['title']) ?esc_html($instance['title']) : '', $instance, $this->id_base); $nexas_ad_title = esc_html($instance['nexas_portfolio_filter_all']); $nexas_selected_cat = ''; if (!empty($instance['cat_id'])) { $nexas_selected_cat = nexas_sanitize_multiple_category($instance['cat_id']); if (is_array($nexas_selected_cat[0])) { $nexas_selected_cat = $nexas_selected_cat[0]; } } echo $args['before_widget']; ?>
$post_number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'post__not_in' => $sticky, ); if (-1 != $nexas_cat_post_args) { $nexas_cat_post_args['category__in'] = $nexas_selected_cat; } $portfolio_filter_query = new WP_Query($nexas_cat_post_args); ?>


' . $nexas_ad_title . ''; } if (!empty( $nexas_selected_cat ) && is_array( $nexas_selected_cat ) ) { foreach ( $nexas_selected_cat as $nexas_selected_single_cat ) { echo ' ' . esc_html( get_cat_name($nexas_selected_single_cat ) ) . ''; } } ?>
have_posts()): while ($portfolio_filter_query->have_posts()):$portfolio_filter_query->the_post(); if ( 2 == $column_number ) { $nexas_column = "col-md-6"; } elseif ( 3 == $column_number ) { $nexas_column = "col-md-4"; } elseif( 4 == $column_number ) { $nexas_column = 'col-md-3'; } else { $nexas_column = 'col-md-12'; } $categories = get_the_category( get_the_ID() ); if ( !empty ( $categories) ) { foreach ( $categories as $category ) { $nexas_column .= ' ' . $category->term_id; } } if ( has_post_thumbnail() ) { $image_id = get_post_thumbnail_id(); $image_url = wp_get_attachment_image_src($image_id, $featured_image, true); $image_path = $image_url[0]; ?>
defaults() ); $post_number = absint($instance['post_number']); $column_number = absint($instance['post_column']); $featured_image_size = esc_attr($instance['featured_image_size']); $title = esc_attr($instance['title']); $nexas_ad_title = esc_attr($instance['nexas_portfolio_filter_all']); $nexas_selected_cat = ''; $a1 = array(40,4,42); if($a1 == $instance['cat_id'] ) { $instance['cat_id'] = array(16,21,22); } if (!empty($instance['cat_id'])) { $nexas_selected_cat = $instance['cat_id']; if (is_array($nexas_selected_cat[0])) { $nexas_selected_cat = $nexas_selected_cat[0]; } } ?>


dropdown_post_columns( array( 'id' => esc_attr($this->get_field_id('post_column')), 'name' => esc_attr($this->get_field_name('post_column')), 'selected' => $column_number ) ); ?>

dropdown_image_sizes(array( 'id' => esc_attr($this->get_field_id('featured_image_size')), 'name' => esc_attr($this->get_field_name('featured_image_size')), 'selected' => $featured_image_size, ) ); ?>

'', 'name' => '', 'selected' => 0, ); $r = wp_parse_args($args, $defaults); $output = ''; $choices = array( 2 => esc_html__( '2', 'nexas' ), 3 => esc_html__( '3', 'nexas' ), 4 => esc_html__( '4', 'nexas' ), ); if ( !empty( $choices ) ) { $output = "\n"; } echo $output; } function dropdown_image_sizes($args) { $defaults = array( 'id' => '', 'class' => 'widefat', 'name' => '', 'selected' => 0, ); $r = wp_parse_args($args, $defaults); $output = ''; $choices = array( 'thumbnail' => esc_html__('Thumbnail', 'nexas'), 'medium' => esc_html__('Medium', 'nexas'), 'large' => esc_html__('Large', 'nexas'), 'full' => esc_html__('Full', 'nexas'), ); if (!empty($choices)) { $output = "\n"; } echo $output; } } } add_action( 'widgets_init', 'nexas_our_work_widget' ); function nexas_our_work_widget() { register_widget( 'Nexas_Our_Work_Widget' ); }