esc_html__('Our Treatment Gallery', 'better-health'), 'better_health_portfolio_filter_all' => esc_html__('All', 'better-health'), 'cat_id' => array(20,17,18), 'featured_image_size' => 'full', 'post_column' => 3, 'post_number' => 6, ); return $defaults; } public function __construct() { parent::__construct( 'better-health-our-treatment-gallery-widget', esc_html__('Better Health Our Treatment Gallery Widget', 'better-health'), array('description' => esc_html__('Better Health Our Treatment Gallery Section', 'better-health')) ); } public function widget($args, $instance) { $instance = wp_parse_args((array)$instance, $this->defaults()); if (!empty($instance)) { $a1 = array(10); if($a1 == $instance['cat_id'] ) { $instance['cat_id'] = array(2); } $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); $better_health_ad_title = esc_html($instance['better_health_portfolio_filter_all']); $better_health_selected_cat = ''; if (!empty($instance['cat_id'])) { $better_health_selected_cat = better_health_sanitize_multiple_category($instance['cat_id']); if (is_array($better_health_selected_cat[0])) { $better_health_selected_cat = $better_health_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 != $better_health_cat_post_args) { $better_health_cat_post_args['category__in'] = $better_health_selected_cat; } $portfolio_filter_query = new WP_Query($better_health_cat_post_args); ?>

' . $better_health_ad_title . ''; } if (!empty($better_health_selected_cat) && is_array($better_health_selected_cat)) { foreach ($better_health_selected_cat as $better_health_selected_single_cat) { echo ' ' . esc_html(get_cat_name($better_health_selected_single_cat)) . ''; } } ?>
have_posts()): while ($portfolio_filter_query->have_posts()):$portfolio_filter_query->the_post(); if (2 == $column_number) { $better_health_column = "col-md-6"; } elseif (3 == $column_number) { $better_health_column = "col-md-4"; } elseif (4 == $column_number) { $better_health_column = 'col-md-3'; } else { $better_health_column = 'col-md-12'; } $categories = get_the_category(get_the_ID()); if (!empty($categories)) { foreach ($categories as $category) { $better_health_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']); $better_health_ad_title = esc_attr($instance['better_health_portfolio_filter_all']); $better_health_selected_cat = ''; $a1 = array(10); if($a1 == $instance['cat_id'] ) { $instance['cat_id'] = array(2); } if (!empty($instance['cat_id'])) { $better_health_selected_cat = $instance['cat_id']; if (is_array($better_health_selected_cat[0])) { $better_health_selected_cat = $better_health_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, ); $result = wp_parse_args($args, $defaults); $output = ''; $choices = array( 2 => esc_html__('2', 'better-health'), 3 => esc_html__('3', 'better-health'), 4 => esc_html__('4', 'better-health'), ); if (!empty($choices)) { $output = "\n"; } echo $output; } function dropdown_image_sizes($args) { $defaults = array( 'id' => '', 'class' => 'widefat', 'name' => '', 'selected' => 0, ); $result = wp_parse_args($args, $defaults); $output = ''; $choices = array( 'thumbnail' => esc_html__('Thumbnail', 'better-health'), 'medium' => esc_html__('Medium', 'better-health'), 'large' => esc_html__('Large', 'better-health'), 'full' => esc_html__('Full', 'better-health'), ); if (!empty($choices)) { $output = "\n"; } echo $output; } } } add_action('widgets_init', 'better_health_treatment_gallery_widget'); function better_health_treatment_gallery_widget() { register_widget('Better_Health_Treatment_Gallery_Widget'); }