css
4 years ago
images
12 years ago
img
13 years ago
js
4 years ago
archiveorg-book.php
4 years ago
archiveorg.php
4 years ago
archives.php
5 years ago
bandcamp.php
5 years ago
brightcove.php
5 years ago
cartodb.php
5 years ago
class.filter-embedded-html-objects.php
5 years ago
codepen.php
5 years ago
crowdsignal.php
5 years ago
dailymotion.php
4 years ago
descript.php
4 years ago
facebook.php
5 years ago
flatio.php
5 years ago
flickr.php
5 years ago
getty.php
5 years ago
gist.php
5 years ago
googleapps.php
5 years ago
googlemaps.php
5 years ago
googleplus.php
5 years ago
gravatar.php
5 years ago
houzz.php
5 years ago
inline-pdfs.php
4 years ago
instagram.php
4 years ago
kickstarter.php
5 years ago
mailchimp.php
5 years ago
medium.php
5 years ago
mixcloud.php
5 years ago
others.php
5 years ago
pinterest.php
5 years ago
presentations.php
5 years ago
quiz.php
4 years ago
recipe.php
5 years ago
scribd.php
5 years ago
sitemap.php
5 years ago
slideshare.php
5 years ago
slideshow.php
4 years ago
smartframe.php
4 years ago
soundcloud.php
4 years ago
spotify.php
4 years ago
ted.php
5 years ago
tweet.php
5 years ago
twitchtv.php
5 years ago
twitter-timeline.php
5 years ago
unavailable.php
4 years ago
untappd-menu.php
5 years ago
upcoming-events.php
5 years ago
ustream.php
5 years ago
videopress.php
5 years ago
vimeo.php
4 years ago
vine.php
5 years ago
vr.php
4 years ago
wordads.php
5 years ago
wufoo.php
4 years ago
youtube.php
4 years ago
upcoming-events.php
52 lines
| 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | |
| 3 | /** |
| 4 | * Display a list of upcoming events from a calendar. |
| 5 | * |
| 6 | * @package automattic/jetpack |
| 7 | */ |
| 8 | |
| 9 | /** |
| 10 | * Register a upcomingevents shortcode. |
| 11 | * Most of the heavy lifting done in iCalendarReader class, |
| 12 | * where the icalendar_render_events() function controls the display. |
| 13 | */ |
| 14 | class Upcoming_Events_Shortcode { |
| 15 | |
| 16 | /** |
| 17 | * Register things. |
| 18 | */ |
| 19 | public static function init() { |
| 20 | add_shortcode( 'upcomingevents', array( __CLASS__, 'shortcode' ) ); |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * Register the shortcode. |
| 25 | * |
| 26 | * @param array $atts Shortcode attributes. |
| 27 | */ |
| 28 | public static function shortcode( $atts = array() ) { |
| 29 | jetpack_require_lib( 'icalendar-reader' ); |
| 30 | $atts = shortcode_atts( |
| 31 | array( |
| 32 | 'url' => '', |
| 33 | 'number' => 0, |
| 34 | ), |
| 35 | $atts, |
| 36 | 'upcomingevents' |
| 37 | ); |
| 38 | $args = array( |
| 39 | 'context' => 'shortcode', |
| 40 | 'number' => absint( $atts['number'] ), |
| 41 | ); |
| 42 | $events = icalendar_render_events( $atts['url'], $args ); |
| 43 | |
| 44 | if ( ! $events ) { |
| 45 | $events = sprintf( '<p>%s</p>', __( 'No upcoming events', 'jetpack' ) ); |
| 46 | } |
| 47 | |
| 48 | return $events; |
| 49 | } |
| 50 | } |
| 51 | add_action( 'plugins_loaded', array( 'Upcoming_Events_Shortcode', 'init' ), 101 ); |
| 52 |