-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcountdown.php
56 lines (44 loc) · 1.43 KB
/
countdown.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/*
Plugin Name: Countdown Shortcode
Plugin URI: https://github.com/wp-pure/countdown
Description: A simple plugin that creates a javascript countdown clock from a shortcode.
Version: 0.0.1
Author: James Pederson
Author URI: https://jpederson.com
License: GPL2
*/
// the shortcode itself
function countdown_shortcode( $atts ) {
// set shortcode defaults
$a = shortcode_atts( array(
'date' => date( 'UTC', time()+864000 ),
), $atts );
$clock_html = '<div class="countdown-clock" data-date="' . $a['date'] . '">
<div class="countdown-column">
<span class="number days"></span>
<div class="label">Days</div>
</div>
<div class="countdown-column">
<span class="number hours"></span>
<div class="label">Hours</div>
</div>
<div class="countdown-column">
<span class="number minutes"></span>
<div class="label">Minutes</div>
</div>
<div class="countdown-column">
<span class="number seconds"></span>
<div class="label">Seconds</div>
</div>
</div>
<link href="/wp-content/countdown" />';
return $clock_html;
}
add_shortcode( 'countdown', 'countdown_shortcode' );
// include the js and css
function countdown_assets() {
wp_enqueue_style( 'countdown-css', plugin_dir_url( __FILE__ ) . 'countdown.css?v=1' );
wp_enqueue_script( 'countdown-js', plugin_dir_url( __FILE__ ) . 'countdown.js?v=1', array( 'jquery' ), false, true );
}
add_action( 'wp_enqueue_scripts', 'countdown_assets' );