Moved activate/deactivate, require support files, and user logged in hook from glmChe...
authorChuck Scott <cscott@gaslightmedia.com>
Tue, 16 May 2017 16:19:32 +0000 (12:19 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Tue, 16 May 2017 16:19:32 +0000 (12:19 -0400)
This solves support files not being loaded if a database doesn't check properly under certain situations.

index.php

index 4d8c543..e71592c 100644 (file)
--- a/index.php
+++ b/index.php
@@ -304,6 +304,72 @@ $config['addOns'] = apply_filters('glm-member-db-register-addon', $config['addOn
 $config['validActions'] = array();
 $config['shortcodes'] = array();
 
+/*
+ *
+ * Activate and Deactivate hooks
+ *
+ */
+
+// Activate
+function glmMembersPluginActivate ()
+{
+    global $wpdb, $config;
+    require_once GLM_MEMBERS_PLUGIN_PATH . '/activate.php';
+    new glmMembersPluginActivate($wpdb, $config);
+}
+register_activation_hook(__FILE__, 'glmMembersPluginActivate');
+
+// Deactivate
+function glmMembersPluginDeactivate ()
+{
+    global $wpdb, $config;
+    require_once GLM_MEMBERS_PLUGIN_PATH . '/deactivate.php';
+    $x = new glmMembersPluginDeactivate($wpdb, $config);
+    return false;
+}
+register_deactivation_hook(__FILE__, 'glmMembersPluginDeactivate');
+
+/*
+ *
+ * Load any other common files needed
+ *
+ */
+
+// Load data abstract
+require_once GLM_MEMBERS_PLUGIN_LIB_PATH.'/GlmDataAbstract/DataAbstract.php';
+
+// Load glmPluginSupport class
+require_once GLM_MEMBERS_PLUGIN_PATH . '/classes/glmPluginSupport.php';
+
+// Load Smarty Template Support
+require_once GLM_MEMBERS_PLUGIN_PATH . '/lib/smartyTemplateSupport.php';
+
+/*
+ *  Hook through which an add-on may supply additional logged in user information and
+ *  have that data stored in the config array. Typically it would be the
+ *  glm-members-db-contacts add-on supplying the information.
+ *
+ *  This hook provides default data with the current WordPress user 'data' object
+ *  as a 'wpUser' sub-array if a WordPress user is logged in. If not 'wpUser' will
+ *  be false. The supplied data is the basic information on the WordPress user
+ *  provided by the 'data' object from wp_get_current_user().
+ *
+ *  To permit more than one routine to access this filter and therefore to supply
+ *  additional information on the logged in user, code may merge it's own data or may
+ *  add another sub-array containing user information specific to an add-on (i.e.
+ *  contacts add-on might supply a 'contactUser' sub-array).
+ *
+ */
+if (function_exists('is_user_logged_in')) {
+    $config['loggedInUser'] = array(
+        'wpUser' => false
+    );
+    if (is_user_logged_in()) {
+        $config['loggedInUser']['wpUser'] = (array) wp_get_current_user()->data;
+    }
+    $config['loggedInUser'] = apply_filters('glm_members_current_logged_in_user', $config['loggedInUser']);
+}
+
 // Check all database tables for all registered add-ons, allow install/update
 if (glmCheckDatabase('install')) {
 
@@ -342,72 +408,6 @@ if (glmCheckDatabase('install')) {
         }
     }
 
-    /*
-     *
-     * Activate and Deactivate hooks
-     *
-     */
-
-    // Activate
-    function glmMembersPluginActivate ()
-    {
-        global $wpdb, $config;
-        require_once GLM_MEMBERS_PLUGIN_PATH . '/activate.php';
-        new glmMembersPluginActivate($wpdb, $config);
-    }
-    register_activation_hook(__FILE__, 'glmMembersPluginActivate');
-
-    // Deactivate
-    function glmMembersPluginDeactivate ()
-    {
-        global $wpdb, $config;
-        require_once GLM_MEMBERS_PLUGIN_PATH . '/deactivate.php';
-        $x = new glmMembersPluginDeactivate($wpdb, $config);
-        return false;
-    }
-    register_deactivation_hook(__FILE__, 'glmMembersPluginDeactivate');
-
-    /*
-     *
-     * Load any other common files needed
-     *
-     */
-
-    // Load data abstract
-    require_once GLM_MEMBERS_PLUGIN_LIB_PATH.'/GlmDataAbstract/DataAbstract.php';
-
-    // Load glmPluginSupport class
-    require_once GLM_MEMBERS_PLUGIN_PATH . '/classes/glmPluginSupport.php';
-
-    // Load Smarty Template Support
-    require_once GLM_MEMBERS_PLUGIN_PATH . '/lib/smartyTemplateSupport.php';
-
-    /*
-     *  Hook through which an add-on may supply additional logged in user information and
-     *  have that data stored in the config array. Typically it would be the
-     *  glm-members-db-contacts add-on supplying the information.
-     *
-     *  This hook provides default data with the current WordPress user 'data' object
-     *  as a 'wpUser' sub-array if a WordPress user is logged in. If not 'wpUser' will
-     *  be false. The supplied data is the basic information on the WordPress user
-     *  provided by the 'data' object from wp_get_current_user().
-     *
-     *  To permit more than one routine to access this filter and therefore to supply
-     *  additional information on the logged in user, code may merge it's own data or may
-     *  add another sub-array containing user information specific to an add-on (i.e.
-     *  contacts add-on might supply a 'contactUser' sub-array).
-     *
-     */
-    if (function_exists('is_user_logged_in')) {
-        $config['loggedInUser'] = array(
-            'wpUser' => false
-        );
-        if (is_user_logged_in()) {
-            $config['loggedInUser']['wpUser'] = (array) wp_get_current_user()->data;
-        }
-        $config['loggedInUser'] = apply_filters('glm_members_current_logged_in_user', $config['loggedInUser']);
-    }
-
 } // have databases
 
 /*