defaults = array( 'title' => esc_attr__( 'Archives', 'essential-widgets' ), 'limit' => 10, 'type' => 'monthly', 'post_type' => 'post', 'order' => 'DESC', 'format' => 'html', 'before' => '', 'after' => '', 'show_post_count' => false, ); $widget_ops = array( 'classname' => 'essential-widgets widget_archive ew-archive ewarchive', 'description' => esc_html__( 'Displays a list of categories', 'essential-widgets' ), ); $control_ops = array( 'id_base' => 'ew-archive', ); parent::__construct( 'ew-archive', // Base ID __( 'EW: Archives', 'essential-widgets' ), // Name $widget_ops, $control_ops ); } function form($instance) { // Merge the user-selected arguments with the defaults. $instance = wp_parse_args( (array) $instance, $this->defaults ); // Get post types. $post_types = get_post_types( array( 'name' => 'post' ), 'objects' ); $post_types = array_merge( $post_types, get_post_types( array( 'publicly_queryable' => true, '_builtin' => false ), 'objects' ) ); // Create an array of archive types. $type = array( 'alpha' => esc_attr__( 'Alphabetical', 'essential-widgets' ), 'daily' => esc_attr__( 'Daily', 'essential-widgets' ), 'monthly' => esc_attr__( 'Monthly', 'essential-widgets' ), 'postbypost' => esc_attr__( 'Post By Post', 'essential-widgets' ), 'weekly' => esc_attr__( 'Weekly', 'essential-widgets' ), 'yearly' => esc_attr__( 'Yearly', 'essential-widgets' ) ); // Create an array of order options. $order = array( 'ASC' => esc_attr__( 'Ascending', 'essential-widgets' ), 'DESC' => esc_attr__( 'Descending', 'essential-widgets' ) ); // Create an array of archive formats. $format = array( 'custom' => esc_attr__( 'Plain', 'essential-widgets' ), 'html' => esc_attr__( 'List', 'essential-widgets' ), 'option' => esc_attr__( 'Dropdown', 'essential-widgets' ) ); ?>

defaults ); // Overwrite the $echo argument and set it to false. $instance['echo'] = false; // Output the sidebar's $before_widget wrapper. echo $args['before_widget']; // If a title was input by the user, display it. if ( ! empty( $instance['title'] ) ) echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $args['after_title']; // Get the archives list. $archives = str_replace( array( "\r", "\n", "\t" ), '', wp_get_archives( $instance ) ); $archives = str_replace(' (', ' (', $archives); $archives = str_replace(')', ')', $archives); // If the archives should be shown in a element and each