Upcoming_Events_Shortcode

Most of the heavy lifting done in iCalendarReader class.

Defined (1)

The class is defined in the following location(s).

/modules/shortcodes/upcoming-events.php  
  1. class Upcoming_Events_Shortcode { 
  2.  
  3. public static function init() { 
  4. add_shortcode( 'upcomingevents', array( __CLASS__, 'shortcode' ) ); 
  5.  
  6. public static function shortcode( $atts = array() ) { 
  7. jetpack_require_lib( 'icalendar-reader' ); 
  8. $atts = shortcode_atts( array( 'url' => '', 'number' => 0 ), $atts, 'upcomingevents' ); 
  9. $args = array( 
  10. 'context' => 'shortcode',  
  11. 'number' => absint( $atts['number'] ),  
  12. ); 
  13. $events = icalendar_render_events( $atts['url'], $args ); 
  14.  
  15. if ( ! $events ) { 
  16. $events = sprintf( '<p>%s</p>', __( 'No upcoming events', 'jetpack' ) ); 
  17.  
  18. return $events;