Skip to content

Commit

Permalink
Merge pull request #99 from cmanon/feature/98-time-exception
Browse files Browse the repository at this point in the history
Added check for empty activity time
  • Loading branch information
jrfoell authored May 28, 2021
2 parents 39f8df2 + 9b56c4c commit 08164e0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
9 changes: 6 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ==

Expand All @@ -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 =

Expand Down Expand Up @@ -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/
Expand Down
4 changes: 4 additions & 0 deletions src/WPStrava/SOM.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
12 changes: 12 additions & 0 deletions tests/WPStrava/SOMEnglishTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
* @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.
*
Expand Down

0 comments on commit 08164e0

Please sign in to comment.