'newsbox', 'description' => __( 'A Sidebar widget to display latest post entries in your sidebar', 'avia_framework' ), 'show_instance_in_rest' => true, 'customize_selective_refresh' => false ); } parent::__construct( $id_base, $name, $widget_options, $control_options ); $this->defaults = array( 'title' => '', 'count' => '', 'excerpt' => '', 'cat' => '' ); $this->avia_term = ''; $this->avia_post_type = ''; $this->avia_new_query = ''; } /** * Output the widget in frontend * * @since 4.9 * @param array $args * @param array $instance */ public function widget( $args, $instance ) { global $avia_config; $instance = $this->parse_args_instance( $instance ); extract( $args, EXTR_SKIP ); echo $before_widget; $title = empty( $instance['title'] ) ? '' : apply_filters( 'widget_title', $instance['title'] ); $count = empty( $instance['count'] ) ? '' : $instance['count']; $cat = empty( $instance['cat'] ) ? '' : $instance['cat']; $excerpt = empty( $instance['excerpt'] ) ? '' : $instance['excerpt']; $image_size = isset( $avia_config['widget_image_size'] ) ? $avia_config['widget_image_size'] : 'widget'; /** * @since 4.5.4 * @param string $image_size * @param array $args * @param array $instance * @return string */ $image_size = apply_filters( 'avf_newsbox_image_size', $image_size, $args, $instance ); if( ! empty( $title ) ) { echo $before_title . $title . $after_title; } if( empty( $this->avia_term ) ) { $additional_loop = new WP_Query( "cat={$cat}&posts_per_page={$count}" ); } else { $catarray = explode( ',', $cat ); if( empty( $catarray[0] ) ) { $new_query = array( 'posts_per_page' => $count, 'post_type' => $this->avia_post_type ); } else { if( $this->avia_new_query ) { $new_query = $this->avia_new_query; } else { $new_query = array( 'posts_per_page' => $count, 'tax_query' => array( array( 'taxonomy' => $this->avia_term, 'field' => 'id', 'terms' => explode( ',', $cat ), 'operator' => 'IN' ) ) ); } } $additional_loop = new WP_Query( $new_query ); } if( $additional_loop->have_posts() ) { echo ''; wp_reset_postdata(); } echo $after_widget; } /** * Update widget options * * @param array $new_instance * @param array $old_instance * @return array */ public function update( $new_instance, $old_instance ) { $instance = $this->parse_args_instance( $old_instance ); $instance['title'] = strip_tags( $new_instance['title'] ); $instance['count'] = strip_tags( $new_instance['count'] ); $instance['excerpt'] = strip_tags( $new_instance['excerpt'] ); if( ! empty( $new_instance['cat'] ) ) { $instance['cat'] = is_array( $new_instance['cat'] ) ? implode( ',', $new_instance['cat'] ) : strip_tags( $new_instance['cat'] ); } return $instance; } /** * Output the form in backend * * @param array $instance */ public function form( $instance ) { $instance = $this->parse_args_instance( $instance ); $title = strip_tags( $instance['title'] ); $count = strip_tags( $instance['count'] ); $excerpt = strip_tags( $instance['excerpt'] ); $elementCat = array( 'name' => __( 'Which categories should be used for the portfolio?', 'avia_framework' ), 'desc' => __( 'You can select multiple categories here', 'avia_framework' ), 'id' => $this->get_field_name( 'cat' ) . '[]', 'type' => 'select', 'std' => strip_tags( $instance['cat'] ), 'class' => '', 'multiple' => 6, 'subtype' => 'cat' ); //check if a different taxonomy than the default is set if( ! empty( $this->avia_term ) ) { $elementCat['taxonomy'] = $this->avia_term; } $html = new \avia_htmlhelper(); ?>

'; echo $list; ?>

'; echo $list; ?>