Last active
May 24, 2016 14:40
-
-
Save elimn/a14a3042ce253a594416cfbe454c652d to your computer and use it in GitHub Desktop.
MT | TEC | Add shortcode to countdown to the next upcoming event
This file contains 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 | |
/* | |
* Shortcode that extends the existing countdown shortcode, but this ones shows | |
* the next upcoming events rather than a specific one. | |
* | |
* Example usage: | |
* | |
* [tribe_event_countdown_next show_seconds="1" complete="The party is on!"] | |
*/ | |
class Tribe_Custom_Countdown_Shortcode extends Tribe__Events__Pro__Shortcodes__Event_Countdown { | |
public $output = ''; | |
/** | |
* Default arguments expected by the countdown widget. | |
* | |
* @var array | |
*/ | |
protected $default_args = array( | |
// General widget properties | |
'before_widget' => '', | |
'before_title' => '', | |
'title' => '', | |
'after_title' => '', | |
'after_widget' => '', | |
// Widget specific properties | |
'type' => 'next-event', | |
'show_seconds' => '', | |
'complete' => '', | |
); | |
protected $arguments = array(); | |
public function __construct( $attributes ) { | |
$this->arguments = shortcode_atts( $this->default_args, $attributes ); | |
// If the ECP CSS has not already been added lets lazily add it now | |
Tribe__Events__Pro__Template_Factory::asset_package( 'events-pro-css' ); | |
ob_start(); | |
the_widget( 'Tribe__Events__Pro__Countdown_Widget', $this->arguments, $this->arguments ); | |
$this->output = ob_get_clean(); | |
} | |
} | |
function tribe_event_countdown_shortcode( $atts ) { | |
$wrapper = new Tribe_Custom_Countdown_Shortcode( $atts ); | |
return $wrapper->output; | |
} | |
add_shortcode( 'tribe_event_countdown_next', 'tribe_event_countdown_shortcode' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment