Update for the options
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 3 Jul 2018 18:15:12 +0000 (14:15 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 3 Jul 2018 18:15:12 +0000 (14:15 -0400)
Set option only when getting one.

setup/adminHooks.php
views/glmInfoNotifications.html

index 2527d02..a3cb316 100644 (file)
@@ -72,8 +72,6 @@ add_action(
         $latest = get_option( GLM_SERVERSTATS_PLUGIN_RELAY_LATEST, false );
         $latest_data = unserialize( $latest );
 
-        // echo '<div><pre>$latest_data: ' . print_r( $latest_data, true ) . '</pre></div>';
-
         // 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 '<pre>$response: ' . print_r( $response, true ) . '</pre>';
             if ( $status == 200 ) {
                 $messages = json_decode( $message_data, true );
-                // echo '<pre>$messages: ' . print_r( $messages, true ) . '</pre>';
                 foreach ( $messages as $message ) {
                     $title   = $message['title'];
                     $id      = $message['id'];
@@ -110,7 +106,6 @@ add_action(
             } else {
                 $latest_version = false;
             }
-            // echo '<pre>$latest_version: ' . print_r( $latest_version, true ) . '</pre>';
             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 );
index f2d0807..8b5345a 100644 (file)
@@ -4,7 +4,7 @@
 
     <ul>
         <li>
-            <a href="{$thisUrl}?page={$thisPage}&glm_action=index&option=full">Full List</a>
+            <a href="{$thisUrl}?page={$thisPage}&glm_action=index&option=full">Show Full List</a>
         </li>
     </ul>