Advertisement
Beee

Event today widget

Jun 18th, 2017
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.85 KB | None | 0 0
  1. <?php
  2.     class EventToday extends WP_Widget {
  3.  
  4.         public function __construct() {
  5.             // Instantiate the parent object
  6.             parent::__construct(
  7.                 'event_now',                    // Base ID
  8.                 'IDF: Taking Place Today',      // Name
  9.                 array( 'description' => 'Events taking place today' ) // Args
  10.             );
  11.         }
  12.  
  13.         public function widget( $args, $instance ) {
  14.             if ( class_exists( 'EM_Events' ) ) { // if events plugin is enabled
  15.  
  16.                 extract( $args );
  17.                 $tpn_widgettitle    = "Taking place now";
  18.                 $event_now          = do_shortcode( '<ul>[events_list scope="today" limit="1"]{is_current}<li>#_EVENTEDIT <a href="#_EVENTURL">#_RACENAMENOYEAR</a> ({has_category_world-cup}<a href="' . home_url() . '/races/type/world-cup/">WC</a>{/has_category_world-cup}{has_category_world-qualifying-series}<a href="' . home_url() . '/races/type/world-qualifying-series/">WQS</a>{/has_category_world-qualifying-series}) on #_{F j} in #_LOCATIONCOUNTRY #_COUNTRYFLAG</li>{/is_current}[/events_list]</ul>' );
  19.  
  20.                 $event_today_args         = array(
  21.                     'scope'   => 'today',
  22.                     'orderby' => 'event_start_date,event_name',
  23.                 );
  24.                 // $event_now = EM_Events::get( $event_today_args );
  25.  
  26.                 // Widget output
  27.                 if ( strlen( $event_now ) > 25 ) {
  28.  
  29.                     echo $before_widget;
  30.                     if ( $tpn_widgettitle ) echo $before_title . $tpn_widgettitle . $after_title;
  31.  
  32.                     // widget content
  33.                     echo $event_now;
  34.  
  35.                     echo '<div><a href="' . home_url() . '/races/">All races &raquo;</a></div>';
  36.  
  37.                     echo $after_widget;
  38.  
  39.                 }
  40.             }
  41.         }
  42.  
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement