<?php global $ci, $ci_defaults, $load_defaults, $content_width; ?>
<?php if ( true === $load_defaults ) : ?>
<?php

	$ci_defaults['archive_no']    = 5;
	$ci_defaults['archive_week']  = 'enabled';
	$ci_defaults['archive_month'] = 'enabled';
	$ci_defaults['archive_year']  = 'enabled';

	add_filter( 'ci_theme_sanitize_panel_options', 'ci_theme_panel_sanitize_snippet_archive', 10, 2 );
	function ci_theme_panel_sanitize_snippet_archive( $values, $defaults ) {
		$values['archive_no']    = absint( $values['archive_no'] );
		$values['archive_week']  = 'enabled' === $values['archive_week'] ? 'enabled' : '';
		$values['archive_month'] = 'enabled' === $values['archive_month'] ? 'enabled' : '';
		$values['archive_year']  = 'enabled' === $values['archive_year'] ? 'enabled' : '';

		return $values;
	}
?>
<?php else : ?>

	<fieldset id="ci-panel-archive">
		<legend><?php esc_html_e( 'Archive', 'ci_theme' ); ?></legend>
		<fieldset class="set">
			<p class="guide"><?php esc_html_e( 'The number of the latest posts displayed in the archive page.', 'ci_theme' ); ?></p>
			<?php ci_panel_input( 'archive_no', __( 'Number of latest posts', 'ci_theme' ) ); ?>
		</fieldset>
		<fieldset>
			<p class="guide"><?php esc_html_e( 'Use the following options to display various types of archives.', 'ci_theme' ); ?></p>
			<?php ci_panel_checkbox( 'archive_week', 'enabled', __( 'Display weekly archive', 'ci_theme' ) ); ?>
			<?php ci_panel_checkbox( 'archive_month', 'enabled', __( 'Display monthly archive', 'ci_theme' ) ); ?>
			<?php ci_panel_checkbox( 'archive_year', 'enabled', __( 'Display yearly archive', 'ci_theme' ) ); ?>
		</fieldset>
	</fieldset>

<?php endif;
