Skip to content

Instantly share code, notes, and snippets.

@nickdavis
Last active August 29, 2015 14:05
Show Gist options
  • Save nickdavis/45e1b51785f11589e44c to your computer and use it in GitHub Desktop.
Save nickdavis/45e1b51785f11589e44c to your computer and use it in GitHub Desktop.
<?php
/**
* This file customizes the Homepage output for the Aua Med School Theme.
*
* @author Halflife Studios
* @package Aua Med School
* @subpackage Customizations
*/
add_action('get_header', 'auamed_home_enqueue_scripts');
/**
* Load scripts/stylesheets for slider
*
*/
function auamed_home_enqueue_scripts() {
wp_enqueue_script( 'backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/backstretch.js', array('jquery'), '2.0.4', FALSE );
wp_enqueue_script( 'jquery-effects-core' );
//wp_enqueue_script( 'auamed-easings', get_bloginfo( 'stylesheet_directory' ) . '/js/jquery.easings.min.js', array('jquery'), '2.1.9', TRUE );
wp_enqueue_script( 'auamed-slimscroll', get_bloginfo( 'stylesheet_directory' ) . '/js/jquery.slimscroll.min.js', array('jquery'), '1.3.2', TRUE );
wp_enqueue_style( 'fullpage', get_bloginfo( 'stylesheet_directory' ) . '/css/fullpage.css', CHILD_THEME_NAME, '2.1.9', 'screen' );
//wp_enqueue_script( 'auamed-fullpage', get_bloginfo( 'stylesheet_directory' ) . '/js/fullpage.min.js', array('jquery'), '1.5.8', TRUE );
wp_enqueue_script( 'auamed-fullpage-3slides', get_bloginfo( 'stylesheet_directory' ) . '/js/fullpage3slides.min.js', array('jquery'), '2.1.9', TRUE );
}
add_action( 'genesis_meta', 'auamed_home_genesis_meta' );
/**
* Setup Homepage
*
*/
function auamed_home_genesis_meta() {
//* Force full-width-content layout setting
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
//* Add header CSS
add_action('wp_head', 'auamed_home_header_css');
//* Start and Add Script Options
add_action('genesis_after', 'auamed_home_script_options');
//* Add Slides Menu & Content
add_action('genesis_before_footer', 'auamed_home_slides_menu', 1);
add_action('genesis_before_footer', 'auamed_home_slides_content', 1);
}
//* Add inline (dynamic) CSS for the slider
function auamed_home_header_css() {
$post_type = 'post';
query_posts( array ('posts_per_page' => -1, 'post_type' => $post_type ) );
if ( have_posts()) {
$loop_counter = 0;
echo'<style type="text/css">' ;
while ( have_posts() ) : the_post();
global $post;
$color = get_post_meta($post->ID, 'themedy_color', true);
$color = !empty($color) ? $color : '#111'; #default
echo '#active-section'.$loop_counter.' #section'.$loop_counter.', #active-section'.$loop_counter.' .nav-primary, #active-section'.$loop_counter.' .navigation .toggle-menu.active, #active-section'.$loop_counter.' .navigation .toggle-menu:hover { background-color: '.$color.' !important; }';
$loop_counter++;
endwhile;
echo '</style>';
} wp_reset_query();
}
//* Add dynamic script options for the slider
function auamed_home_script_options() {
$post_type = 'post';
query_posts( array ('posts_per_page' => -1, 'post_type' => $post_type, ) );
// Build a list of permalinks to use in our Anchors array in the JavaScript below
if( have_rows('slides') ):
// Add opening bracket
$anchors = '[';
// loop through the rows of data
while ( have_rows('slides') ) : the_row();
$anchors .= '\'' .get_sub_field('permalink'). '\', ';
endwhile;
// Add the closing bracket
$anchors .= ']';
endif;
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
var isTablet = navigator.userAgent.match(/(iPhone|iPod|Android|BlackBerry|Windows Phone)/);
var anchorsList = <?php echo $anchors; ?>;
var autoScrollOpt = true;
// Full Page Scroll
$("#myContainer").fullpage({
anchors: anchorsList,
//animateAnchor: true,
fixedElements: '.before-header, .footer-widgets, .site-header, .slides-sidebar',
resize: false,
css3: false,
scrollingSpeed: 1100,
easing: 'easeInQuart',
loopTop: false,
loopBottom: false,
//navigation: autoScrollOpt,
//navigationPosition: 'left',
//navigationTooltips: ['First', 'Second'],
menu: '#slides-menu',
autoScrolling: autoScrollOpt,
// afterLoad: function(anchorLink, index){
// if(index == 2){
// $('.section-animation').addClass('active');
// }
// else {
// $('.section-animation').removeClass('active');
// }
// },
onLeave: function(index, nextIndex, direction){
var currentSection = jQuery('.section.active').attr("id");
jQuery('body').attr('id', 'active-'+currentSection); //change body ID
if ( (index == 1 && direction == 'down') || (index == 3 && direction == 'up') || (index == 3 && direction == 'down') || (index == 5 && direction == 'up') ) {
$('.section-animation').addClass('active');
}
else if( (index == 2 && direction == 'up') || (index == 2 && direction == 'down') || (index == 4 && direction == 'up') || (index == 4 && direction == 'down') ) {
$('.section-animation').removeClass('active');
}
//$('#brain').toggleClass('active', (index == 1 && direction == 'down' ) || (index == 3 && direction == 'up'));
//$('#brain').toggleClass('moveDown', index == 0 && direction == 'down');
}
});
// Initial body ID
var currentSection = jQuery('.section.active').attr("id");
jQuery('body').attr('id', 'active-'+currentSection); // TODO: Add 'active-last' class
// Full Page Image
<?php
// check if the flexible content field has rows of data
if( have_rows('slides') ):
$loop_counter = 0;
// loop through the rows of data
while ( have_rows('slides') ) : the_row();
$imgurl = get_sub_field('background_image');
$brainurl = '/wp-content/themes/auamed/images/Brains_Learning6.gif';
//$cloudsurl = '/wp-content/themes/auamed/images/background-school-clouds-5.gif';
$pinsurl = '/wp-content/themes/auamed/images/Map-GIF_Clinicals4-pins.png';
$schoolurl = '/wp-content/themes/auamed/images/background-school-24.png';
if ($loop_counter == 0) {
echo 'jQuery(document).ready(function($){jQuery("#section'.$loop_counter.'").backstretch("'. $imgurl.'");jQuery(".section-animation-school").backstretch("'. $schoolurl .'");});'; // Add backstretch twice in order to get correct brain size
}
else if ($loop_counter == 1) {
echo 'jQuery(document).ready(function($){jQuery("#section'.$loop_counter.'").backstretch("'. $imgurl.'");jQuery(".section-animation-brain").backstretch("'. $brainurl .'");});'; // Add backstretch twice in order to get correct brain size
}
else if ($loop_counter == 3) {
echo 'jQuery(document).ready(function($){jQuery("#section'.$loop_counter.'").backstretch("'. $imgurl.'");jQuery(".section-animation-pins").backstretch("'. $pinsurl .'");});'; // Add backstretch twice in order to line up our pins correctly
}
else if ( get_sub_field('background_image') ) {
echo 'jQuery(document).ready(function($){jQuery("#section'.$loop_counter.'").backstretch("'. $imgurl.'");});';
}
$loop_counter++;
endwhile;
endif;
?>
});
</script>
<?php
}
//* Markup for Slides menu
function auamed_home_slides_menu() {
// check if the flexible content field has rows of data
if( have_rows('slides') ):
echo '<div class="slides-sidebar">';
echo '<ul id="slides-menu">';
// loop through the rows of data
while ( have_rows('slides') ) : the_row();
echo '<li data-menuanchor="'. get_sub_field('permalink') . '">';
// If there's a tooltip set, set the tooltip class and show it
if (get_sub_field('tooltip')) {
echo '<a href="#'. get_sub_field('permalink') . '" class="tooltip">';
the_sub_field('title_menu');
echo '<span><img class="callout" src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/icon-callout.png" />' . get_sub_field('tooltip') . '</span>';
}
// ...else show a menu item without a tooltip class or markup
else {
echo '<a href="#'. get_sub_field('permalink') . '" class="tooltip">';
the_sub_field('title_menu');
}
echo '</a>';
echo '</li>';
endwhile;
echo '</ul>';
echo '<div class="slides-copy">';
echo '<p>' . get_field('slides_sidebar') . '</p>';
echo '</div>';
echo '</div>';
?>
<!-- <div id="staticImg">
<div class="imgsContainer">
<img src="/wp-content/themes/auamed/images/Brains_Learning5.gif" alt="iphone" id="iphone-green" />
</div>
</div> -->
<?php
endif;
}
//* Markup for Slides content
function auamed_home_slides_content() {
// check if the flexible content field has rows of data
if( have_rows('slides') ):
$loop_counter = 0;
echo '<div id="myContainer">';
// loop through the rows of data
while ( have_rows('slides') ) : the_row(); ?>
<article itemtype="http://schema.org/BlogPosting" itemscope="itemscope" class="section" id="section<?php echo $loop_counter; ?>">
<?php if ($loop_counter == 0) { ?>
<div class="section-animation-clouds active"></div>
<div class="section-animation-school active"></div>
<?php } ?>
<?php if ($loop_counter == 1) { ?>
<div class="section-animation section-animation-brain">
</div>
<?php } ?>
<?php // This is our div to hang the pins background on with backstretch
if ($loop_counter == 3) { ?>
<div class="section-animation section-animation-pins">
</div>
<?php } ?>
<?php if( get_row_layout() == 'regular' ): // Do stuff only for 'regular' layout ?>
<div class="wrap">
<header class="entry-header">
<h2 class="entry-title" itemprop="headline"><?php the_sub_field('title'); ?></h2>
<h3><?php the_sub_field('subtitle'); ?></h3>
</header>
<div itemprop="text" class="entry-content">
<?php wpautop(the_sub_field('text')); ?>
</div>
<?php if ( have_rows('buttons') ) : ?>
<footer class="entry-footer">
<?php while ( have_rows('buttons') ) : the_row(); ?>
<a class="readmore button" href="<?php the_sub_field('link'); ?>"><?php the_sub_field('text'); ?></a>
<?php endwhile; ?>
</footer>
<?php endif; ?>
</div>
<?php endif; // endif regular layout ?>
<?php if( get_row_layout() == 'seminars' ): // Do stuff only for 'seminars' layout ?>
<div class="slide">Slide 3.1</div>
<div class="slide">Slide 3.2</div>
<div class="slide">Slide 3.3</div>
<div class="slide">Slide 3.4</div>
<div class="slide">Slide 3.5</div>
<div class="slide">Slide 3.6</div>
<?php endif; // endif seminars layout ?>
</article>
<?php $loop_counter++; endwhile;
echo '</div>'; // close #myContainer
endif;
}
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment