define('GLM_MEMBERS_PLUGIN_NAME', 'Gaslight Media Members Database');
define('GLM_MEMBERS_PLUGIN_DIR', 'glm-member-db');
-// Debug Options
-define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG', true);
-define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE', true);
-define('GLM_MEMBERS_PLUGIN_FRONT_DEBUG', true);
-define('GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE', true);
+// Determine which system we're running on - If not provided, assume PRODUCTION
+$host = getenv('GLM_HOST_ID');
+if (trim($host) == '') {
+ $host = 'PRODUCTION';
+}
+define('GLM_MEMBER_PLUGIN_HOST', $host);
// Determine current http/https protocol
$pageProtocol = 'http';
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+$startupNotices = '';
+
// Get standard defined parameters
require_once('defines.php');
-// Get plugin configuration - Just use common section for now, we'll deal with others later
+// Get plugin configuration
$configData = parse_ini_file(GLM_MEMBERS_PLUGIN_PATH.'/config/plugin.ini', true);
$config = $configData['common'];
+// Override parameters according to GLM_HOST_ID
+$hostSection = strtolower(GLM_MEMBER_PLUGIN_HOST).':common';
+if (isset($configData[$hostSection])) {
+ $config = array_replace($config, $configData[strtolower(GLM_MEMBER_PLUGIN_HOST).':common']);
+} else {
+ $startupNotices .=
+ '<p><b>Bad configuration file section name or section not found:</b> '. $hostSection
+ .'<br>See plugin '.GLM_MEMBERS_PLUGIN_PATH.'config/plugin.ini file.'
+ .'<br>Also check that the server "GLM_HOST_ID" environment parameter exists and matches a section in the above ini file.</p>'
+ ;
+}
+
+// Add Debug defines
+define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG', $config['admin_debug']);
+define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE', $config['admin_debug_verbose']);
+define('GLM_MEMBERS_PLUGIN_FRONT_DEBUG', $config['front_debug']);
+define('GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE', $config['front_debug_verbose']);
+
+// Also get image sizes array from the plugin.ini - uses separate ini section.
$config['imageSizes'] = $configData['imageSizes'];
// Get additional configuration data
}
}
-// Check if there's admin notices for output
+
+/*
+ * Check if there's any startup notices in this file. (stuff that happens before we get all setup)
+ *
+ * If there is, have the message displayed at the top of the wp-admin content area.
+ */
+function glmMembersStartupNotices() {
+ global $startupNotices;
+ echo '<div class="updated"><h3>'.GLM_MEMBERS_PLUGIN_NAME.' Plugin Warning</h3><p>'.$startupNotices.'</p></div>';
+}
+if ($startupNotices != '') {
+ add_action('admin_notices','glmMembersStartupNotices');
+}
+
+/*
+ * Check if there's any debug information or other notices that need to be displayed
+ *
+ * If there is, display as a separate window.
+ *
+ * NOTE: Need to break out notices that should be displayed in the wp-admin content area. To
+ * do that I need to modify the glmMembersAdminNotices function above and the
+ * addNotice() function in the classes/glmPluginSupport.php file. Should have addNotice()
+ * function be able to add to another option specifically for doing this.
+ */
$notices = get_option('glmMembersAdminNotices');
if (is_admin() && $notices && !GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+
// Add action to output the notices
add_action('admin_notices','glmMembersAdminNotices');
+
}
?>
\ No newline at end of file