'Display Articles List Widget', 'classname' => 'articles-list-widget' ) ); } // print to frontend function widget( $args, $instance ) { // Widget output extract($args); echo $before_widget; echo $before_title . $instance['title'] . $after_title; $tpl = PBR_THEME_DIR .'/templates/widgets/articles_list.php'; require( $tpl ); echo $after_widget; } function update( $new_instance, $old_instance ) { // Save widget options $instance['title'] = $new_instance['title']; $instance['number'] = $new_instance['number']; $instance['orderby'] = $new_instance['orderby']; $instance['orderway'] = $new_instance['orderway']; $instance['columns'] = $new_instance['columns']; $instance['style'] = $new_instance['style']; return $instance; } function form( $instance ) { //default $instance = wp_parse_args( $instance, array( 'title' => 'articles list widget', 'number' => '4', 'orderby' => 'date', 'orderway' => 'ASC', 'columns' => '4', 'style' => 'grid' ) ); $orderby = [ 'date' => __('Date', 'basee'), 'ID' => __('ID', 'basee'), 'author' => __('Author', 'basee'), 'title' => __('Title', 'basee'), 'modified' => __('Modified', 'basee'), 'rand' => __('Rand', 'basee'), 'comment_count' => __('Comment Count', 'basee'), ]; $orderway = [ 'ASC' => __('Ascending', 'basee'), 'DESC' => __('Descending', 'basee'), ]; $columns = [ '1' => __('1', 'basee'), '2' => __('2', 'basee'), '3' => __('3', 'basee'), '4' => __('4', 'basee'), '6' => __('6', 'basee'), ]; $styles = [ 'grid' => __('Grid', 'basee'), 'list' => __('List', 'basee'), ]; ?>