Beee

widget coming events

Jun 29th, 2016
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.57 KB | None | 0 0
  1. <?php
  2.     class ComingEvents extends WP_Widget {
  3.  
  4.         function ComingEvents() {
  5.             // Instantiate the parent object
  6.             parent::__construct(
  7.                 'coming_events', // Base ID
  8.                 'IDF: Coming Events', // Name
  9.                 array( 'description' => 'Custom widget for coming events' ) // Args
  10.             );
  11.         }
  12.  
  13.         function widget( $args, $instance ) {
  14.             if ( class_exists('EM_Events') ) { // if events plugin is enabled
  15.  
  16.                 // Widget output
  17.                 extract( $args );
  18.                 $tc_widgettitle     = "Next race";
  19.                 $coming_events      = do_shortcode('<ul>[events_list scope="future" limit="1" orderby="event_start_date,event_name"]<li>#_EVENTEDIT #_EVENTLINK ({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} {has_location}in #_LOCATIONCOUNTRY #_COUNTRYFLAG{/has_location}</li>[/events_list]</ul>');
  20.  
  21.                 if ( strlen($coming_events) > 25 ) {
  22.  
  23.                     echo $before_widget;
  24.                     if ( $tc_widgettitle ) echo $before_title . $tc_widgettitle . $after_title;
  25.  
  26.                     // widget content
  27.                     echo $coming_events;
  28.  
  29.                     echo '<div><a href="'.home_url().'/races/">All races &raquo;</a></div>';
  30.  
  31.                     echo $after_widget;
  32.                 }
  33.             }
  34.         }
  35.  
  36.     }
Add Comment
Please, Sign In to add comment