From: Steve Sutton Date: Fri, 8 Jun 2018 20:58:46 +0000 (-0400) Subject: Adding new menu for glm notifications X-Git-Tag: v2.0.0~17 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=3a58e599a99a4d7a35a278174f84f96a2b310c2b;p=WP-Plugins%2Fglm-serverstats.git Adding new menu for glm notifications More discussion is needed for how this is going to work. --- diff --git a/css/admin.css b/css/admin.css index 913616b..21aa3f9 100644 --- a/css/admin.css +++ b/css/admin.css @@ -407,3 +407,28 @@ input[type=submit], input[type=file] { color: #888; font-weight: 400; } + +/* GLM Info CSS */ +#glm-info-container { + background-color: white; + border: 1px solid darkgrey; + padding: .8rem 1rem; + display: inline-block; + width: 1200px; +} + +#glm-info-container h2 { + width: 100%; + clear: both; + margin: 1rem 0; +} + +#glm-info-container img { + margin: 0 1rem; +} + +.#glm-info-container .glm-info-message { + clear: both; + margin: 1rem 0; + position: relative; +} diff --git a/models/glmInfoNotifications.php b/models/glmInfoNotifications.php new file mode 100644 index 0000000..4b1df54 --- /dev/null +++ b/models/glmInfoNotifications.php @@ -0,0 +1,53 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release serverBandwidthSupport.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + +/* + * This class provides support for the reporting of server bandwidth stats + * for simple day and month values as well as detailed lists of values for + * a day (by 10 min intervals), month (by days), or 2 years (by months). + * + */ +class glmInfoNotifications +{ + public function model() + { + $messages = false; + $url = 'http://develop.localhost/wp-admin/admin-ajax.php?action=glm_members_admin_ajax&glm_action=relay'; + + // Get the messages from the main plugin. + $fetchData = wp_remote_get( $url ); + $messageData = wp_remote_retrieve_body( $fetchData ); + $status = wp_remote_retrieve_response_code( $fetchData); + + if ( $status == 200 ) { + $messages = json_decode( $messageData, true ); + } + + // If there's no message id then only get the first one. + $messages = array_slice( $messages, 0, 1 ); + + // Compile template data + $templateData = array( + 'messages' => $messages, + 'status' => $status, + ); + + // Return status, suggested view, and data to controller + return array( + 'view' => 'glmInfoNotifications', + 'data' => $templateData + ); + } +} diff --git a/setup/adminMenus.php b/setup/adminMenus.php index 1f074e6..4307f72 100644 --- a/setup/adminMenus.php +++ b/setup/adminMenus.php @@ -25,6 +25,17 @@ if (current_user_can('editor') || current_user_can('administrator')) { GLM_SERVERSTATS_PLUGIN_ASSETS_URL.'/flame.png', '3.100' ); + add_menu_page( + 'GLM Info', + 'GLM Info', + 'edit_pages', + 'glm-info-main-menu', + function(){ + serverStatsController('glmInfoNotifications'); + }, + GLM_SERVERSTATS_PLUGIN_ASSETS_URL.'/flame.png', + '3.200' + ); } // Add a sub-submeu for server Stats - For admin users only diff --git a/views/glmInfoNotifications.html b/views/glmInfoNotifications.html new file mode 100644 index 0000000..e6886ca --- /dev/null +++ b/views/glmInfoNotifications.html @@ -0,0 +1,19 @@ +
+ +

GLM Notifications

+ +
+ + {if $messages} + {foreach $messages as $m} +
+

{$m.title}

+
posted on {$m.updated.datetime}
+ {$m.message} +
+ {/foreach} + {/if} + +
+ +