/** @see WP_Widget::widget */ public function widget($args, $instance) { extract($args); //$widget_id = $args['widget_id']; $title = apply_filters('widget_title', empty($instance['title']) ? __('Rides', 'wp-strava') : $instance['title']); $strava_club_id = empty($instance['strava_club_id']) ? '' : $instance['strava_club_id']; $quantity = empty($instance['quantity']) ? '5' : $instance['quantity']; $this->som = WPStrava_SOM::get_som(); ?> <?php echo $before_widget; ?> <?php if ($title) { echo $before_title . $title . $after_title; } ?> <?php echo $this->strava_request_handler($strava_club_id, $strava_som_option, $quantity); ?> <?php echo $after_widget; ?> <?php }
public function getRidesLongerThan($rides, $dist) { $som = WPStrava_SOM::get_som(); $meters = $som->distance_inverse($dist); $long_rides = array(); foreach ($rides as $ride_info) { if ($ride_info->distance > $meters) { $long_rides[] = $ride_info; } } return $long_rides; }
function handler($atts) { self::$add_script = true; $defaults = array('id' => 0, 'som' => WPStrava::get_instance()->settings->som, 'map_width' => '480', 'map_height' => '320'); extract(shortcode_atts($defaults, $atts)); $strava_som = WPStrava_SOM::get_som($som); $strava_ride = WPStrava::get_instance()->rides; $rideDetails = $strava_ride->getRide($id); //sanitize width & height $map_width = str_replace('%', '', $map_width); $map_height = str_replace('%', '', $map_height); $map_width = str_replace('px', '', $map_width); $map_height = str_replace('px', '', $map_height); if ($rideDetails) { return ' <div id="ride-header-' . $id . '" class="wp-strava-ride-container"> <table id="ride-details-table"> <thead> <tr> <th>' . __('Elapsed Time', 'wp-strava') . '</th> <th>' . __('Moving Time', 'wp-strava') . '</th> <th>' . __('Distance', 'wp-strava') . '</th> <th>' . __('Average Speed', 'wp-strava') . '</th> <th>' . __('Max Speed', 'wp-strava') . '</th> <th>' . __('Elevation Gain', 'wp-strava') . '</th> </tr> </thead> <tbody> <tr class="ride-details-table-info"> <td>' . $strava_som->time($rideDetails->elapsed_time) . '</td> <td>' . $strava_som->time($rideDetails->moving_time) . '</td> <td>' . $strava_som->distance($rideDetails->distance) . '</td> <td>' . $strava_som->speed($rideDetails->average_speed) . '</td> <td>' . $strava_som->speed($rideDetails->max_speed) . '</td> <td>' . $strava_som->elevation($rideDetails->total_elevation_gain) . '</td> </tr> <tr class="ride-details-table-units"> <td>' . $strava_som->get_time_label() . '</td> <td>' . $strava_som->get_time_label() . '</td> <td>' . $strava_som->get_distance_label() . '</td> <td>' . $strava_som->get_speed_label() . '</td> <td>' . $strava_som->get_speed_label() . '</td> <td>' . $strava_som->get_elevation_label() . '</td> </tr> </tbody> </table>' . WPStrava_StaticMap::get_image_tag($rideDetails, $map_height, $map_width) . '</div>'; } }
public function __construct() { $this->som = WPStrava_SOM::get_som(); parent::__construct(false, 'Strava Latest Map', array('description' => __('Strava latest ride using static google map image', 'wp-strava'))); }