Fixed issues with deactivate/reactivate and crases on some searches
authorChuck Scott <cscott@gaslightmedia.com>
Mon, 26 Oct 2015 20:20:14 +0000 (16:20 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Mon, 26 Oct 2015 20:20:14 +0000 (16:20 -0400)
activate.php
classes/glmPluginSupport.php
controllers/admin.php
controllers/front.php
deactivate.php
defines.php
glm-member-db.php
lib/smartyTemplateSupport.php
uninstall.php

index db1fa88..21f340a 100644 (file)
  * @link     http://dev.gaslightmedia.com/
  */
 
+// Check that we're being called by WordPress.
+if (!defined('ABSPATH')) {
+    die("Please do not call this code directly!");
+}
+
 // Load glmPluginSupport class
 require_once (GLM_MEMBERS_PLUGIN_PATH . '/classes/glmPluginSupport.php');
 
@@ -55,6 +60,11 @@ class glmMembersPluginActivate extends glmPluginSupport
         // This line is for dropping the currrent database version for testing
         // delete_option('glmMembersDatabaseDbVersion');
 
+        // Check if there was an error and WP is calling us again
+        if ($this->checkErrorScrape()) {
+            exit;
+        }
+
         // Make sure the current user has this capability
         if (! current_user_can('activate_plugins')) {
             $this->addNotice("Interesting, you don't have permission to activate plugins.");
@@ -69,8 +79,6 @@ class glmMembersPluginActivate extends glmPluginSupport
 
         if (!$noDatabaseCheck) {
 
-            $this->checkErrorScrape();
-
             // Check the database and permit installation of a new database if it doesn't exist;
             if (!$this->checkDatabase('install')) {
 
index a1d0c9b..50cf02e 100644 (file)
@@ -164,15 +164,19 @@ class GlmPluginSupport
             } else {
 
                 $installErrors = get_option('glmMembersInstallErrors');
-                echo 'There has been an unknown error installing the Gaslight Media Members Database plugin.<p>'.$installErrors;
+                echo 'There has been an unknown error with the Gaslight Media Members Database plugin.<p>'.$installErrors;
+                delete_option('glmMembersInstallErrors');
+
 
             }
 
             // Quit here so Wordpress doesn't mark plugin as activated or deactivated
-            exit;
+            return true;
 
         }
 
+        return false;
+
     }
 
     /*
@@ -187,7 +191,6 @@ class GlmPluginSupport
     public function checkDatabase ($option = false)
     {
 
-
         $dbVersion = get_option('glmMembersDatabaseDbVersion');
         $db_setup_status = false;
 
@@ -207,7 +210,8 @@ class GlmPluginSupport
             $existingTables = $this->wpdb->get_var("
                 SELECT COUNT(*)
                   FROM information_schema.tables
-                 WHERE table_name like '".GLM_MEMBERS_PLUGIN_DB_PREFIX."%';
+                 WHERE  table_schema = 'explorewesternup'
+                   AND table_name like '".GLM_MEMBERS_PLUGIN_DB_PREFIX."%';
             ");
 
             // If there's no tables, just assume we need to install all new ones.
@@ -226,7 +230,7 @@ class GlmPluginSupport
 
         // If glmMembersDatabaseDbVersion is not set, install current version
         if (!$dbVersion) {
-
+echo "111";
             // If $option is not 'install', then don't do it;
             if ($option != 'install') {
                 return false;
@@ -273,7 +277,7 @@ class GlmPluginSupport
 
         // Otherwise, check if we need to update the database
         } elseif ($dbVersion != GLM_MEMBERS_PLUGIN_DB_VERSION) {
-
+echo "222";
             // Include an admin message that we're updating the database
             $this->addNotice('<b>The '.GLM_MEMBERS_PLUGIN_NAME.' database tables require updating...</b>');
 
@@ -361,8 +365,8 @@ class GlmPluginSupport
             }
 
         } else {
-//            $this->addNotice('The '.GLM_MEMBERS_PLUGIN_NAME.' has been reactivated using the existing database tables.');
-//            $db_setup_status = true;
+            $this->addNotice('The '.GLM_MEMBERS_PLUGIN_NAME.' has been reactivated using the existing database tables.');
+            $db_setup_status = true;
         }
 
         return $db_setup_status;
index ca31c6b..b5fa09a 100644 (file)
@@ -74,7 +74,7 @@ $GLOBALS['glmMembersAdminValidActions'] = array(
 require_once (GLM_MEMBERS_PLUGIN_PATH . '/classes/glmPluginSupport.php');
 
 // Load Smarty Template Support
-require (GLM_MEMBERS_PLUGIN_PATH . '/lib/smartyTemplateSupport.php');
+require_once (GLM_MEMBERS_PLUGIN_PATH . '/lib/smartyTemplateSupport.php');
 
 /**
  * Admin Controller Class
index 68cc9a7..3bab226 100644 (file)
@@ -41,6 +41,9 @@ $GLOBALS['glmMembersFrontValidActions'] = array(
 // 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');
+
 /*
  * This class controls which models are use for front-end functionality
  * of this plugin.
@@ -453,7 +456,6 @@ class glmMembersFront extends GlmPluginSupport
          */
 
         // Load Smarty Template support
-        require (GLM_MEMBERS_PLUGIN_PATH . '/lib/smartyTemplateSupport.php');
         $smarty = new smartyTemplateSupport();
 
         // Add standard parameters
index ed14770..6d62b89 100644 (file)
  * @link     http://dev.gaslightmedia.com/
  */
 
+// Check that we're being called by WordPress.
+if (!defined('ABSPATH')) {
+    die("Please do not call this code directly!");
+}
+
 // Load glmPluginSupport class
 require_once (GLM_MEMBERS_PLUGIN_PATH . '/classes/glmPluginSupport.php');
 
@@ -52,6 +57,12 @@ class glmMembersPluginDeactivate extends glmPluginSupport
             die();
         }
 
+        // Check if there was an error and WP is calling us again
+        if ($this->checkErrorScrape()) {
+            exit;
+        }
+
+
         // Save WordPress Database object
         $this->wpdb = $wpdb;
 
index 6ae6206..714cd30 100644 (file)
@@ -28,13 +28,12 @@ define('GLM_MEMBERS_PLUGIN_HTTP_PROTOCOL', $pageProtocol);
 $urlParts = parse_url(get_bloginfo('url'));
 $pageUri = explode('?', $_SERVER['REQUEST_URI']);               // Bust this up to access URL path and script name only
 
-$adminURL = admin_url('admin.php');
 $WPUploadDir = wp_upload_dir();
 
 // URLs
-define('GLM_MEMBERS_SITE_BASE_URL', $pageProtocol.'://'.$urlParts['host'].$urlParts['path'].'/');
-define('GLM_MEMBERS_PLUGIN_ADMIN_URL', $adminURL);
+define('GLM_MEMBERS_SITE_BASE_URL', home_url('/') );
 define('GLM_MEMBERS_PLUGIN_URL', plugin_dir_url(__FILE__));
+define('GLM_MEMBERS_PLUGIN_ADMIN_URL', admin_url('admin.php'));
 define('GLM_MEMBERS_PLUGIN_BASE_URL', WP_PLUGIN_URL.'/'.GLM_MEMBERS_PLUGIN_DIR);
 define('GLM_MEMBERS_PLUGIN_CURRENT_URL', $urlParts['scheme'].'://'.$urlParts['host'].$pageUri[0]);
 define('GLM_MEMBERS_PLUGIN_MEDIA_URL', $WPUploadDir['baseurl'].'/'.GLM_MEMBERS_PLUGIN_DIR);
index abbee61..2e5871a 100644 (file)
@@ -181,6 +181,11 @@ define('GLM_MEMBERS_PLUGIN_DB_VERSION', '1.0.30');
  * ********************************************************************************
  */
 
+// Check that we're being called by WordPress.
+if (!defined('ABSPATH')) {
+    die("Please do not call this code directly!");
+}
+
 /*
  * Some initial setup and tests
  */
index e4e926f..5163c4b 100644 (file)
@@ -29,6 +29,7 @@
  * new smartyTemplateSupport();
  *
  */
+
 class smartyTemplateSupport {
 
        /**
index a18599f..49ffa27 100644 (file)
  * @link     http://dev.gaslightmedia.com/
  */
 
-// Get setup and configuration
-require_once('defines.php');
+// Check that we're being called by WordPress.
+if (!defined('ABSPATH')) {
+    die("Please do not call this code directly!");
+}
 
 //if uninstall not called from WordPress exit
-if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
-    exit();
+if (!defined('WP_UNINSTALL_PLUGIN')) {
+    die("Sorry, uninstall must be called by WordPress!");
+}
+
+// Get setup and configuration
+require_once('defines.php');
 
 // Delete options
 delete_option('glmMembersDatabasePluginVersion');