mirror of
https://github.com/10h30/wp-strava.git
synced 2026-07-11 18:56:18 +09:00
Version 0.62 release:
- Tested with wordpress 3.3.2 - Changed default icon for side widget. - Fixed issue with club id search. - Fixed and enabled shortcode [ride]. - Changed login and ride_details calls to use Strava V2 API.
This commit is contained in:
Regular → Executable
+2
-1
@@ -4,7 +4,8 @@
|
|||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
float: left;
|
float: left;
|
||||||
background: url('../images/fugue-sprite.png') -48px -96px no-repeat;
|
background: url('../images/fugue-sprite.png') no-repeat;
|
||||||
|
background-position: -224px -160px;
|
||||||
margin: 0 6px 2px 0;
|
margin: 0 6px 2px 0;
|
||||||
}
|
}
|
||||||
.table {
|
.table {
|
||||||
|
|||||||
Executable → Regular
|
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 122 KiB |
@@ -0,0 +1,39 @@
|
|||||||
|
|
||||||
|
jQuery(document).ready(function($){
|
||||||
|
$('.map').each(function(){
|
||||||
|
var mapId = $(this).attr('id');
|
||||||
|
|
||||||
|
var rideCoordinates = window.coordinates[mapId].latlng;
|
||||||
|
var mapCenter = new google.maps.LatLng(23.091860, -102.839356);
|
||||||
|
var mapOptions = {
|
||||||
|
zoom: 5,
|
||||||
|
center: mapCenter,
|
||||||
|
//mapTypeControl: true,
|
||||||
|
//mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
|
||||||
|
zoomControl: true,
|
||||||
|
zoomControlOptions: {style: google.maps.MapTypeControlStyle.SMALL},
|
||||||
|
mapTypeId: google.maps.MapTypeId.TERRAIN
|
||||||
|
};
|
||||||
|
var mapObject = new google.maps.Map($('#' + mapId)[0], mapOptions);
|
||||||
|
var mapBounds = new google.maps.LatLngBounds();
|
||||||
|
var mapCoordinates = new google.maps.MVCArray();
|
||||||
|
var size = rideCoordinates.length;
|
||||||
|
for(i = 0; i < size; i++) {
|
||||||
|
point = new google.maps.LatLng(parseFloat(rideCoordinates[i][0]), parseFloat(rideCoordinates[i][1]));
|
||||||
|
mapBounds.extend(point);
|
||||||
|
mapCoordinates.push(point);
|
||||||
|
}
|
||||||
|
|
||||||
|
var polylineOptions = {
|
||||||
|
path: mapCoordinates,
|
||||||
|
strokeColor: '#e0642e',
|
||||||
|
strokeOpacity: 0.8,
|
||||||
|
strokeWeight: 3
|
||||||
|
};
|
||||||
|
|
||||||
|
var polyline = new google.maps.Polyline(polylineOptions);
|
||||||
|
polyline.setMap(mapObject);
|
||||||
|
mapObject.fitBounds(mapBounds);
|
||||||
|
//google.maps.event.trigger(mapObject, 'resize');
|
||||||
|
});
|
||||||
|
});
|
||||||
+21
-17
@@ -5,10 +5,12 @@ namespace WP\Strava;
|
|||||||
*/
|
*/
|
||||||
class Rides {
|
class Rides {
|
||||||
private $rideUrl = "http://www.strava.com/api/v1/rides/:id";
|
private $rideUrl = "http://www.strava.com/api/v1/rides/:id";
|
||||||
|
private $rideUrlV2 = "http://www.strava.com/api/v2/rides/:id";
|
||||||
private $ridesUrl = "http://www.strava.com/api/v1/rides";
|
private $ridesUrl = "http://www.strava.com/api/v1/rides";
|
||||||
private $authenticationUrl = "https://www.strava.com/api/v1/authentication/login";
|
private $authenticationUrl = "https://www.strava.com/api/v1/authentication/login";
|
||||||
|
private $authenticationUrlV2 = "https://www.strava.com/api/v2/authentication/login";
|
||||||
private $rideMapDetailsUrl = "http://www.strava.com/api/v1/rides/:id/map_details";
|
private $rideMapDetailsUrl = "http://www.strava.com/api/v1/rides/:id/map_details";
|
||||||
private $rideMapDetailsUrlv2 = "http://www.strava.com/api/v2/rides/:id/map_details";
|
private $rideMapDetailsUrlV2 = "http://www.strava.com/api/v2/rides/:id/map_details";
|
||||||
|
|
||||||
public $ridesLinkUrl = "http://app.strava.com/rides/";
|
public $ridesLinkUrl = "http://app.strava.com/rides/";
|
||||||
public $stravaRides;
|
public $stravaRides;
|
||||||
@@ -19,35 +21,37 @@ class Rides {
|
|||||||
} // __construct
|
} // __construct
|
||||||
|
|
||||||
public function getRideDetails($rideId, $systemOfMeasurement) {
|
public function getRideDetails($rideId, $systemOfMeasurement) {
|
||||||
$url = preg_replace('/:id/', $rideId, $this->rideUrl);
|
$url = preg_replace('/:id/', $rideId, $this->rideUrlV2);
|
||||||
//$url = $this->ridesUrl . $rideId;
|
|
||||||
$json = file_get_contents($url);
|
$json = file_get_contents($url);
|
||||||
|
|
||||||
if($json) {
|
if($json) {
|
||||||
$strava_ride = json_decode($json);
|
$strava_ride = json_decode($json);
|
||||||
|
|
||||||
//Transform data to a ready to be displayed format
|
//Transform data to a ready to be displayed format
|
||||||
$startDate = date("F j, Y - H:i a", strtotime($strava_ride->ride->startDateLocal));
|
$startDate = date("F j, Y - H:i a", strtotime($strava_ride->ride->start_date_local));
|
||||||
$elapsedTime = date("H:i:s", mktime(0, 0, $strava_ride->ride->elapsedTime));
|
$elapsedTime = date("H:i:s", mktime(0, 0, $strava_ride->ride->elapsed_time));
|
||||||
$movingTime = date("H:i:s", mktime(0, 0, $strava_ride->ride->movingTime));
|
$movingTime = date("H:i:s", mktime(0, 0, $strava_ride->ride->moving_time));
|
||||||
|
|
||||||
if ($systemOfMeasurement == "metric") {
|
if ($systemOfMeasurement == "metric") {
|
||||||
//To km
|
//To km
|
||||||
$distance = number_format($strava_ride->ride->distance/1000, 2);
|
$distance = number_format($strava_ride->ride->distance/1000, 2);
|
||||||
//To km/h
|
//To km/h
|
||||||
$averageSpeed = number_format($strava_ride->ride->averageSpeed * 3.6, 2);
|
$averageSpeed = number_format($strava_ride->ride->average_speed * 3.6, 2);
|
||||||
//To km/h
|
//To km/h
|
||||||
$maximumSpeed = number_format($strava_ride->ride->maximumSpeed/1000, 2);
|
// Removed on version 2 of the Strava API
|
||||||
|
//$maximumSpeed = number_format($strava_ride->ride->maximumSpeed/1000, 2);
|
||||||
//It is already in meters
|
//It is already in meters
|
||||||
$elevationGain = number_format($strava_ride->ride->elevationGain, 2);
|
$elevationGain = number_format($strava_ride->ride->elevation_gain, 2);
|
||||||
} elseif ($systemOfMeasurement == "english") {
|
} elseif ($systemOfMeasurement == "english") {
|
||||||
//To miles
|
//To miles
|
||||||
$distance = number_format($strava_ride->ride->distance/1609.34, 2);
|
$distance = number_format($strava_ride->ride->distance/1609.34, 2);
|
||||||
//To miles/h
|
//To miles/h
|
||||||
$averageSpeed = number_format($strava_ride->ride->averageSpeed * 2.2369, 2);
|
$averageSpeed = number_format($strava_ride->ride->average_speed * 2.2369, 2);
|
||||||
//To miles/h
|
//To miles/h
|
||||||
$maximumSpeed = number_format($strava_ride->ride->maximumSpeed/1609.34, 2);
|
// Removed on version 2 of the Strava API
|
||||||
|
//$maximumSpeed = number_format($strava_ride->ride->maximumSpeed/1609.34, 2);
|
||||||
//To foot
|
//To foot
|
||||||
$elevationGain = number_format($strava_ride->ride->elevationGain/0.3048, 2);
|
$elevationGain = number_format($strava_ride->ride->elevation_gain/0.3048, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ride_details = array(
|
$ride_details = array(
|
||||||
@@ -59,7 +63,7 @@ class Rides {
|
|||||||
'movingTime' => $movingTime,
|
'movingTime' => $movingTime,
|
||||||
'distance' => $distance,
|
'distance' => $distance,
|
||||||
'averageSpeed' => $averageSpeed,
|
'averageSpeed' => $averageSpeed,
|
||||||
'maximumSpeed' => $maximumSpeed,
|
//'maximumSpeed' => $maximumSpeed,
|
||||||
'elevationGain' => $elevationGain
|
'elevationGain' => $elevationGain
|
||||||
);
|
);
|
||||||
return $ride_details;
|
return $ride_details;
|
||||||
@@ -91,7 +95,7 @@ class Rides {
|
|||||||
} else {
|
} else {
|
||||||
$json = file_get_contents($url . '?athleteName=' . urlencode($searchId));
|
$json = file_get_contents($url . '?athleteName=' . urlencode($searchId));
|
||||||
}
|
}
|
||||||
} elseif ($this->searchOption == "club" AND is_numeric($searchId)) {
|
} elseif ($searchOption == "club" AND is_numeric($searchId)) {
|
||||||
$json = file_get_contents($url . '?clubId=' . urlencode($searchId));
|
$json = file_get_contents($url . '?clubId=' . urlencode($searchId));
|
||||||
} else {
|
} else {
|
||||||
$this->feedback .= _e("There's an error on the widget options combination.", "wp-strava");
|
$this->feedback .= _e("There's an error on the widget options combination.", "wp-strava");
|
||||||
@@ -108,11 +112,11 @@ class Rides {
|
|||||||
public function getAuthenticationToken($email, $password) {
|
public function getAuthenticationToken($email, $password) {
|
||||||
$util = new Util;
|
$util = new Util;
|
||||||
$data = array('email' => $email, 'password' => $password);
|
$data = array('email' => $email, 'password' => $password);
|
||||||
$json = $util->makePostRequest($this->authenticationUrl, $data);
|
$json = $util->makePostRequest($this->authenticationUrlV2, $data);
|
||||||
|
|
||||||
if($json) {
|
if($json) {
|
||||||
$strava_login = json_decode($json);
|
$strava_login = json_decode($json);
|
||||||
if($strava_login->success == "true") {
|
if(!isset($strava_login->error)) {
|
||||||
$this->feedback .= __('Successfully authenticated.', 'wp-strava');
|
$this->feedback .= __('Successfully authenticated.', 'wp-strava');
|
||||||
return $strava_login->token;
|
return $strava_login->token;
|
||||||
} else {
|
} else {
|
||||||
@@ -127,7 +131,7 @@ class Rides {
|
|||||||
|
|
||||||
public function getRideMap($rideId, $token, $efforts, $threshold) {
|
public function getRideMap($rideId, $token, $efforts, $threshold) {
|
||||||
if($rideId != 0 AND $token != "") {
|
if($rideId != 0 AND $token != "") {
|
||||||
$url = preg_replace('/:id/', $rideId, $this->rideMapDetailsUrlv2);
|
$url = preg_replace('/:id/', $rideId, $this->rideMapDetailsUrlV2);
|
||||||
$json = file_get_contents($url . '?token=' . $token . '&threshold=' . $threshold);
|
$json = file_get_contents($url . '?token=' . $token . '&threshold=' . $threshold);
|
||||||
|
|
||||||
if($json) {
|
if($json) {
|
||||||
|
|||||||
+140
-127
@@ -6,7 +6,7 @@ require_once 'util.class.php';
|
|||||||
Plugin Name: WP Strava
|
Plugin Name: WP Strava
|
||||||
Plugin URI: http://cmanon.com
|
Plugin URI: http://cmanon.com
|
||||||
Description: Plugin to show your strava.com information in your wordpress blog. Some Icons are Copyright © Yusuke Kamiyamane. All rights reserved. Licensed under a Creative Commons Attribution 3.0 license.
|
Description: Plugin to show your strava.com information in your wordpress blog. Some Icons are Copyright © Yusuke Kamiyamane. All rights reserved. Licensed under a Creative Commons Attribution 3.0 license.
|
||||||
Version: 0.61
|
Version: 0.62
|
||||||
Author: Carlos Santa Cruz (cmanon)
|
Author: Carlos Santa Cruz (cmanon)
|
||||||
Author URI: http://cmanon.com
|
Author URI: http://cmanon.com
|
||||||
License: GPL2
|
License: GPL2
|
||||||
@@ -49,6 +49,21 @@ function register_strava_settings() {
|
|||||||
//register_setting('wp-strava-settings-group','strava_som');
|
//register_setting('wp-strava-settings-group','strava_som');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function load_styles() {
|
||||||
|
// Register a personalized stylesheet
|
||||||
|
wp_register_style('wp-strava-style', plugins_url('css/wp-strava.css', __FILE__));
|
||||||
|
wp_enqueue_style('wp-strava');
|
||||||
|
}
|
||||||
|
add_action('wp_enqueue_script', 'load_styles');
|
||||||
|
|
||||||
|
function load_scripts() {
|
||||||
|
// Load required javascript libraries
|
||||||
|
wp_enqueue_script('jquery');
|
||||||
|
//wp_enqueue_script('google-maps', 'http://maps.google.com/maps/api/js?sensor=false');
|
||||||
|
}
|
||||||
|
add_action('wp-enqueue_script', 'load_scripts');
|
||||||
|
|
||||||
|
|
||||||
function wp_strava_plugin_options() {
|
function wp_strava_plugin_options() {
|
||||||
if (!current_user_can('administrator')) {
|
if (!current_user_can('administrator')) {
|
||||||
wp_die(__('You do not have sufficient permissions to access this page.'));
|
wp_die(__('You do not have sufficient permissions to access this page.'));
|
||||||
@@ -102,12 +117,6 @@ function wp_strava_plugin_options() {
|
|||||||
</div>
|
</div>
|
||||||
<?php } // Finished admin menu options
|
<?php } // Finished admin menu options
|
||||||
|
|
||||||
// Load required javascript libraries
|
|
||||||
wp_enqueue_script('jquery');
|
|
||||||
//wp_enqueue_script('google-maps', 'http://maps.google.com/maps/api/js?sensor=false');
|
|
||||||
|
|
||||||
// Register a personalized stylesheet
|
|
||||||
wp_register_style('wp-strava', plugins_url('css/wp-strava.css', __FILE__));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WP Strava Latest Rides Widget Class
|
* WP Strava Latest Rides Widget Class
|
||||||
@@ -250,126 +259,130 @@ function strava_request_handler($strava_search_option, $strava_search_id, $strav
|
|||||||
return $response;
|
return $response;
|
||||||
} // Function strava_request_handler
|
} // Function strava_request_handler
|
||||||
|
|
||||||
// Shortcode handler function
|
|
||||||
// [ride id=id efforts=false threshold=5 map-width="100%" map-height="400px"] tag
|
class RideShortcode {
|
||||||
function strava_ride_shortcode_handler($atts) {
|
static $add_script;
|
||||||
$token = get_option('strava_token');
|
|
||||||
$strava_som = get_option('strava_som');
|
static function init() {
|
||||||
|
add_shortcode('ride', array(__CLASS__, 'handler'));
|
||||||
if($token) {
|
|
||||||
$pairs = array(
|
add_action('init', array(__CLASS__, 'registerScripts'));
|
||||||
'id' => 0,
|
add_action('wp_footer', array(__CLASS__, 'printScripts'));
|
||||||
'efforts' => false,
|
|
||||||
'threshold' => 0,
|
|
||||||
'map_width' => "100%",
|
|
||||||
'map_height' => "400px"
|
|
||||||
);
|
|
||||||
|
|
||||||
extract(shortcode_atts($pairs, $atts));
|
|
||||||
|
|
||||||
$ride = new Rides();
|
|
||||||
$rideDetails = $ride->getRideDetails($id, $strava_som_option);
|
|
||||||
$rideCoordinates = $ride->getRideMap($id, $token, $efforts, $threshold);
|
|
||||||
|
|
||||||
if ($strava_som == "metric") {
|
|
||||||
$units = array(
|
|
||||||
'elapsedTime' => __('hours','wp-strava'),
|
|
||||||
'movingTime' => __('hours','wp-strava'),
|
|
||||||
'distance' => __('km','wp-strava'),
|
|
||||||
'averageSpeed' => __('km/h','wp-strava'),
|
|
||||||
'maximumSpeed' => __('km/h','wp-strava'),
|
|
||||||
'elevationGain' => __('meters','wp-strava')
|
|
||||||
);
|
|
||||||
} elseif ($strava_som_option == "english") {
|
|
||||||
$units = array(
|
|
||||||
'elapsedTime' => __('hours','wp-strava'),
|
|
||||||
'movingTime' => __('hours','wp-strava'),
|
|
||||||
'distance' => __('miles','wp-strava'),
|
|
||||||
'averageSpeed' => __('miles/h','wp-strava'),
|
|
||||||
'maximumSpeed' => __('miles/h','wp-strava'),
|
|
||||||
'elevationGain' => __('feet','wp-strava')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($rideCoordinates) {
|
|
||||||
return "
|
|
||||||
<div id='ride-header-{$id}' class='table'>
|
|
||||||
<table id='ride-details-table'>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Elapsed Time</th>
|
|
||||||
<th>Moving Time</th>
|
|
||||||
<th>Distance</th>
|
|
||||||
<th>Average Speed</th>
|
|
||||||
<th>Max Speed</th>
|
|
||||||
<th>Elevation Gain</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr class='ride-details-table-info'>
|
|
||||||
<td>{$rideDetails['elapsedTime']}</td>
|
|
||||||
<td>{$rideDetails['movingTime']}</td>
|
|
||||||
<td>{$rideDetails['distance']}</td>
|
|
||||||
<td>{$rideDetails['averageSpeed']}</td>
|
|
||||||
<td>{$rideDetails['maximumSpeed']}</td>
|
|
||||||
<td>{$rideDetails['elevationGain']}</td>
|
|
||||||
</tr>
|
|
||||||
<tr class='ride-details-table-units'>
|
|
||||||
<td>{$units['elapsedTime']}</td>
|
|
||||||
<td>{$units['movingTime']}</td>
|
|
||||||
<td>{$units['distance']}</td>
|
|
||||||
<td>{$units['averageSpeed']}</td>
|
|
||||||
<td>{$units['maximumSpeed']}</td>
|
|
||||||
<td>{$units['elevationGain']}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div id='ride-map-{$id}' class='map' style='width: {$map_width}; height: {$map_height}; border: 1px solid lightgrey;'></div>
|
|
||||||
<script type='text/javascript' src='http://maps.google.com/maps/api/js?sensor=false'></script>
|
|
||||||
<script type='text/javascript'>
|
|
||||||
jQuery(document).ready(function($){
|
|
||||||
var coordinates = eval({$rideCoordinates});
|
|
||||||
var rideCoordinates = coordinates.latlng;
|
|
||||||
var mapCenter = new google.maps.LatLng(23.091860, -102.839356);
|
|
||||||
var mapOptions = {
|
|
||||||
zoom: 5,
|
|
||||||
center: mapCenter,
|
|
||||||
//mapTypeControl: true,
|
|
||||||
//mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
|
|
||||||
zoomControl: true,
|
|
||||||
zoomControlOptions: {style: google.maps.MapTypeControlStyle.SMALL},
|
|
||||||
mapTypeId: google.maps.MapTypeId.TERRAIN
|
|
||||||
};
|
|
||||||
var mapObject = new google.maps.Map($('#ride-map-{$id}')[0], mapOptions);
|
|
||||||
var mapBounds = new google.maps.LatLngBounds();
|
|
||||||
var mapCoordinates = new google.maps.MVCArray();
|
|
||||||
var size = rideCoordinates.length;
|
|
||||||
for(i = 0; i < size; i++) {
|
|
||||||
point = new google.maps.LatLng(parseFloat(rideCoordinates[i][0]), parseFloat(rideCoordinates[i][1]));
|
|
||||||
mapBounds.extend(point);
|
|
||||||
mapCoordinates.push(point);
|
|
||||||
}
|
|
||||||
|
|
||||||
var polylineOptions = {
|
|
||||||
path: mapCoordinates,
|
|
||||||
strokeColor: '#e0642e',
|
|
||||||
strokeOpacity: 0.8,
|
|
||||||
strokeWeight: 3
|
|
||||||
};
|
|
||||||
|
|
||||||
var polyline = new google.maps.Polyline(polylineOptions);
|
|
||||||
polyline.setMap(mapObject);
|
|
||||||
mapObject.fitBounds(mapBounds);
|
|
||||||
//google.maps.event.trigger(mapObject, 'resize');
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return _e('Please first get your strava token using the settings wp strava page.', 'wp-strava');
|
|
||||||
}
|
}
|
||||||
} // strava_ride_shortcode_handler
|
|
||||||
//add_shortcode('ride', 'WP\Strava\strava_ride_shortcode_handler');
|
// Shortcode handler function
|
||||||
|
// [ride id=id som=metric efforts=false threshold=5 map-width="100%" map-height="400px"] tag
|
||||||
|
function handler($atts) {
|
||||||
|
self::$add_script = true;
|
||||||
|
|
||||||
|
$token = get_option('strava_token');
|
||||||
|
|
||||||
|
if($token) {
|
||||||
|
$pairs = array(
|
||||||
|
'id' => 0,
|
||||||
|
'som' => "metric",
|
||||||
|
'efforts' => false,
|
||||||
|
'threshold' => 0,
|
||||||
|
'map_width' => "100%",
|
||||||
|
'map_height' => "400px"
|
||||||
|
);
|
||||||
|
|
||||||
|
extract(shortcode_atts($pairs, $atts));
|
||||||
|
|
||||||
|
if (isset($som)) {
|
||||||
|
$strava_som = $som;
|
||||||
|
} else {
|
||||||
|
$strava_som = get_option('strava_som_option', 'metric');
|
||||||
|
}
|
||||||
|
|
||||||
|
$ride = new Rides();
|
||||||
|
$rideDetails = $ride->getRideDetails($id, $strava_som);
|
||||||
|
$rideCoordinates = $ride->getRideMap($id, $token, $efforts, $threshold);
|
||||||
|
|
||||||
|
if ($strava_som == "metric") {
|
||||||
|
$units = array(
|
||||||
|
'elapsedTime' => __('hours','wp-strava'),
|
||||||
|
'movingTime' => __('hours','wp-strava'),
|
||||||
|
'distance' => __('km','wp-strava'),
|
||||||
|
'averageSpeed' => __('km/h','wp-strava'),
|
||||||
|
//'maximumSpeed' => __('km/h','wp-strava'),
|
||||||
|
'elevationGain' => __('meters','wp-strava')
|
||||||
|
);
|
||||||
|
} elseif ($strava_som == "english") {
|
||||||
|
$units = array(
|
||||||
|
'elapsedTime' => __('hours','wp-strava'),
|
||||||
|
'movingTime' => __('hours','wp-strava'),
|
||||||
|
'distance' => __('miles','wp-strava'),
|
||||||
|
'averageSpeed' => __('miles/h','wp-strava'),
|
||||||
|
//'maximumSpeed' => __('miles/h','wp-strava'),
|
||||||
|
'elevationGain' => __('feet','wp-strava')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($rideCoordinates) {
|
||||||
|
return "
|
||||||
|
<div id='ride-header-{$id}' class='table'>
|
||||||
|
<table id='ride-details-table'>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Elapsed Time</th>
|
||||||
|
<th>Moving Time</th>
|
||||||
|
<th>Distance</th>
|
||||||
|
<th>Average Speed</th>
|
||||||
|
<th>Elevation Gain</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr class='ride-details-table-info'>
|
||||||
|
<td>{$rideDetails['elapsedTime']}</td>
|
||||||
|
<td>{$rideDetails['movingTime']}</td>
|
||||||
|
<td>{$rideDetails['distance']}</td>
|
||||||
|
<td>{$rideDetails['averageSpeed']}</td>
|
||||||
|
<td>{$rideDetails['elevationGain']}</td>
|
||||||
|
</tr>
|
||||||
|
<tr class='ride-details-table-units'>
|
||||||
|
<td>{$units['elapsedTime']}</td>
|
||||||
|
<td>{$units['movingTime']}</td>
|
||||||
|
<td>{$units['distance']}</td>
|
||||||
|
<td>{$units['averageSpeed']}</td>
|
||||||
|
<td>{$units['elevationGain']}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div id='{$id}' class='map' style='width: {$map_width}; height: {$map_height}; border: 1px solid lightgrey;'></div>
|
||||||
|
<script type='text/javascript'>
|
||||||
|
if (window.coordinates === undefined) {
|
||||||
|
window.coordinates = [];
|
||||||
|
}
|
||||||
|
window.coordinates[{$id}] = eval({$rideCoordinates});
|
||||||
|
</script>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return _e('Please first get your strava token using the settings wp strava page.', 'wp-strava');
|
||||||
|
}
|
||||||
|
} // handler
|
||||||
|
|
||||||
|
static function registerScripts() {
|
||||||
|
wp_register_style('wp-strava-style', plugins_url('css/wp-strava.css', __FILE__));
|
||||||
|
|
||||||
|
wp_register_script('wp-strava-script', plugins_url('js/wp-strava.js', __FILE__), array('jquery'), '1.0', true);
|
||||||
|
wp_register_script('google-maps', 'http://maps.google.com/maps/api/js?sensor=false');
|
||||||
|
}
|
||||||
|
|
||||||
|
static function printScripts() {
|
||||||
|
if (self::$add_script) {
|
||||||
|
wp_enqueue_style('wp-strava-style');
|
||||||
|
wp_enqueue_script('jquery');
|
||||||
|
|
||||||
|
wp_print_scripts('google-maps');
|
||||||
|
wp_print_scripts('wp-strava-script');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize short code
|
||||||
|
RideShortcode::init();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user