Commit 81627db7 authored by Mike Little's avatar Mike Little

get calendar options

add css for background image
enqueue css and javaacript
output html and call content part template.
parent dd3b8e84
......@@ -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,41 +24,70 @@ 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">
<main id="main" class="site-main" role="main">
<?php if ( have_posts() ) : ?>
<?php if ( have_posts() ) : ?>
<header class="page-header">
<h1 class="page-title"><?php echo esc_html( $page_title ); ?></h1>
</header><!-- .page-header -->
<header class="page-header">
<h1 class="page-title"><?php echo esc_html( $page_title ); ?></h1>
</header><!-- .page-header -->
<div id="grid">
<?php
// Start the Loop.
while ( have_posts() ) :
the_post();
/*
* Include the Post-Format-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.
*/
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>',
)
);
<?php
while ( have_posts() ) :
the_post();
/*
* 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-advent_day.php and that will be used instead.
*/
Codeup_Advent_Calendar::get_instance()->template_loader()->get_template_part( 'content', CAC_ADVENT_DAY_TYPE );
endwhile;
// If no content, include the "No posts found" template.
else :
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment