'newsmag_builder', 'description' => __( 'Posts are displayed next to each other in a grid-like fashion.', 'newsmag' ), 'customize_selective_refresh' => true ) ); } public function enqueue() { wp_enqueue_script( 'jquery-ui' ); wp_enqueue_script( 'jquery-ui-slider' ); } public function form( $instance ) { $defaults = array( 'title' => __( 'Recent posts', 'newsmag' ), 'show_post' => 4, 'newsmag_category' => 'uncategorized', 'order' => 'desc' ); $instance = wp_parse_args( (array) $instance, $defaults ); ?>

$args['show_post'] ); $atts['order'] = $args['order']; $atts['orderby'] = 'date'; if('rand' == $atts['order']){ $atts['order'] = ''; $atts['orderby'] = 'rand'; } if ( $idObj ) { $id = $idObj->term_id; $atts['cat'] = $id; } $posts = new WP_Query( $atts ); wp_reset_postdata(); return $posts; } public function widget( $args, $instance ) { $defaults = array( 'title' => __( 'Recent posts', 'newsmag' ), 'show_post' => 4, 'newsmag_category' => '', 'order' => 'desc' ); $instance = wp_parse_args( (array) $instance, $defaults ); echo $args['before_widget']; $filepath = get_template_directory() . '/inc/libraries/widgets/widget-newsmag-posts-grid/layouts/posts_grid.php'; $posts = $this->get_posts( $instance ); if ( file_exists( $filepath ) ) { include $filepath; } else { esc_html_e( 'Please configure your widget', 'newsmag' ); } echo $args['after_widget']; } }