mirror of
https://github.com/10h30/wp-strava.git
synced 2026-07-20 07:04:24 +09:00
Avoid errors on first run
This commit is contained in:
@@ -56,7 +56,7 @@ class WPStrava_LatestMapWidget extends WP_Widget {
|
|||||||
$strava_club_id = empty( $instance['strava_club_id'] ) ? NULL : $instance['strava_club_id'];
|
$strava_club_id = empty( $instance['strava_club_id'] ) ? NULL : $instance['strava_club_id'];
|
||||||
$build_new = false;
|
$build_new = false;
|
||||||
|
|
||||||
//try our transient first
|
// Try our transient first.
|
||||||
$ride_transient = get_transient( 'strava_latest_map_ride' );
|
$ride_transient = get_transient( 'strava_latest_map_ride' );
|
||||||
$ride_option = get_option( '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 );
|
$ride = current( $rides );
|
||||||
|
|
||||||
//update transients & options
|
//update transients & options
|
||||||
if ( $ride->id != $ride_option->id ) {
|
if ( empty( $ride_option->id ) || $ride->id != $ride_option->id ) {
|
||||||
$build_new = true;
|
$build_new = true;
|
||||||
update_option( 'strava_latest_map_ride', $ride );
|
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 );
|
set_transient( 'strava_latest_map_ride', $ride, HOUR_IN_SECONDS );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@
|
|||||||
define( 'WPSTRAVA_PLUGIN_DIR', trailingslashit( dirname( __FILE__) ) );
|
define( 'WPSTRAVA_PLUGIN_DIR', trailingslashit( dirname( __FILE__) ) );
|
||||||
define( 'WPSTRAVA_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
|
define( 'WPSTRAVA_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
|
||||||
define( 'WPSTRAVA_PLUGIN_NAME', plugin_basename(__FILE__) );
|
define( 'WPSTRAVA_PLUGIN_NAME', plugin_basename(__FILE__) );
|
||||||
define( 'WPSTRAVA_DEBUG', false );
|
if ( ! defined( 'WPSTRAVA_DEBUG' ) ) define( 'WPSTRAVA_DEBUG', false );
|
||||||
|
|
||||||
// Load the multilingual support.
|
// Load the multilingual support.
|
||||||
if( file_exists( WPSTRAVA_PLUGIN_DIR . 'lang/' . get_locale() . '.mo' ) ) {
|
if( file_exists( WPSTRAVA_PLUGIN_DIR . 'lang/' . get_locale() . '.mo' ) ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user