Working on Settigns
authorChuck Scott <cscott@gaslightmedia.com>
Thu, 1 Oct 2015 14:44:09 +0000 (10:44 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Thu, 1 Oct 2015 14:44:09 +0000 (10:44 -0400)
config.php [new file with mode: 0644]
glm-member-db.php

diff --git a/config.php b/config.php
new file mode 100644 (file)
index 0000000..069ff2e
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+/**
+ * Gaslight Media Members Database Plugin
+ *
+ * Get plugin configuration
+ */
+
+// 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 - These can't go into the defines.php file - Guess why.
+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 States and Countries arrays
+$stateData = parse_ini_file(GLM_MEMBERS_PLUGIN_PATH.'/config/states.ini');
+$config['states'] = $stateData['states'];
+$countryData = parse_ini_file(GLM_MEMBERS_PLUGIN_PATH.'/config/countries.ini');
+$config['countries'] = $countryData['countries'];
+
+// Read in Settings and Terms from database
+$settings = $wpdb->get_row("SELECT * FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "settings_general WHERE id = 1;", ARRAY_A);
+unset($settings['id']);
+$terms = $wpdb->get_row("SELECT * FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "settings_terms WHERE id = 1;", ARRAY_A);
+unset($terms['id']);
+$config = array_merge($config, $settings, $terms);
+
+echo "<pre>".print_r($config,1)."</pre>";
+exit;
+
+
+// Check for config value replacements in the current theme
+$currentThemeDirectory = get_template_directory();
+if (file_exists($currentThemeDirectory.'/glm-member-db/plugin.ini')) {
+
+    // Read in the ini file from the theme
+    $themeIni = parse_ini_file($currentThemeDirectory.'/glm-member-db/plugin.ini');
+
+    // Replace parameters that are in the theme ini file
+    $config = array_replace($config, $themeIni);
+
+}
+
+?>
index 722dcae..d634d36 100644 (file)
@@ -3,7 +3,7 @@
  * Plugin Name: GLM Members Database
  * Plugin URI: http://www.gaslightmedia.com/
  * Description: Gaslight Media Members Database.
- * Version: 1.0.10
+ * Version: 1.0.20
  * Author: Chuck Scott
  * Author URI: http://www.gaslightmedia.com/
  * License: GPL2
@@ -19,7 +19,7 @@
  * @package glmMembersDatabase
  * @author Chuck Scott <cscott@gaslightmedia.com>
  * @license http://www.gaslightmedia.com Gaslightmedia
- * @version 1.0.10
+ * @version 1.0.20
  */
 
 /*
@@ -44,68 +44,12 @@ $startupNotices = '';
 // Get standard defined parameters
 require_once('defines.php');
 
-// 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 - These can't go into the defines.php file - Guess why.
-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
-$stateData = parse_ini_file(GLM_MEMBERS_PLUGIN_PATH.'/config/states.ini');
-$config['states'] = $stateData['states'];
-$countryData = parse_ini_file(GLM_MEMBERS_PLUGIN_PATH.'/config/countries.ini');
-$config['countries'] = $countryData['countries'];
-
-// Check for config value replacements in the current theme
-$currentThemeDirectory = get_template_directory();
-if (file_exists($currentThemeDirectory.'/glm-member-db/plugin.ini')) {
-
-    // Read in the ini file from the theme
-    $themeIni = parse_ini_file($currentThemeDirectory.'/glm-member-db/plugin.ini');
-
-    // Replace parameters that are in the theme ini file
-    $config = array_replace($config, $themeIni);
-
-}
-
-// Add General Settings and Terms from the database to $config
-$setGeneral = $wpdb->get_row(
-    'SELECT * FROM '.GLM_MEMBERS_PLUGIN_DB_PREFIX.'settings_general WHERE id = 1;',
-    ARRAY_A
-);
-unset($setGeneral['id']);
-$setTerms = $wpdb->get_row(
-        'SELECT * FROM '.GLM_MEMBERS_PLUGIN_DB_PREFIX.'settings_terms WHERE id = 1;',
-        ARRAY_A
-);
-unset($setTerms['id']);
-$config = array_merge($config, $setGeneral, $setTerms);
+// Get configuration
+require_once('config.php');
 
 // Try to set the DB version option to false (new plugin) - If it's already set this won't do anything.
 add_option('glmMembersDatabaseDbVersion', false);
 
-// Custom plugin post type (for wp_post entries)
-// define('GLM_MEMBERS_PLUGIN_POST_TYPE', '');
-
 /**
  * *******************************************************************************
  *
@@ -261,6 +205,15 @@ register_deactivation_hook(__FILE__, 'glmMembersPluginDeactivate');
 
 // Uninstall - Not using. Using "uninstall.php" in the root directory of this plugin.
 
+/*
+ *
+ * Load any other common files needed
+ *
+ */
+
+// Load data abstract
+require_once(GLM_MEMBERS_PLUGIN_LIB_PATH.'/GlmDataAbstract/DataAbstract.php');
+
 /*
  *
  * Determine which controller to load