Skip to content

Commit

Permalink
Update activity shortcode to handle multiple athletes
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfoell committed Sep 29, 2017
1 parent 5f162ec commit 080b592
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions lib/RideShortcode.class.php → lib/ActivityShortcode.class.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

class WPStrava_RideShortcode {
class WPStrava_ActivityShortcode {
private static $add_script;

public static function init() {
Expand All @@ -15,22 +15,23 @@ public static function handler( $atts ) {
self::$add_script = true;

$defaults = array(
'id' => 0,
'som' => WPStrava::get_instance()->settings->som,
'map_width' => '480',
'map_height' => '320',
'id' => 0,
'som' => WPStrava::get_instance()->settings->som,
'map_width' => '480',
'map_height' => '320',
'athlete_token' => WPStrava::get_instance()->settings->get_default_token(),
);

extract( shortcode_atts( $defaults, $atts ) );

$strava_som = WPStrava_SOM::get_som( $som );
$strava_ride = WPStrava::get_instance()->rides;
$ride_details = $strava_ride->getRide( $id );
$activity = WPStrava::get_instance()->rides;
$ride_details = $activity->getRide( $athlete_token, $id );

//sanitize width & height
$map_width = str_replace( '%', '', $map_width );
$map_width = str_replace( '%', '', $map_width );
$map_height = str_replace( '%', '', $map_height );
$map_width = str_replace( 'px', '', $map_width );
$map_width = str_replace( 'px', '', $map_width );
$map_height = str_replace( 'px', '', $map_height );

if ( $ride_details ) {
Expand Down Expand Up @@ -82,4 +83,4 @@ public static function print_scripts() {
}

// Initialize short code
WPStrava_RideShortcode::init();
WPStrava_ActivityShortcode::init();
2 changes: 1 addition & 1 deletion lib/Strava.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require_once WPSTRAVA_PLUGIN_DIR . 'lib/SOM.class.php';
require_once WPSTRAVA_PLUGIN_DIR . 'lib/LatestRidesWidget.class.php';
require_once WPSTRAVA_PLUGIN_DIR . 'lib/LatestMapWidget.class.php';
require_once WPSTRAVA_PLUGIN_DIR . 'lib/RideShortcode.class.php';
require_once WPSTRAVA_PLUGIN_DIR . 'lib/ActivityShortcode.class.php';
require_once WPSTRAVA_PLUGIN_DIR . 'lib/StaticMap.class.php';

class WPStrava {
Expand Down

0 comments on commit 080b592

Please sign in to comment.