Avoid errors on first run

This commit is contained in:
Justin Foell
2017-05-10 14:23:11 -05:00
parent 5cd0a60649
commit 37816d12b8
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -56,7 +56,7 @@ class WPStrava_LatestMapWidget extends WP_Widget {
$strava_club_id = empty( $instance['strava_club_id'] ) ? NULL : $instance['strava_club_id'];
$build_new = false;
//try our transient first
// Try our transient first.
$ride_transient = get_transient( 'strava_latest_map_ride' );
$ride_option = get_option( 'strava_latest_map_ride' );
@@ -87,12 +87,12 @@ class WPStrava_LatestMapWidget extends WP_Widget {
$ride = current( $rides );
//update transients & options
if ( $ride->id != $ride_option->id ) {
if ( empty( $ride_option->id ) || $ride->id != $ride_option->id ) {
$build_new = true;
update_option( 'strava_latest_map_ride', $ride );
}
if ( $ride->id != $ride_transient->id ) {
if ( empty( $ride_transient->id ) || $ride->id != $ride_transient->id ) {
set_transient( 'strava_latest_map_ride', $ride, HOUR_IN_SECONDS );
}
}
+1 -1
View File
@@ -28,7 +28,7 @@
define( 'WPSTRAVA_PLUGIN_DIR', trailingslashit( dirname( __FILE__) ) );
define( 'WPSTRAVA_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
define( 'WPSTRAVA_PLUGIN_NAME', plugin_basename(__FILE__) );
define( 'WPSTRAVA_DEBUG', false );
if ( ! defined( 'WPSTRAVA_DEBUG' ) ) define( 'WPSTRAVA_DEBUG', false );
// Load the multilingual support.
if( file_exists( WPSTRAVA_PLUGIN_DIR . 'lang/' . get_locale() . '.mo' ) ) {