diff --git a/readme.txt b/readme.txt index 234191a..48a0633 100755 --- a/readme.txt +++ b/readme.txt @@ -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/ diff --git a/src/WPStrava/SOM.php b/src/WPStrava/SOM.php index deaf7d0..f65532c 100644 --- a/src/WPStrava/SOM.php +++ b/src/WPStrava/SOM.php @@ -36,6 +36,10 @@ abstract public function get_pace_label(); * @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 ); diff --git a/tests/WPStrava/SOMEnglishTest.php b/tests/WPStrava/SOMEnglishTest.php index c6e5a5f..3791938 100644 --- a/tests/WPStrava/SOMEnglishTest.php +++ b/tests/WPStrava/SOMEnglishTest.php @@ -96,6 +96,18 @@ public function test_time_greater24h() { $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 + * @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. *