Update activity shortcode to handle multiple athletes

This commit is contained in:
Justin Foell
2017-09-29 10:52:57 -05:00
parent 5f162ec215
commit 080b59295d
2 changed files with 12 additions and 11 deletions
@@ -1,6 +1,6 @@
<?php <?php
class WPStrava_RideShortcode { class WPStrava_ActivityShortcode {
private static $add_script; private static $add_script;
public static function init() { public static function init() {
@@ -15,22 +15,23 @@ class WPStrava_RideShortcode {
self::$add_script = true; self::$add_script = true;
$defaults = array( $defaults = array(
'id' => 0, 'id' => 0,
'som' => WPStrava::get_instance()->settings->som, 'som' => WPStrava::get_instance()->settings->som,
'map_width' => '480', 'map_width' => '480',
'map_height' => '320', 'map_height' => '320',
'athlete_token' => WPStrava::get_instance()->settings->get_default_token(),
); );
extract( shortcode_atts( $defaults, $atts ) ); extract( shortcode_atts( $defaults, $atts ) );
$strava_som = WPStrava_SOM::get_som( $som ); $strava_som = WPStrava_SOM::get_som( $som );
$strava_ride = WPStrava::get_instance()->rides; $activity = WPStrava::get_instance()->rides;
$ride_details = $strava_ride->getRide( $id ); $ride_details = $activity->getRide( $athlete_token, $id );
//sanitize width & height //sanitize width & height
$map_width = str_replace( '%', '', $map_width ); $map_width = str_replace( '%', '', $map_width );
$map_height = str_replace( '%', '', $map_height ); $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 ); $map_height = str_replace( 'px', '', $map_height );
if ( $ride_details ) { if ( $ride_details ) {
@@ -82,4 +83,4 @@ class WPStrava_RideShortcode {
} }
// Initialize short code // Initialize short code
WPStrava_RideShortcode::init(); WPStrava_ActivityShortcode::init();
+1 -1
View File
@@ -4,7 +4,7 @@ require_once WPSTRAVA_PLUGIN_DIR . 'lib/Settings.class.php';
require_once WPSTRAVA_PLUGIN_DIR . 'lib/SOM.class.php'; require_once WPSTRAVA_PLUGIN_DIR . 'lib/SOM.class.php';
require_once WPSTRAVA_PLUGIN_DIR . 'lib/LatestRidesWidget.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/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'; require_once WPSTRAVA_PLUGIN_DIR . 'lib/StaticMap.class.php';
class WPStrava { class WPStrava {