mirror of
https://github.com/10h30/wp-strava.git
synced 2026-07-12 03:06:34 +09:00
Removed all instances of 'ride' in favor of 'activity'
Removed all extract() Updated code standards and documentation Update readme
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Route Shortcode.
|
||||
*
|
||||
* @author Daniel Lintott
|
||||
* @since 1.3.0
|
||||
*/
|
||||
class WPStrava_RouteShortcode {
|
||||
private static $add_script;
|
||||
|
||||
@@ -22,22 +28,30 @@ class WPStrava_RouteShortcode {
|
||||
'markers' => false,
|
||||
);
|
||||
|
||||
extract( shortcode_atts( $defaults, $atts ) );
|
||||
$atts = shortcode_atts( $defaults, $atts );
|
||||
|
||||
$strava_som = WPStrava_SOM::get_som( $som );
|
||||
$strava_som = WPStrava_SOM::get_som( $atts['som'] );
|
||||
$route = WPStrava::get_instance()->routes;
|
||||
$route_details = $route->get_route( $id );
|
||||
$route_details = $route->get_route( $atts['id'] );
|
||||
|
||||
if ( is_wp_error( $route_details ) ) {
|
||||
if ( WPSTRAVA_DEBUG ) {
|
||||
return '<pre>' . print_r( $route_details, true ) . '</pre>'; // @codingStandardsIgnoreLine
|
||||
} else {
|
||||
return $route_details->get_error_message();
|
||||
}
|
||||
}
|
||||
|
||||
//sanitize width & height
|
||||
$map_width = str_replace( '%', '', $map_width );
|
||||
$map_height = str_replace( '%', '', $map_height );
|
||||
$map_width = str_replace( '%', '', $atts['map_width'] );
|
||||
$map_height = str_replace( '%', '', $atts['map_height'] );
|
||||
$map_width = str_replace( 'px', '', $map_width );
|
||||
$map_height = str_replace( 'px', '', $map_height );
|
||||
|
||||
if ( $route_details ) {
|
||||
return '
|
||||
<div id="ride-header-' . $id . '" class="wp-strava-ride-container">
|
||||
<table id="ride-details-table">
|
||||
<div id="activity-header-' . $atts['id'] . '" class="wp-strava-activity-container">
|
||||
<table id="activity-details-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>' . __( 'Est. Moving Time', 'wp-strava' ) . '</th>
|
||||
@@ -46,22 +60,24 @@ class WPStrava_RouteShortcode {
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="ride-details-table-info">
|
||||
<tr class="activity-details-table-info">
|
||||
<td>' . $strava_som->time( $route_details->estimated_moving_time ) . '</td>
|
||||
<td>' . $strava_som->distance( $route_details->distance ) . '</td>
|
||||
<td>' . $strava_som->elevation( $route_details->elevation_gain ) . '</td>
|
||||
</tr>
|
||||
<tr class="ride-details-table-units">
|
||||
<tr class="activity-details-table-units">
|
||||
<td>' . $strava_som->get_time_label() . '</td>
|
||||
<td>' . $strava_som->get_distance_label() . '</td>
|
||||
<td>' . $strava_som->get_elevation_label() . '</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>' .
|
||||
WPStrava_StaticMap::get_image_tag( $route_details, $map_height, $map_width, $markers ) .
|
||||
'</div>';
|
||||
</table>
|
||||
<a title="' . $route_details->name . '" href="' . WPStrava_Routes::ROUTES_URL . $route_details->id . '">' .
|
||||
WPStrava_StaticMap::get_image_tag( $route_details, $map_height, $map_width, $atts['markers'] ) .
|
||||
'</a>
|
||||
</div>';
|
||||
} // End if( $route_details ).
|
||||
} // handler
|
||||
}
|
||||
|
||||
public static function print_scripts() {
|
||||
if ( self::$add_script ) {
|
||||
|
||||
Reference in New Issue
Block a user