Created
September 23, 2016 02:56
-
-
Save thinhbg59/fb0fe7411e678733bda48d1a9c31ab32 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(!function_exists('noo_shortcode_countdown')){ | |
function noo_shortcode_countdown($attrs){ | |
extract(shortcode_atts(array( | |
'date' => '', | |
'title' => '', | |
'description' => '', | |
'button_name' => '', | |
'button_link' => '', | |
'background' => 'parallax', | |
'parallax_image' => '', | |
'overlay_parallax' => '', | |
'link_youtube' => '', | |
'back_youtube' => '', | |
'auto_mute' => 'true', | |
'slider_image' => '', | |
'slider_height' => '', | |
'height_custom' => '1', | |
'button_style' => 'scroll', //link or scroll or hide | |
'hide_days' => 'false', | |
'hide_hours' => 'false', | |
'hide_minutes' => 'false', | |
'hide_seconds' => 'false', | |
'text_days' => 'Days', | |
'text_hours' => 'Hours', | |
'text_minutes' => 'Minutes', | |
'text_seconds' => 'Seconds', | |
'mouse_scroll' => 'true', | |
),$attrs)); | |
ob_start(); | |
$hide_days = $hide_days == 'true' ? 'false' : 'true'; | |
$hide_hours = $hide_hours == 'true' ? 'false' : 'true'; | |
$hide_minutes = $hide_minutes == 'true' ? 'false' : 'true'; | |
$hide_seconds = $hide_seconds == 'true' ? 'false' : 'true'; | |
wp_enqueue_script('vendor-timecircle-js'); | |
if( $background =='youtube' ): | |
wp_enqueue_script('vendor-YTPlayer-js'); | |
endif; | |
if( isset($background) && $background=='parallax'): | |
wp_enqueue_script('noo-tweenLite'); | |
wp_enqueue_script('noo-EasePack'); | |
wp_enqueue_script('noo-rAF'); | |
wp_enqueue_script('noo-effect'); | |
endif; | |
$date_time = ''; | |
if( isset($date) && $date != '' ){ | |
$date_time = explode('/',$date); | |
} | |
$customheight = 'auto'; | |
if( $slider_height == 2 ){ | |
$customheight = $height_custom.'px'; | |
} | |
$class_parallax = ''; | |
if ( $background == 'parallax' ): | |
$class_parallax = "parallax "; | |
wp_enqueue_script('vendor-parallax'); | |
endif; | |
$image_id = ''; | |
?> | |
<div class="noo-countdown <?php echo esc_attr($class_parallax) ?>" style="height: <?php echo esc_attr($customheight); ?> <?php if( isset($background) && $background=='parallax'): ?>; background-image: url('<?php echo esc_url(wp_get_attachment_url($parallax_image)); ?>')<?php endif; ?>"> | |
<?php if( isset($slider_image) && !empty($slider_image) && $background =='slider'){ | |
$image_id = explode(',',$slider_image); | |
?> | |
<ul class="full-background"> | |
<?php foreach($image_id as $id): ?> | |
<li style="background-image: url('<?php echo wp_get_attachment_url(esc_attr($id)); ?>')"></li> | |
<?php endforeach; ?> | |
</ul> | |
<?php } ?> | |
<?php if( $background =='youtube' && $link_youtube != '' ): ?> | |
<a id="bgndVideo" class="player" data-property="{videoURL:'<?php echo esc_url($link_youtube); ?>',containment:'.noo-countdown',autoPlay:true, mute:<?php echo esc_attr($auto_mute); ?>, startAt:0, opacity:1}"></a> | |
<?php if( isset($back_youtube) && $back_youtube !='' ): ?><div class="background-mobi" style="display:none; background-image: url('<?php echo esc_url(wp_get_attachment_url($back_youtube)); ?>')"></div><?php endif; ?> | |
<?php endif; ?> | |
<div class="overlay_parallax" style="background-color: <?php echo esc_attr($overlay_parallax); ?>"></div> | |
<div class="noo-countdown-content"> | |
<div class="container"> | |
<?php | |
$old_date = $date; | |
$middle = strtotime($old_date); | |
$new_date = date_i18n( get_option( 'date_format' ), $middle ); | |
if($date != '') : | |
?> | |
<?php endif;?> | |
<?php if( isset($title) && $title !='' ): ?><h2><?php echo esc_html($title); ?></h2><?php endif; ?> | |
<?php if( isset($description) && $description != '' ): ?> | |
<center><img src="<?php echo $description; ?>" width="50%"></center> | |
<?php endif; ?> | |
<!-- Countdown dashboard start --> | |
<div class="wrap_countdown"> | |
<div id="DateCountdown" data-date="<?php if( isset($date_time) && $date_time[2] !=''){ echo esc_attr($date_time[2]); } ?>-<?php if( isset($date_time) && $date_time[0] !=''){ echo esc_attr($date_time[0]); } ?>-<?php if( isset($date_time) && $date_time[1] !=''){ echo esc_attr($date_time[1]); } ?> 00:00:00"></div> | |
</div> | |
<!-- Countdown dashboard end --> | |
<?php if( 'link' == $button_style ): ?> | |
<?php if( isset($button_name) && $button_name != '' ): ?> | |
<div style="width: 200px; display: inline-block; vertical-align: middle;"> | |
<a href="<?php echo esc_url($button_link); ?>"> | |
<img src="<?php echo $button_name; ?>" width="75%"> | |
</a> | |
</div> | |
<?php endif; ?> | |
<?php elseif( 'scroll' == $button_style ): ?> | |
<a href="#" class="scroll-mouse"> | |
<i class="fa fa-arrow-down"></i> | |
</a> | |
<?php endif; ?> | |
</div> | |
</div> | |
</div> | |
<script type="text/javascript"> | |
<?php if( $slider_height == 1 ){ ?> | |
if ( jQuery(window).height() > 767 ) { | |
var $height_w = jQuery(window).height() - jQuery('header').height(); | |
if ( jQuery('header').hasClass('header-2') || jQuery('header').hasClass('header-3') ) | |
$height_w = jQuery(window).height(); | |
jQuery('.noo-countdown').css('height',$height_w+'px'); | |
} else { | |
jQuery('.noo-countdown').css('height','700px'); | |
} | |
jQuery(window).resize(function(){ | |
if ( jQuery(window).height() > 767 ) { | |
var $height_w = jQuery(window).height() - jQuery('header').height(); | |
if ( jQuery('header').hasClass('header-2') || jQuery('header').hasClass('header-3') ) | |
$height_w = jQuery(window).height(); | |
jQuery('.noo-countdown').css('height',$height_w+'px'); | |
} else { | |
jQuery('.noo-countdown').css('height','700px'); | |
} | |
}); | |
<?php } ?> | |
jQuery(function () { | |
<?php if( $background !='parallax' ): ?> | |
jQuery('.full-background li:first-child').show(); | |
var myVar = ''; | |
clearInterval(myVar); | |
myVar = setInterval(function(){ | |
jQuery('.full-background li:first-child').fadeOut(1200).next('li').fadeIn(1200).end().appendTo('.full-background'); | |
},3500); | |
<?php endif; ?> | |
<?php if( $background =='youtube' ): ?> | |
var onMobile = false; | |
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) { onMobile = true; } | |
if( ( onMobile === false ) ) { | |
jQuery(".player").mb_YTPlayer(); | |
} else { | |
/* as a fallback we add a special class to the header which displays a poster image */ | |
jQuery('.noo-countdown').addClass('video-section'); | |
} | |
<?php endif; ?> | |
jQuery('.scroll-mouse').click(function(){ | |
var $height_w = jQuery(window).height(); | |
jQuery("html, body").animate({ scrollTop: $height_w }, 700); | |
return false; | |
}); | |
var primary_color = '<?php echo noo_get_option( 'noo_site_link_hover_color', '#f0a441' ); ?>'; | |
jQuery("#DateCountdown").TimeCircles({ | |
"animation": "smooth", | |
"bg_width": 1, | |
"fg_width": 0.01, | |
"circle_bg_color": "#fff", | |
"time": { | |
"Days": { | |
"text": "<?php echo esc_attr($text_days); ?>", | |
"color": primary_color, | |
"show": <?php echo esc_attr($hide_days); ?> | |
}, | |
"Hours": { | |
"text": "<?php echo esc_attr($text_hours); ?>", | |
"color": primary_color, | |
"show": <?php echo esc_attr($hide_hours); ?> | |
}, | |
"Minutes": { | |
"text": "<?php echo esc_attr($text_minutes); ?>", | |
"color": primary_color, | |
"show": <?php echo esc_attr($hide_minutes); ?> | |
}, | |
"Seconds": { | |
"text": "<?php echo esc_attr($text_seconds); ?>", | |
"color": primary_color, | |
"show": <?php echo esc_attr($hide_seconds); ?> | |
} | |
} | |
}); | |
}); | |
function getCookie(cname) { | |
var name = cname + "="; | |
var ca = document.cookie.split(';'); | |
for(var i=0; i<ca.length; i++) { | |
var c = ca[i]; | |
while (c.charAt(0)==' ') c = c.substring(1); | |
if (c.indexOf(name) == 0) return c.substring(name.length, c.length); | |
} | |
return ""; | |
} | |
</script> | |
<?php | |
$countdown = ob_get_contents(); | |
ob_end_clean(); | |
return $countdown; | |
} | |
add_shortcode('noo_countdown', 'noo_shortcode_countdown'); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment