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'];
?>
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' ); }