mirror of
https://github.com/10h30/wp-strava.git
synced 2026-06-05 15:10:01 +09:00
Merge pull request #99 from cmanon/feature/98-time-exception
Added check for empty activity time
This commit is contained in:
+6
-3
@@ -28,13 +28,13 @@ Using WP-Strava 2.0+ requires a working WordPress cron configuration. By default
|
||||
|
||||
Embed an activity in any page or post. Shows a summary of the activity plus a map if a google maps key has been added.
|
||||
|
||||
Paste in the full activity URL from Strava, such as https://www.strava.com/activities/1793155844 and click "Embed." A preview map will be shown in the editor, similar to what will be displayed on the front-end. In the side-panel you can selection options to show the image only (without the details table), display markers at the start & finish points, and override the system of measure from your default selection under Settings -> Strava.
|
||||
Paste in the full activity URL from Strava, such as https://www.strava.com/activities/1793155844 and click "Embed." A preview map will be shown in the editor, similar to what will be displayed on the front-end. In the side-panel you can select options to show the image only (without the details table), display markers at the start & finish points, and override the system of measure from your default selection under Settings -> Strava.
|
||||
|
||||
== Strava Route==
|
||||
|
||||
Embed a route in any page or post. Shows a summary of the route plus a map if a google maps key has been added.
|
||||
|
||||
Paste in the full route URL from Strava, such as https://www.strava.com/routes/2326567 and click "Embed." A preview map will be shown in the editor, similar to what will be displayed on the front-end. In the side-panel you can selection options to show the image only (without the details table), display markers at the start & finish points, and override the system of measure from your default selection under Settings -> Strava.
|
||||
Paste in the full route URL from Strava, such as https://www.strava.com/routes/2326567 and click "Embed." A preview map will be shown in the editor, similar to what will be displayed on the front-end. In the side-panel you can select options to show the image only (without the details table), display markers at the start & finish points, and override the system of measure from your default selection under Settings -> Strava.
|
||||
|
||||
== Strava Activities List ==
|
||||
|
||||
@@ -44,7 +44,7 @@ Shows your most recent activities in a bulleted list.
|
||||
|
||||
Embed a segment in a page or post. Shows a summary of the segment plugs a map if a google maps key has been added.
|
||||
|
||||
Paste in the full segment URL from Strava, such as https://www.strava.com/segments/18803428 and click "Embed." A preview map will be shown in the editor, similar to what will be displayed on the front-end. In the side-panel you can selection options to show the image only (without the details table), display markers at the start & finish points, and override the system of measure from your default selection under Settings -> Strava.
|
||||
Paste in the full segment URL from Strava, such as https://www.strava.com/segments/18803428 and click "Embed." A preview map will be shown in the editor, similar to what will be displayed on the front-end. In the side-panel you can select options to show the image only (without the details table), display markers at the start & finish points, and override the system of measure from your default selection under Settings -> Strava.
|
||||
|
||||
= Shortcodes =
|
||||
|
||||
@@ -132,6 +132,9 @@ On the WP-Strava settings page you cannot currently remove and add another athle
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 2.9.1 =
|
||||
Add conditional to look for zero/null/empty activity time to avoid exception https://wordpress.org/support/topic/exception-thrown-oceanwp-theme/
|
||||
|
||||
= 2.9.0 =
|
||||
Added Segment Block https://wordpress.org/support/topic/show-segments-feature/ / https://wordpress.org/support/topic/embed-segments-feature/
|
||||
Switched Activities List to display moving time instead of elapsed time https://wordpress.org/support/topic/moving-time-instead-of-elapsed-time/
|
||||
|
||||
@@ -36,6 +36,10 @@ abstract class WPStrava_SOM {
|
||||
* @see https://stackoverflow.com/a/20870843/2146022
|
||||
*/
|
||||
public function time( $seconds ) {
|
||||
if ( empty( $seconds ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$zero = new DateTime( '@0' );
|
||||
$offset = new DateTime( "@{$seconds}" );
|
||||
$diff = $zero->diff( $offset );
|
||||
|
||||
@@ -96,6 +96,18 @@ class WPStrava_SOMEnglishTest extends TestCase {
|
||||
$this->assertEquals( '61:24:31', $this->som->time( 221071 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that null or empty seconds input will return an empty string (not an exception).
|
||||
*
|
||||
* @author Justin Foell <justin@foell.org>
|
||||
* @since 2.9.1
|
||||
*/
|
||||
public function test_time_empty() {
|
||||
$this->assertEquals( '', $this->som->time( '' ) );
|
||||
$this->assertEquals( '', $this->som->time( null ) );
|
||||
$this->assertEquals( '', $this->som->time( 0 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that 1304 calories is 1,304 using both string and int inputs.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user