From 034edda9d2cb12a612478207a436548508bf6084 Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Tue, 16 May 2017 12:19:32 -0400 Subject: [PATCH] Moved activate/deactivate, require support files, and user logged in hook from glmCheckDatabase call success block. This solves support files not being loaded if a database doesn't check properly under certain situations. --- index.php | 132 +++++++++++++++++++++++++++--------------------------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/index.php b/index.php index 4d8c5435..e71592c0 100644 --- 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 /* -- 2.17.1