define('GLM_SERVERSTATS_PLUGIN_SHORT_NAME', 'ServerStats');
define('GLM_SERVERSTATS_PLUGIN_SLUG', 'glm-serverstats');
define('GLM_SERVERSTATS_PLUGIN_RELAY_URL', 'https://www.gaslightmedia.com/wp-admin/admin-ajax.php?action=glm_members_admin_ajax&glm_action=relay');
+// define('GLM_SERVERSTATS_PLUGIN_RELAY_URL', 'http://develop.localhost/wp-admin/admin-ajax.php?action=glm_members_admin_ajax&glm_action=relay');
define('GLM_SERVERSTATS_PLUGIN_RELAY_LATEST', 'glm_serverstats_relay_latest');
define('GLM_SERVERSTATS_PLUGIN_RELAY_LATEST_VERSION', 'glm_serverstats_relay_latest_version');
define('GLM_SERVERSTATS_PLUGIN_RELAY_LATEST_TIMEOUT', '20 minutes');
// Get current time
$current_time = strtotime( 'now' );
+ // trigger_error( '$current_time: ' . $current_time . ' ' . date( 'Y-m-d H:i:s', $current_time ), E_USER_NOTICE );
$latest = get_option( GLM_SERVERSTATS_PLUGIN_RELAY_LATEST, false );
+ // trigger_error( '$latest: ' . $latest, E_USER_NOTICE );
$latest_data = unserialize( $latest );
+ // trigger_error( '$cached: ' . $latest_data['cached'] . ' ' . date( 'Y-m-d H:i:s', $latest_data['cached'] ), E_USER_NOTICE );
// 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 ) {
- $fetch_latest = true;
- }
+ // trigger_error( '$stale_time: ' . $stale_time . ' ' . date( 'Y-m-d H:i:s', $stale_time ), E_USER_NOTICE );
+ // if ( $current_time <= $stale_time ) {
+ // trigger_error( 'state time occurred', E_USER_NOTICE );
+ // $fetch_latest = true;
+ // }
if ( $latest ) {
if ( $latest_data['cached'] <= $stale_time ) {
+ // trigger_error( 'stale time occurred', E_USER_NOTICE );
$fetch_latest = true;
}
} else {
if ( $status == 200 ) {
$messages = json_decode( $message_data, true );
+ // trigger_error( '$messages: ' . print_r( $messages, true ), E_USER_NOTICE );
foreach ( $messages as $message ) {
- $title = $message['title'];
- $id = $message['id'];
- $updated = $message['updated']['timestamp'];
+ $title = $message['title'];
+ $dashboard_message = $message['dashboard_message'];
+ $id = $message['id'];
+ $updated = $message['updated']['timestamp'];
}
} else {
// echo '<pre>$status: ' . print_r( $status, true ) . '</pre>';
}
$latest_data = array(
- 'id' => $id,
- 'title' => $title,
- 'cached' => $current_time,
- 'version' => $id . '-' . $updated
+ 'id' => $id,
+ 'title' => $title,
+ 'dashboard_message' => $dashboard_message,
+ 'cached' => $current_time,
+ 'version' => $id . '-' . $updated
);
// Store as option
$latest = get_option( GLM_SERVERSTATS_PLUGIN_RELAY_LATEST, false );
$latest_data = unserialize( $latest );
+ echo '<div style="display:inline-block;clear: left;">';
echo '<p><b>Gaslight Media Notification: </b><br>';
echo '<p><b>'.$latest_data['title'].'</b><br>';
- echo '<a href="' . admin_url( 'admin.php' ) . '?page=glm-info-main-menu">More Details</a></p>';
+ echo wpautop( $latest_data['dashboard_message'] );
+ echo '</p></div>';
+ echo '<p><a href="' . admin_url( 'admin.php' ) . '?page=glm-info-main-menu">More Details</a></p>';
echo '</div>';
}, 10, 1
);
+{* GLM Notification Menu Page *}
<div class="wrap">
<h1>GLM Notifications</h1>
<ul>
<li>
- <a href="{$thisUrl}?page={$thisPage}&glm_action=index&option=full">Show Full List</a>
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=index&option=full">Show All</a>
</li>
</ul>
{if $view_type == 'main'}
{foreach $messages as $m}
<div class="glm-info-message">
+ <div style="float: right; width: 200px;text-align: right;">{$m.updated.datetime}</div>
<h2>{$m.title}</h2>
- <div>posted on {$m.updated.datetime}</div>
{$m.message}
</div>
{/foreach}
{else}
{foreach $messages as $m}
- <ul>
+ <ul id="glm-notices">
<li>
<strong><a href="{$admin_url}?page={$thisPage}&glm_action=index&option=view&id={$m.id}">{$m.title}</a> {$m.updated.datetime}</strong>
</li>