diff --git a/lib/WPStrava/ActivityShortcode.php b/lib/WPStrava/ActivityShortcode.php index 8e450e4..bb29188 100644 --- a/lib/WPStrava/ActivityShortcode.php +++ b/lib/WPStrava/ActivityShortcode.php @@ -73,23 +73,25 @@ class WPStrava_ActivityShortcode { return $e->to_html(); } - //sanitize width & 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 ); - + $activity_output = ''; if ( $activity_details ) { - $activity_output = '
'; + $activity_output .= '
'; if ( ! $atts['image_only'] ) { $activity_output .= $this->get_table( $activity_details, $atts['som'] ); } + + // Sanitize width & 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 ); + $activity_output .= '' . WPStrava_StaticMap::get_image_tag( $activity_details, $map_height, $map_width, $atts['markers'] ) . '
'; - return $activity_output; } // End if( $activity_details ). + return $activity_output; } /** diff --git a/lib/WPStrava/RouteShortcode.php b/lib/WPStrava/RouteShortcode.php index 3230699..68e3423 100644 --- a/lib/WPStrava/RouteShortcode.php +++ b/lib/WPStrava/RouteShortcode.php @@ -53,6 +53,7 @@ class WPStrava_RouteShortcode { 'map_height' => '320', 'athlete_token' => WPStrava::get_instance()->settings->get_default_token(), 'markers' => false, + 'image_only' => false, ); $atts = shortcode_atts( $defaults, $atts, 'route' ); @@ -60,9 +61,9 @@ class WPStrava_RouteShortcode { /* Make sure boolean values are actually boolean * @see https://wordpress.stackexchange.com/a/119299 */ - $atts['markers'] = filter_var( $atts['markers'], FILTER_VALIDATE_BOOLEAN ); + $atts['markers'] = filter_var( $atts['markers'], FILTER_VALIDATE_BOOLEAN ); + $atts['image_only'] = filter_var( $atts['image_only'], FILTER_VALIDATE_BOOLEAN ); - $strava_som = WPStrava_SOM::get_som( $atts['som'] ); $route = WPStrava::get_instance()->routes; $route_details = null; @@ -72,41 +73,61 @@ class WPStrava_RouteShortcode { return $e->to_html(); } - // Sanitize width & 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 ); - + $route_output = ''; if ( $route_details ) { - return ' -
- - - - - - - - - - - - - - - - - - - - -
' . __( 'Est. Moving Time', 'wp-strava' ) . '' . __( 'Distance', 'wp-strava' ) . '' . __( 'Elevation Gain', 'wp-strava' ) . '
' . $strava_som->time( $route_details->estimated_moving_time ) . '' . $strava_som->distance( $route_details->distance ) . '' . $strava_som->elevation( $route_details->elevation_gain ) . '
' . $strava_som->get_time_label() . '' . $strava_som->get_distance_label() . '' . $strava_som->get_elevation_label() . '
- ' . + $route_output = ''; } // End if( $route_details ). + return $route_output; + } + + /** + * The the route details in in HTML table. + * + * @param string $route_details route details from the route class. + * @param string $som System of measure (english/metric). + * @return string HTML Table of route details. + * @author Justin Foell + * @since NEXT + */ + private function get_table( $route_details, $som ) { + $strava_som = WPStrava_SOM::get_som( $som ); + return ' + + + + + + + + + + + + + + + + + + + + +
' . __( 'Est. Moving Time', 'wp-strava' ) . '' . __( 'Distance', 'wp-strava' ) . '' . __( 'Elevation Gain', 'wp-strava' ) . '
' . $strava_som->time( $route_details->estimated_moving_time ) . '' . $strava_som->distance( $route_details->distance ) . '' . $strava_som->elevation( $route_details->elevation_gain ) . '
' . $strava_som->get_time_label() . '' . $strava_som->get_distance_label() . '' . $strava_som->get_elevation_label() . '
+ '; } /**