diff --git a/lib/WPStrava/ActivityShortcode.php b/lib/WPStrava/ActivityShortcode.php
index 8b5a459..d1d5fa4 100644
--- a/lib/WPStrava/ActivityShortcode.php
+++ b/lib/WPStrava/ActivityShortcode.php
@@ -107,11 +107,14 @@ class WPStrava_ActivityShortcode {
private function get_table( $activity_details, $som ) {
$strava_som = WPStrava_SOM::get_som( $som );
$strava_activitytype = WPStrava_ActivityType::get_type_group( $activity_details->type );
- $avg_speed = '';
- $max_speed = '';
- $speed_label = '';
$avg_title = '
' . __( 'Average Speed', 'wp-strava' ) . ' | ';
$max_title = '' . __( 'Max Speed', 'wp-strava' ) . ' | ';
+ $elevation_title = '' . __( 'Elevation Gain', 'wp-strava' ) . ' | ';
+ $avg_speed = '';
+ $max_speed = '';
+ $elevation = '' . $strava_som->elevation( $activity_details->total_elevation_gain ) . ' | ';
+ $speed_label = '';
+ $elevation_label = '' . $strava_som->get_elevation_label() . ' | ';
switch ( $strava_activitytype ) {
case WPStrava_ActivityType::TYPE_GROUP_PACE:
@@ -135,6 +138,12 @@ class WPStrava_ActivityShortcode {
break;
}
+ if ( WPStrava::get_instance()->settings->hide_elevation ) {
+ $elevation = '';
+ $elevation_title = '';
+ $elevation_label = '';
+ }
+
return '
@@ -144,7 +153,7 @@ class WPStrava_ActivityShortcode {
| ' . __( 'Distance', 'wp-strava' ) . ' |
' . $avg_title . '
' . $max_title . '
- ' . __( 'Elevation Gain', 'wp-strava' ) . ' |
+ ' . $elevation_title . '
@@ -154,7 +163,7 @@ class WPStrava_ActivityShortcode {
' . $strava_som->distance( $activity_details->distance ) . ' |
' . $avg_speed . '
' . $max_speed . '
- ' . $strava_som->elevation( $activity_details->total_elevation_gain ) . ' |
+ ' . $elevation . '
| ' . $strava_som->get_time_label() . ' |
@@ -162,7 +171,7 @@ class WPStrava_ActivityShortcode {
' . $strava_som->get_distance_label() . ' |
' . $speed_label . '
' . $speed_label . '
- ' . $strava_som->get_elevation_label() . ' |
+ ' . $elevation_label . '
diff --git a/lib/WPStrava/LatestActivities.php b/lib/WPStrava/LatestActivities.php
index 0117532..3ae8597 100644
--- a/lib/WPStrava/LatestActivities.php
+++ b/lib/WPStrava/LatestActivities.php
@@ -50,8 +50,12 @@ class WPStrava_LatestActivities {
$response .= sprintf( __( ' went %1$s %2$s', 'wp-strava' ), $som->distance( $activity->distance ), $som->get_distance_label() );
// Translators: "during 2 hours"
$response .= sprintf( __( ' during %1$s %2$s', 'wp-strava' ), $som->time( $activity->elapsed_time ), $som->get_time_label() );
- // Translators: "climbing 100 ft."
- $response .= sprintf( __( ' climbing %1$s %2$s', 'wp-strava' ), $som->elevation( $activity->total_elevation_gain ), $som->get_elevation_label() );
+
+ if ( ! WPStrava::get_instance()->settings->hide_elevation ) {
+ // Translators: "climbing 100 ft."
+ $response .= sprintf( __( ' climbing %1$s %2$s', 'wp-strava' ), $som->elevation( $activity->total_elevation_gain ), $som->get_elevation_label() );
+ }
+
$response .= '';
}
$response .= '';
diff --git a/lib/WPStrava/RouteShortcode.php b/lib/WPStrava/RouteShortcode.php
index a0a9a51..323a524 100644
--- a/lib/WPStrava/RouteShortcode.php
+++ b/lib/WPStrava/RouteShortcode.php
@@ -105,25 +105,37 @@ class WPStrava_RouteShortcode {
*/
private function get_table( $route_details, $som ) {
$strava_som = WPStrava_SOM::get_som( $som );
+
+
+ $elevation_title = '' . __( 'Elevation Gain', 'wp-strava' ) . ' | ';
+ $elevation = '' . $strava_som->elevation( $route_details->elevation_gain ) . ' | ';
+ $elevation_label = '' . $strava_som->get_elevation_label() . ' | ';
+
+ if ( WPStrava::get_instance()->settings->hide_elevation ) {
+ $elevation = '';
+ $elevation_title = '';
+ $elevation_label = '';
+ }
+
return '
| ' . __( 'Est. Moving Time', 'wp-strava' ) . ' |
' . __( 'Distance', 'wp-strava' ) . ' |
- ' . __( 'Elevation Gain', 'wp-strava' ) . ' |
+ ' . $elevation_title . '
| ' . $strava_som->time( $route_details->estimated_moving_time ) . ' |
' . $strava_som->distance( $route_details->distance ) . ' |
- ' . $strava_som->elevation( $route_details->elevation_gain ) . ' |
+ ' . $elevation . '
| ' . $strava_som->get_time_label() . ' |
' . $strava_som->get_distance_label() . ' |
- ' . $strava_som->get_elevation_label() . ' |
+ ' . $elevation_label . '
diff --git a/lib/WPStrava/Settings.php b/lib/WPStrava/Settings.php
index c922665..b68d34f 100644
--- a/lib/WPStrava/Settings.php
+++ b/lib/WPStrava/Settings.php
@@ -505,6 +505,33 @@ class WPStrava_Settings {
return null;
}
+ /**
+ * Display the Hide Elevation Checkbox.
+ *
+ * @author Justin Foell
+ * @since 1.7.2
+ */
+ public function print_hide_elevation_input() {
+ ?>
+ hide_elevation, 'on' ); ?>/>
+
+ * @since 1.7.2
+ */
+ public function sanitize_hide_elevation( $checked ) {
+ if ( 'on' === $checked ) {
+ return $checked;
+ }
+ return null;
+ }
+
/**
* Print checkbox option to clear cache.
*
diff --git a/readme.txt b/readme.txt
index 64a51ea..3921aeb 100644
--- a/readme.txt
+++ b/readme.txt
@@ -83,6 +83,11 @@ WP-Strava caches activity for one hour so your site doesn't hit the Strava API o
== Changelog ==
+= 1.7.2 =
+
+Added setting to hide elevation.
+
+
= 1.7.1 =
Added PHPUnit tests for all System of Measure calculations.