From: Chuck Scott Date: Wed, 2 Oct 2019 19:24:53 +0000 (-0400) Subject: Implemented namespace for this plugin and fixed issues resulting from that. X-Git-Tag: v4.2.0^2~6 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=56c52ef30b5c0e3a9cf3d3c395030aedc39278ef;p=WP-Plugins%2Fglm-serverstats.git Implemented namespace for this plugin and fixed issues resulting from that. --- diff --git a/activate.php b/activate.php index e89aff1..5ebcba6 100755 --- a/activate.php +++ b/activate.php @@ -1,5 +1,5 @@ model(); // If there's a redirect request, run that (this controler can only do one level of redirect) @@ -305,7 +301,7 @@ function glmServerStatsPluginActivate () require_once GLM_SERVERSTATS_PLUGIN_PATH . '/activate.php'; new glmServerStatsPluginActivate(); } -register_activation_hook(__FILE__, 'glmServerStatsPluginActivate'); +register_activation_hook(__FILE__, '\GLMServerStats\glmServerStatsPluginActivate'); // Deactivate function glmServerStatsPluginDeactivate () @@ -314,7 +310,7 @@ function glmServerStatsPluginDeactivate () $x = new glmServerStatsPluginDeactivate(); return false; } -register_deactivation_hook(__FILE__, 'glmServerStatsPluginDeactivate'); +register_deactivation_hook(__FILE__, '\GLMServerStats\glmServerStatsPluginDeactivate'); /* * Check if we should run the target check E-mail process @@ -369,7 +365,7 @@ function doGlmServerUsageCron() { } } -add_action('glm_serverstats_notify_cron', 'doGlmServerUsageCron'); +add_action('glm_serverstats_notify_cron', '\GLMServerStats\doGlmServerUsageCron'); /* * This code sets up a once per minute cron schedule to use for testing. diff --git a/lib/opentools-update-checker/opentools-update-checker.php b/lib/opentools-update-checker/opentools-update-checker.php index 6f0b4bb..2cee653 100644 --- a/lib/opentools-update-checker/opentools-update-checker.php +++ b/lib/opentools-update-checker/opentools-update-checker.php @@ -1,4 +1,5 @@ updateChecker); } return $panels; diff --git a/lib/plugin-update-checker/github-checker.php b/lib/plugin-update-checker/github-checker.php index 7867fe6..c2d506f 100644 --- a/lib/plugin-update-checker/github-checker.php +++ b/lib/plugin-update-checker/github-checker.php @@ -1,6 +1,6 @@ =') ? '' : 'Legacy') . '.php'); } @@ -416,7 +416,7 @@ class PucGitHubChecker_3_1 extends PluginUpdateChecker_3_1 { } protected function parseReadme($content) { - if ( !class_exists('PucReadmeParser', false) ) { + if ( !class_exists('GLMServerStats\PucReadmeParser', false) ) { require_once(dirname(__FILE__) . '/vendor/readme-parser.php'); } $parser = new PucReadmeParser(); diff --git a/lib/plugin-update-checker/plugin-update-checker.php b/lib/plugin-update-checker/plugin-update-checker.php index 38760f4..b9a9852 100644 --- a/lib/plugin-update-checker/plugin-update-checker.php +++ b/lib/plugin-update-checker/plugin-update-checker.php @@ -1,4 +1,5 @@ getUpdateState(); if ( empty($state) ){ - $state = new stdClass; + $state = new \stdClass; $state->lastCheck = 0; $state->checkedVersion = ''; $state->update = null; @@ -497,7 +498,7 @@ class PluginUpdateChecker_3_1 { */ private function addUpdateToList($updates, $updateToAdd) { if ( !is_object($updates) ) { - $updates = new stdClass(); + $updates = new \stdClass(); $updates->response = array(); } @@ -541,7 +542,7 @@ class PluginUpdateChecker_3_1 { //Being defensive. if ( !is_object($updates) ) { - $updates = new stdClass(); + $updates = new \stdClass(); } if ( !isset($updates->translations) ) { $updates->translations = array(); @@ -934,7 +935,7 @@ class PluginUpdateChecker_3_1 { */ public function initDebugBarPanel() { $debugBarPlugin = dirname(__FILE__) . '/debug-bar-plugin.php'; - if ( class_exists('Debug_Bar', false) && file_exists($debugBarPlugin) ) { + if ( class_exists('GLMServerStats\Debug_Bar', false) && file_exists($debugBarPlugin) ) { /** @noinspection PhpIncludeInspection */ require_once $debugBarPlugin; $this->debugBarPlugin = new PucDebugBarPlugin_3_1($this); @@ -956,7 +957,7 @@ class PluginUpdateChecker_3_1 { endif; -if ( !class_exists('PluginInfo_3_1', false) ): +if ( !class_exists('GLMServerStats\PluginInfo_3_1', false) ): /** * A container class for holding and transforming various plugin metadata. @@ -1057,7 +1058,7 @@ class PluginInfo_3_1 { * @return object */ public function toWpFormat(){ - $info = new stdClass; + $info = new \stdClass; //The custom update API is built so that many fields have the same name and format //as those returned by the native WordPress.org API. These can be assigned directly. @@ -1098,7 +1099,7 @@ class PluginInfo_3_1 { endif; -if ( !class_exists('PluginUpdate_3_1', false) ): +if ( !class_exists('GLMServerStats\PluginUpdate_3_1', false) ): /** * A simple container class for holding information about an available update. @@ -1184,7 +1185,7 @@ class PluginUpdate_3_1 { * @return StdClass */ public function toStdClass() { - $object = new stdClass(); + $object = new \stdClass(); $fields = self::$fields; if ( !empty($this->slug) ) { $fields = apply_filters('puc_retain_fields-' . $this->slug, $fields); @@ -1204,7 +1205,7 @@ class PluginUpdate_3_1 { * @return object */ public function toWpFormat(){ - $update = new stdClass; + $update = new \stdClass; $update->id = $this->id; $update->slug = $this->slug; @@ -1224,7 +1225,7 @@ class PluginUpdate_3_1 { endif; -if ( !class_exists('PucScheduler_3_1', false) ): +if ( !class_exists('GLMServerStats\PucScheduler_3_1', false) ): /** * The scheduler decides when and how often to check for updates. @@ -1403,7 +1404,7 @@ class PucScheduler_3_1 { endif; -if ( !class_exists('PucUpgraderStatus_3_1', false) ): +if ( !class_exists('GLMServerStats\PucUpgraderStatus_3_1', false) ): /** * A utility class that helps figure out which plugin WordPress is upgrading. @@ -1548,7 +1549,7 @@ class PucUpgraderStatus_3_1 { endif; -if ( !class_exists('PucFactory', false) ): +if ( !class_exists('GLMServerStats\GLMServerStats\PucFactory', false) ): /** * A factory that builds instances of other classes from this library. diff --git a/lib/plugin-update-checker/vendor/readme-parser.php b/lib/plugin-update-checker/vendor/readme-parser.php index a861b18..9c974d6 100644 --- a/lib/plugin-update-checker/vendor/readme-parser.php +++ b/lib/plugin-update-checker/vendor/readme-parser.php @@ -237,7 +237,7 @@ Class PucReadmeParser { $text = call_user_func( array( __CLASS__, 'code_trick' ), $text, $markdown ); // A better parser than Markdown's for: backticks -> CODE if ( $markdown ) { // Parse markdown. - if ( !class_exists('Parsedown', false) ) { + if ( !class_exists('GLMServerStats\Parsedown', false) ) { require_once(dirname(__FILE__) . '/Parsedown' . (version_compare(PHP_VERSION, '5.3.0', '>=') ? '' : 'Legacy') . '.php'); } $instance = Parsedown::instance(); @@ -264,7 +264,7 @@ Class PucReadmeParser { ); $text = balanceTags($text); - + $text = wp_kses( $text, $allowed ); $text = trim($text); return $text; diff --git a/lib/smartyTemplateSupport.php b/lib/smartyTemplateSupport.php index 2d46014..534443a 100755 --- a/lib/smartyTemplateSupport.php +++ b/lib/smartyTemplateSupport.php @@ -1,5 +1,5 @@ template = new SmartyBC (); + if ( !class_exists( '\SmartyBC' ) ) { + require_once GLM_SERVERSTATS_PLUGIN_PATH.'/lib/smarty-3.1.33/libs/SmartyBC.class.php'; + } + $this->template = new \SmartyBC (); /* * Configure Smarty Templates for this site diff --git a/models/adminServerStats.php b/models/adminServerStats.php index a60c153..b2626e6 100755 --- a/models/adminServerStats.php +++ b/models/adminServerStats.php @@ -1,4 +1,5 @@ setXValues(true); $graph->setYValues(true); $graph->setMinMaxY(1); // Set minimum top value to Y axis diff --git a/models/frontCookiePopUp.php b/models/frontCookiePopUp.php index f10b66b..ee80f5c 100755 --- a/models/frontCookiePopUp.php +++ b/models/frontCookiePopUp.php @@ -1,4 +1,5 @@ ":'') - .(!empty($websiteSettings['contact_org'])?$websiteSettings['contact_org']."
":'') - .(!empty($websiteSettings['contact_address'])?$websiteSettings['contact_address']."
":'') - .(!empty($websiteSettings['contact_address2'])?$websiteSettings['contact_address2']."
":'') - .(!empty($websiteSettings['contact_city'])?$websiteSettings['contact_city']:'') - .(!empty($websiteSettings['contact_state'])?", ".$websiteSettings['contact_state']:'') - .(!empty($websiteSettings['contact_zip'])?" ".$websiteSettings['contact_zip']:'') - .(!empty($websiteSettings['contact_city'])||!empty($websiteSettings['contact_state'])||!empty($websiteSettings['contact_zip'])?"
":'') - .(!empty($websiteSettings['contact_phone'])?"
Phone: ".$websiteSettings['contact_phone']:'') - .(!empty($websiteSettings['contact_email'])?"
E-Mail: ".$websiteSettings['contact_email']:''); -} -add_shortcode( 'policy_contact', 'policy_contact_shortcode' ); + (!empty($websiteSettings['contact_name'])?$websiteSettings['contact_name']."
":'') + .(!empty($websiteSettings['contact_org'])?$websiteSettings['contact_org']."
":'') + .(!empty($websiteSettings['contact_address'])?$websiteSettings['contact_address']."
":'') + .(!empty($websiteSettings['contact_address2'])?$websiteSettings['contact_address2']."
":'') + .(!empty($websiteSettings['contact_city'])?$websiteSettings['contact_city']:'') + .(!empty($websiteSettings['contact_state'])?", ".$websiteSettings['contact_state']:'') + .(!empty($websiteSettings['contact_zip'])?" ".$websiteSettings['contact_zip']:'') + .(!empty($websiteSettings['contact_city'])||!empty($websiteSettings['contact_state'])||!empty($websiteSettings['contact_zip'])?"
":'') + .(!empty($websiteSettings['contact_phone'])?"
Phone: ".$websiteSettings['contact_phone']:'') + .(!empty($websiteSettings['contact_email'])?"
E-Mail: ".$websiteSettings['contact_email']:''); +}); diff --git a/setup/standardTemplateParams.php b/setup/standardTemplateParams.php index 4fc99a6..5d286e8 100644 --- a/setup/standardTemplateParams.php +++ b/setup/standardTemplateParams.php @@ -1,4 +1,5 @@