Moved pace functions to base SOM class

This commit is contained in:
Justin Foell
2019-02-01 12:48:19 -06:00
parent b95e8356ac
commit 27f2699e96
6 changed files with 32 additions and 57 deletions
+1 -1
View File
@@ -63,7 +63,7 @@ class WPStrava_RouteShortcode {
try {
$route_details = $route->get_route( $atts['id'] );
} catch( WPStrava_Exception $e ) {
} catch ( WPStrava_Exception $e ) {
return $e->to_html();
}
+23 -2
View File
@@ -28,8 +28,6 @@ abstract class WPStrava_SOM {
abstract public function get_elevation_label();
abstract public function pace( $mps );
abstract public function get_pace_label();
abstract public function swimpace( $mps );
abstract public function get_swimpace_label();
public function time( $seconds ) {
return date( 'H:i:s', mktime( 0, 0, $seconds ) );
@@ -38,4 +36,27 @@ abstract class WPStrava_SOM {
public function get_time_label() {
return __( 'hours', 'wp-strava' );
}
/**
* Abbreviated label for this system of measure's pace - Minutes Per 100 Meters: min/100m. Same for English/metric.
*
* @return string 'min/100m'
*/
public function get_swimpace_label() {
return __( 'min/100m', 'wp-strava' );
}
/**
* Change meters per second to Minutes Per 100 Meters. Same for English/metric.
*
* @param float $mps Meters per second.
* @return float Minutes Per 100 Meters.
*/
public function swimpace( $mps ) {
$kmh = $mps * 3.6;
$min100m = 60 / $kmh / 10;
return number_format( $min100m, 2 );
}
}
+1 -25
View File
@@ -56,7 +56,7 @@ class WPStrava_SOMEnglish extends WPStrava_SOM {
}
/**
* Change meters per second to Minutes Per Mile.
* Change meters per second to minutes per mile.
*
* @param float $mps Meters per second.
* @return float Minutes Per Mile.
@@ -86,30 +86,6 @@ class WPStrava_SOMEnglish extends WPStrava_SOM {
return __( 'min/mile', 'wp-strava' );
}
/**
* Change meters per second to Minutes Per 100 Meters.
*
* @param float $mps Meters per second.
* @return float Minutes Per 100 Meters.
*/
public function swimpace( $mps ) {
$kmh = $mps * 3.6;
$min100m = 60 / $kmh / 10;
return number_format( $min100m, 2 );
}
/**
* Abbreviated label for this system of measure's pace - Minutes Per 100 Meters: min/100m
*
* @return string 'min/100m'
*/
public function get_swimpace_label() {
return __( 'min/100m', 'wp-strava' );
}
/**
* Change meters to feet.
*
+1 -24
View File
@@ -56,7 +56,7 @@ class WPStrava_SOMMetric extends WPStrava_SOM {
}
/**
* Change meters per second to kilometers per hour.
* Change meters per second to minutes per kilometer.
*
* @param float $mps Meters per second.
* @return float Kilometers per hour.
@@ -87,29 +87,6 @@ class WPStrava_SOMMetric extends WPStrava_SOM {
return __( 'min/km', 'wp-strava' );
}
/**
* Change meters per second to Minutes Per 100 Meters.
*
* @param float $mps Meters per second.
* @return float Minutes Per 100 Meters.
*/
public function swimpace( $mps ) {
$kmh = $mps * 3.6;
$min100m = 60 / $kmh / 10;
return number_format( $min100m, 2 );
}
/**
* Abbreviated label for this system of measure's pace - Minutes Per 100 Meters: min/100m
*
* @return string 'min/100m'
*/
public function get_swimpace_label() {
return __( 'min/100m', 'wp-strava' );
}
/**
* Change meters to meters };^)
*
+5 -4
View File
@@ -1,9 +1,9 @@
=== WP-Strava ===
Contributors: cmanon, jrfoell, lancewillett, dlintott
Contributors: cmanon, jrfoell, lancewillett, dlintott, sebastianerb
Tags: strava, activity, bicycle, cycling, biking, running, run, swimming, swim, gps, shortcode, widget, plugin
Requires at least: 4.6
Tested up to: 4.9
Tested up to: 5.0
Stable tag: 1.6.0
Requires PHP: 5.2
License: GPLv2 or later
@@ -80,7 +80,8 @@ WP-Strava caches activity for one hour so your site doesn't hit the Strava API o
= NEXT =
Added Pace support (min/km) for Activity Shortcode
Added Sebastian Erb to contributors.
Added Pace support (min/km) and (min/mile) for Activity Shortcode
Added Swimpace support (min/100m) for Activity Shortcode
= 1.6.0 =
@@ -126,7 +127,7 @@ Fix array indices on map widget
= 1.4.0 =
Added dlintott to contributors.
Added Daniel Lintott to contributors.
Fixed non-existent settings js from being enqueued.
Changed all 'ride' styles and functions to 'activity'.
Added inline documentation.
+1 -1
View File
@@ -4,7 +4,7 @@
* Plugin URI: https://wordpress.org/plugins/wp-strava/
* Description: Show your strava.com activity on your WordPress site. Some Icons are Copyright © Yusuke Kamiyamane. All rights reserved. Licensed under a Creative Commons Attribution 3.0 license.
* Version: 1.6.0
* Author: Carlos Santa Cruz, Justin Foell, Lance Willett, Daniel Lintott
* Author: Carlos Santa Cruz, Justin Foell, Lance Willett, Daniel Lintott, Sebastian Erb
* License: GPL2
* Text Domain: wp-strava
* Domain Path: /lang