From 750773d0b1c7b18fe9f9db3da63b2c987eaf138a Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 3 Jul 2018 14:15:12 -0400 Subject: [PATCH] Update for the options Set option only when getting one. --- setup/adminHooks.php | 17 ++++++----------- views/glmInfoNotifications.html | 2 +- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/setup/adminHooks.php b/setup/adminHooks.php index 2527d02..a3cb316 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -72,8 +72,6 @@ add_action( $latest = get_option( GLM_SERVERSTATS_PLUGIN_RELAY_LATEST, false ); $latest_data = unserialize( $latest ); - // echo '
$latest_data: ' . print_r( $latest_data, true ) . '
'; - // check latest for time if too old then fetch latest and update time. $stale_time = strtotime( '-' . GLM_SERVERSTATS_PLUGIN_RELAY_LATEST_TIMEOUT ); if ( $current_time <= $stale_time ) { @@ -93,10 +91,8 @@ add_action( $message_data = wp_remote_retrieve_body( $response ); $status = wp_remote_retrieve_response_code( $response); - // echo '
$response: ' . print_r( $response, true ) . '
'; if ( $status == 200 ) { $messages = json_decode( $message_data, true ); - // echo '
$messages: ' . print_r( $messages, true ) . '
'; foreach ( $messages as $message ) { $title = $message['title']; $id = $message['id']; @@ -110,7 +106,6 @@ add_action( } else { $latest_version = false; } - // echo '
$latest_version: ' . print_r( $latest_version, true ) . '
'; if ( isset( $latest_data ) && isset( $latest_data['version'] ) && $latest_version == $latest_data['version'] ) { // use the cached data } else { @@ -124,14 +119,14 @@ add_action( 'version' => $id . '-' . $updated ); - } + // Store as option + update_option( GLM_SERVERSTATS_PLUGIN_RELAY_LATEST, serialize( $latest_data ), true ); - // Store as option - update_option( GLM_SERVERSTATS_PLUGIN_RELAY_LATEST, serialize( $latest_data ), true ); - if ( $latest_version ) { - update_option( GLM_SERVERSTATS_PLUGIN_RELAY_LATEST_VERSION, $latest_version, true ); - } + if ( $latest_version ) { + update_option( GLM_SERVERSTATS_PLUGIN_RELAY_LATEST_VERSION, $latest_version, true ); + } + } // Reset the default timezone date_default_timezone_set( $default_timezone ); diff --git a/views/glmInfoNotifications.html b/views/glmInfoNotifications.html index f2d0807..8b5345a 100644 --- a/views/glmInfoNotifications.html +++ b/views/glmInfoNotifications.html @@ -4,7 +4,7 @@ -- 2.17.1