Verified Commit 81627db7 authored by Mike Little's avatar Mike Little
Browse files

get calendar options

add css for background image
enqueue css and javaacript
output html and call content part template.
parent dd3b8e84
Loading
Loading
Loading
Loading
+43 −17
Changes for templates/archive-advent_day.php: 43 added lines, 17 removed lines.
Original line number Diff line number Diff line
@@ -16,10 +16,7 @@
 * @since      Twenty Sixteen 1.0
 */

$options          = get_option( 'cac_settings_name' );
$page_title       = isset( $options['cac-calendar_title'] ) ? $options['cac-calendar_title'] : '';
$background_image = isset( $options['cac-calendar_title'] ) ? intval( $options['cac-calendar_title'] ) : 0;

/* Enqueue our stylesheet */
wp_enqueue_style(
	'advent-calendar',
	plugin_dir_url( __FILE__ ) . 'assets/css/advent-calendar.css',
@@ -27,6 +24,46 @@ wp_enqueue_style(
	filemtime( plugin_dir_path( __FILE__ ) . 'assets/css/advent-calendar.css' )
);

/* get our calendar options */
$options = get_option( 'cac_settings_name' );
$page_title       = isset( $options['cac-calendar_title'] ) ? $options['cac-calendar_title'] : '';
$image_id = isset( $options['cac-calendar_background_id'] ) ? intval( $options['cac-calendar_background_id'] ) : 0;
$background_image = wp_get_attachment_image_src( $image_id, 'full' );

/**
 *  Hook to wp_head on low priority to add background image.
 */
if ($background_image) {
	add_action(
		'wp_head', function () use ( $background_image ) {
		?>
		<style>
			.site {
				background-image: url(<?php echo esc_url($background_image[0]); ?>);
				background-size: auto;
				margin: 0;
				background-attachment: fixed;
			}
		</style>
		<?php
	}, 99 );
}


/* Enqueue our JavaScript */
wp_enqueue_script(
	'advent-calendar',
	plugin_dir_url( __FILE__ ) . 'assets/js/advent-calendar.js',
	['jquery'],
	filemtime( plugin_dir_path( __FILE__ ) . 'assets/js/advent-calendar.js' )
);

wp_localize_script( 'advent-calendar', 'advent_calendar_data',
	[
		'foo' => 'bar',
	]
);

get_header(); ?>

<div id="primary" class="content-area">
@@ -40,29 +77,18 @@ get_header(); ?>
		<div id="grid">

			<?php
				// Start the Loop.
			while ( have_posts() ) :
				the_post();

				/*
					 * Include the Post-Format-specific template for the content.
				 * Include the Post type-specific template for the content.
				 * If you want to override this in a child theme, then include a file
					 * called content-___.php (where ___ is the Post Format name) and that will be used instead.
				 * called content-advent_day.php and that will be used instead.
				 */
				Codeup_Advent_Calendar::get_instance()->template_loader()->get_template_part( 'content', CAC_ADVENT_DAY_TYPE );

					// End the loop.
			endwhile;

				// Previous/next page navigation.
				the_posts_pagination(
					array(
						'prev_text'          => __( 'Previous page', 'twentysixteen' ),
						'next_text'          => __( 'Next page', 'twentysixteen' ),
						'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentysixteen' ) . ' </span>',
					)
				);

			// If no content, include the "No posts found" template.
			else :
				get_template_part( 'template-parts/content', 'none' );