'widget_archive',
'description' => __( 'A monthly archive of your site’s Posts.', 'benjamin' ),
'customize_selective_refresh' => true,
);
parent::__construct('archives', __('Archives', 'benjamin'), $widget_ops);
}
private function menuStyleArgs($style = 'side_nav'){
if($style == 'side_nav'):
$class = 'usa-sidenav-list';
elseif($style == 'nav_list'):
$class = 'usa-unstyled-list';
else:
$class = '';
endif;
return $class;
}
public function dropdown($c, $title)
{
$dropdown_id = "{$this->id_base}-dropdown-{$this->number}";
?>
>
'monthly',
'show_post_count' => $c,
) ) );
?>
menuStyleArgs($style);
/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Archives', 'benjamin' ) : $instance['title'], $instance, $this->id_base );
echo $args['before_widget']; // WPCS: xss ok.
if ( $title ) {
echo $args['before_title'] . $title . $args['after_title']; // WPCS: xss ok.
}
if ( $style == 'dropdown' ) {
$this->dropdown($c, $title);
} else {
$this->menu($c, $style_args);
}
echo $args['after_widget']; // WPCS: xss ok.
}
/**
* Handles updating settings for the current Archives widget instance.
*
* @since 2.8.0
* @access public
*
* @param array $new_instance New settings for this instance as input by the user via
* WP_Widget_Archives::form().
* @param array $old_instance Old settings for this instance.
* @return array Updated settings to save.
*/
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') );
$instance['title'] = sanitize_text_field( $new_instance['title'] );
$instance['count'] = $new_instance['count'] ? 1 : 0;
if ( ! empty( $new_instance['menu_style'] ) ) {
$instance['menu_style'] = sanitize_text_field($new_instance['menu_style']);
}
return $instance;
}
/**
* Outputs the settings form for the Archives widget.
*
* @since 2.8.0
* @access public
*
* @param array $instance Current settings.
*/
public function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') );
$title = sanitize_text_field( $instance['title'] );
$saved_style = isset( $instance['menu_style'] ) ? $instance['menu_style'] : '';
?>
id="get_field_id('count')); ?>"
name="get_field_name('count')); ?>" />