rework quicksite plugin
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 3 Nov 2014 20:22:37 +0000 (15:22 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 3 Nov 2014 20:22:37 +0000 (15:22 -0500)
changing the plugin name

controllers/Admin.php
controllers/Front.php
glm-client-info.php
models/Glmclientinfo_Widget.php
views/vCard.php

index 3aeccbb..0ca5b9b 100644 (file)
@@ -36,12 +36,21 @@ class Glmclientinfo_Admin_Controller
         $this->path = $path;
         add_action('admin_menu', array($this, 'glmclientinfo_add_admin_menu'));
         add_action('admin_init', array($this, 'glmclientinfo_settings_init'));
-        register_activation_hook(__FILE__, array($this, 'glmclientinfo_install_plugin_data'));
-        register_deactivation_hook(__FILE__, array($this, 'glmclientinfo_remove_plugin_data'));
-        register_uninstall_hook(__FILE__, array('Glmclientinfo_Admin_Controller', 'glmclientinfo_uninstall'));
+
+    }
+
+    static public function activate_plugin()
+    {
+        Glmclientinfo_Admin_Controller::add_capability();
+        Glmclientinfo_Admin_Controller::glm_add_state_list_option();
+    }
+
+    static public function deactivate_plugin()
+    {
+        Glmclientinfo_Admin_Controller::remove_capability();
     }
 
-    public function add_capability()
+    static public function add_capability()
     {
         $roles = get_editable_roles();
         foreach ($GLOBALS['wp_roles']->role_objects as $key => $role) {
@@ -51,7 +60,7 @@ class Glmclientinfo_Admin_Controller
         }
     }
 
-    public function remove_capability()
+    static public function remove_capability()
     {
         $roles = get_editable_roles();
         foreach ($GLOBALS['wp_roles']->role_objects as $key => $role) {
@@ -63,107 +72,99 @@ class Glmclientinfo_Admin_Controller
 
     static public function glmclientinfo_uninstall()
     {
-        delete_option('glmquicksite_settings');
-        delete_option('glmquicksite_states');
+        delete_option(GLM_CLIENTINFO_SETTINGS);
+        delete_option(GLM_CLEINTINFO_STATES);
     }
 
-    public function glmclientinfo_install_plugin_data()
+    static public function glm_add_state_list_option()
     {
-        add_capability();
-        $this->glm_add_state_list_option();
-    }
-
-    public function glm_add_state_list_option()
-    {
-        if (false == get_option('glmquicksite_states')) {
-            // [status_US] array of states and their abbr.
-            $states_US['']   = '-- Select --'; // {{{
-            $states_US['AL'] = 'Alabama';
-            $states_US['AK'] = 'Alaska';
-            $states_US['AZ'] = 'Arizona';
-            $states_US['AR'] = 'Arkansas';
-            $states_US['CA'] = 'California';
-            $states_US['CO'] = 'Colorado';
-            $states_US['CT'] = 'Connecticut';
-            $states_US['DE'] = 'Delaware';
-            $states_US['DC'] = 'District of Columbia';
-            $states_US['FL'] = 'Florida';
-            $states_US['GA'] = 'Georgia';
-            $states_US['HI'] = 'Hawaii';
-            $states_US['ID'] = 'Idaho';
-            $states_US['IL'] = 'Illinois';
-            $states_US['IN'] = 'Indiana';
-            $states_US['IA'] = 'Iowa';
-            $states_US['KS'] = 'Kansas';
-            $states_US['KY'] = 'Kentucky';
-            $states_US['LA'] = 'Louisiana';
-            $states_US['ME'] = 'Maine';
-            $states_US['MD'] = 'Maryland';
-            $states_US['MA'] = 'Massachusetts';
-            $states_US['MI'] = 'Michigan';
-            $states_US['MN'] = 'Minnesota';
-            $states_US['MS'] = 'Mississippi';
-            $states_US['MO'] = 'Missouri';
-            $states_US['MT'] = 'Montana';
-            $states_US['NE'] = 'Nebraska';
-            $states_US['NV'] = 'Nevada';
-            $states_US['NH'] = 'New Hampshire';
-            $states_US['NJ'] = 'New Jersey';
-            $states_US['NM'] = 'New Mexico';
-            $states_US['NY'] = 'New York';
-            $states_US['NC'] = 'North Carolina';
-            $states_US['ND'] = 'North Dakota';
-            $states_US['OH'] = 'Ohio';
-            $states_US['OK'] = 'Oklahoma';
-            $states_US['OR'] = 'Oregon';
-            $states_US['PA'] = 'Pennsylvania';
-            $states_US['RI'] = 'Rhode Island';
-            $states_US['SC'] = 'South Carolina';
-            $states_US['SD'] = 'South Dakota';
-            $states_US['TN'] = 'Tennessee';
-            $states_US['TX'] = 'Texas';
-            $states_US['UT'] = 'Utah';
-            $states_US['VT'] = 'Vermont';
-            $states_US['VA'] = 'Virginia';
-            $states_US['WA'] = 'Washington';
-            $states_US['WV'] = 'West Virginia';
-            $states_US['WI'] = 'Wisconsin';
-            $states_US['WY'] = 'Wyoming'; // }}}
-            // [states] extended states array
-            $states['AB']    = 'Alberta'; // {{{
-            $states['AS']    = 'American Samoa';
-            $states['BC']    = 'British Columbia';
-            $states['DC']    = 'District of Columbia';
-            $states['FM']    = 'Federated States of Micronesia';
-            $states['GU']    = 'Guam';
-            $states['MB']    = 'Manitoba';
-            $states['MH']    = 'Marshall Islands';
-            $states['NB']    = 'New Brunswick';
-            $states['NF']    = 'Newfoundland';
-            $states['MP']    = 'Northern Mariana Islands';
-            $states['NT']    = 'Northwest Territories';
-            $states['NS']    = 'Nova Scotia';
-            $states['ON']    = 'Ontario';
-            $states['PW']    = 'Palau';
-            $states['PE']    = 'Prince Edward Island';
-            $states['PR']    = 'Puerto Rico';
-            $states['QC']    = 'Quebec';
-            $states['SK']    = 'Saskatchewan';
-            $states['VI']    = 'Virgin Islands';
-            $states['YT']    = 'Yukon'; // }}}
-            //  Merge the 50 US states together with some of the extended
-            //  provinces / territories and then sort them on their keys
-            //  Then add the remaining countries and areas at the end
-            //  of the array.
-            $states          = $states_US + $states;
-            ksort($states);
-            add_option('glmquicksite_states', $states);
+        //echo 'called glm_add_state_list_option';
+        if (get_option(GLM_CLEINTINFO_STATES)) {
+            remove_option(GLM_CLEINTINFO_STATES);
         }
-    }
-
-    public function glmclientinfo_remove_plugin_data()
-    {
-        remove_capability();
+        // [status_US] array of states and their abbr.
+        $states_US['']   = '-- Select --'; // {{{
+        $states_US['AL'] = 'Alabama';
+        $states_US['AK'] = 'Alaska';
+        $states_US['AZ'] = 'Arizona';
+        $states_US['AR'] = 'Arkansas';
+        $states_US['CA'] = 'California';
+        $states_US['CO'] = 'Colorado';
+        $states_US['CT'] = 'Connecticut';
+        $states_US['DE'] = 'Delaware';
+        $states_US['DC'] = 'District of Columbia';
+        $states_US['FL'] = 'Florida';
+        $states_US['GA'] = 'Georgia';
+        $states_US['HI'] = 'Hawaii';
+        $states_US['ID'] = 'Idaho';
+        $states_US['IL'] = 'Illinois';
+        $states_US['IN'] = 'Indiana';
+        $states_US['IA'] = 'Iowa';
+        $states_US['KS'] = 'Kansas';
+        $states_US['KY'] = 'Kentucky';
+        $states_US['LA'] = 'Louisiana';
+        $states_US['ME'] = 'Maine';
+        $states_US['MD'] = 'Maryland';
+        $states_US['MA'] = 'Massachusetts';
+        $states_US['MI'] = 'Michigan';
+        $states_US['MN'] = 'Minnesota';
+        $states_US['MS'] = 'Mississippi';
+        $states_US['MO'] = 'Missouri';
+        $states_US['MT'] = 'Montana';
+        $states_US['NE'] = 'Nebraska';
+        $states_US['NV'] = 'Nevada';
+        $states_US['NH'] = 'New Hampshire';
+        $states_US['NJ'] = 'New Jersey';
+        $states_US['NM'] = 'New Mexico';
+        $states_US['NY'] = 'New York';
+        $states_US['NC'] = 'North Carolina';
+        $states_US['ND'] = 'North Dakota';
+        $states_US['OH'] = 'Ohio';
+        $states_US['OK'] = 'Oklahoma';
+        $states_US['OR'] = 'Oregon';
+        $states_US['PA'] = 'Pennsylvania';
+        $states_US['RI'] = 'Rhode Island';
+        $states_US['SC'] = 'South Carolina';
+        $states_US['SD'] = 'South Dakota';
+        $states_US['TN'] = 'Tennessee';
+        $states_US['TX'] = 'Texas';
+        $states_US['UT'] = 'Utah';
+        $states_US['VT'] = 'Vermont';
+        $states_US['VA'] = 'Virginia';
+        $states_US['WA'] = 'Washington';
+        $states_US['WV'] = 'West Virginia';
+        $states_US['WI'] = 'Wisconsin';
+        $states_US['WY'] = 'Wyoming'; // }}}
+        // [states] extended states array
+        $states['AB']    = 'Alberta'; // {{{
+        $states['AS']    = 'American Samoa';
+        $states['BC']    = 'British Columbia';
+        $states['DC']    = 'District of Columbia';
+        $states['FM']    = 'Federated States of Micronesia';
+        $states['GU']    = 'Guam';
+        $states['MB']    = 'Manitoba';
+        $states['MH']    = 'Marshall Islands';
+        $states['NB']    = 'New Brunswick';
+        $states['NF']    = 'Newfoundland';
+        $states['MP']    = 'Northern Mariana Islands';
+        $states['NT']    = 'Northwest Territories';
+        $states['NS']    = 'Nova Scotia';
+        $states['ON']    = 'Ontario';
+        $states['PW']    = 'Palau';
+        $states['PE']    = 'Prince Edward Island';
+        $states['PR']    = 'Puerto Rico';
+        $states['QC']    = 'Quebec';
+        $states['SK']    = 'Saskatchewan';
+        $states['VI']    = 'Virgin Islands';
+        $states['YT']    = 'Yukon'; // }}}
+        //  Merge the 50 US states together with some of the extended
+        //  provinces / territories and then sort them on their keys
+        //  Then add the remaining countries and areas at the end
+        //  of the array.
+        $states          = $states_US + $states;
+        ksort($states);
+        add_option(GLM_CLEINTINFO_STATES, $states);
+        //echo 'called add_option';
     }
 
     public function glmclientinfo_add_admin_menu()
@@ -172,16 +173,16 @@ class Glmclientinfo_Admin_Controller
             'Gaslight Client Info',
             'GLM Client Info',
             GLM_NEW_CAPABILITY,
-            'glmquicksite',
-            array($this, 'glmquicksite_options_page'),
+            'glmclientinfo',
+            array($this, 'glmclientinfo_options_page'),
             'dashicons-id'
         );
     }
 
     public function glmclientinfo_settings_exist()
     {
-        if (false == get_option('glmquicksite_settings')) {
-            add_option('glmquicksite_settings');
+        if (false == get_option(GLM_CLIENTINFO_SETTINGS)) {
+            add_option(GLM_CLIENTINFO_SETTINGS);
         }
     }
 
@@ -300,7 +301,7 @@ class Glmclientinfo_Admin_Controller
     {
         static $options;
         if (!$options) {
-            $options = get_option('glmclientinfo_settings');
+            $options = get_option(GLM_CLIENTINFO_SETTINGS);
         }
         include $this->path . 'views/text.php';
     }
@@ -308,15 +309,15 @@ class Glmclientinfo_Admin_Controller
     public function glmclientinfoRenderTextArea($fieldName)
     {
         static $options;
-        $options = get_option('glmclientinfo_settings');
+        $options = get_option(GLM_CLIENTINFO_SETTINGS);
         include $this->path . 'views/textArea.php';
     }
 
     public function glmclientinfoRenderStateSelect($fieldName)
     {
         static $options;
-        $options = get_option('glmclientinfo_settings');
-        $states  = get_option('glmclientinfo_states');
+        $options = get_option(GLM_CLIENTINFO_SETTINGS);
+        $states  = get_option(GLM_CLEINTINFO_STATES);
         include $this->path . 'views/stateSelect.php';
     }
 
@@ -330,7 +331,7 @@ class Glmclientinfo_Admin_Controller
         return GLM_NEW_CAPABILITY;
     }
 
-    public function glmquicksite_options_page()
+    public function glmclientinfo_options_page()
     {
         if (current_user_can(GLM_NEW_CAPABILITY)) {
             include $this->path . 'views/optionsPage.php';
index e7b51f4..5cff1a7 100644 (file)
@@ -49,7 +49,7 @@ class Glmclientinfo_Front_controller
     }
 
     /**
-     * Register the QuickSite Widget with WordPress
+     * Register the Client Info Widget with WordPress
      */
     function glmclientinfo_register_widget()
     {
index 95e57ed..2d5e650 100644 (file)
@@ -7,9 +7,15 @@
  * Author URI: http://www.gaslightmedia.com
  * License: All right reserved
  */
+define('GLM_CLIENTINFO_SETTINGS', 'glmclientinfo_settings');
+define('GLM_CLEINTINFO_STATES', 'glmclientinfo_states');
 define('GLM_NEW_CAPABILITY', 'glmclientinfo_edit_client');
 define('BUILT_IN_CAPABILITY', 'edit_posts');
 
+register_activation_hook(__FILE__, array('Glmclientinfo_Admin_Controller', 'activate_plugin'));
+register_deactivation_hook(__FILE__, array('Glmclientinfo_Admin_Controller', 'deactivate_plugin'));
+register_uninstall_hook(__FILE__, array('Glmclientinfo_Admin_Controller', 'glmclientinfo_uninstall'));
+
 // call the Admin Controller to setup the Admin of the plugin
 require_once 'controllers/Admin.php';
 $adminController = new Glmclientinfo_Admin_Controller(
index 2d0bc80..9d748e7 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 /**
- * QuickSite_Widget.php
+ * Glmclientinfo_Widget.php
  *
  * PHP version 5.3
  *
@@ -39,8 +39,8 @@ class Glmclientinfo_Widget
     public function __construct()
     {
         parent::__construct(
-            'QuickSite_Widget',
-            __('QuickSite Widget', 'text_domain'),
+            'GlmClientInfo_Widget',
+            __('Client Info Widget', 'text_domain'),
             array('description' => __('A Gaslight Widget', 'text_domain'))
         );
     }
@@ -69,7 +69,7 @@ class Glmclientinfo_Widget
      *
      * @return string Option
      */
-    function glm_get_quicksite_option($name)
+    function glm_get_clientinfo_option($name)
     {
         $settings = get_option('glmclientinfo_settings');
         $states   = get_option('glmclientinfo_states');
index 6cc5ad3..17053d2 100644 (file)
@@ -1,31 +1,31 @@
 <div class="vcard">
-<h2 class="fn org"><?php echo $this->glm_get_quicksite_option('businessName');?></h2>
-<p class="street-address"><?php echo $this->glm_get_quicksite_option('address');?></p>
+<h2 class="fn org"><?php echo $this->glm_get_clientinfo_option('businessName');?></h2>
+<p class="street-address"><?php echo $this->glm_get_clientinfo_option('address');?></p>
 <p>
-    <span flexy:if="city" class="locality"><?php echo $this->glm_get_quicksite_option('city');?>,</span>
-    <abbr class="region" title="<?php echo $this->glm_get_quicksite_option('stateFull');?>"><?php echo $this->glm_get_quicksite_option('state');?></abbr>
-    <span class="postal-code"><?php echo $this->glm_get_quicksite_option('zip');?></span>
+    <span flexy:if="city" class="locality"><?php echo $this->glm_get_clientinfo_option('city');?>,</span>
+    <abbr class="region" title="<?php echo $this->glm_get_clientinfo_option('stateFull');?>"><?php echo $this->glm_get_clientinfo_option('state');?></abbr>
+    <span class="postal-code"><?php echo $this->glm_get_clientinfo_option('zip');?></span>
 </p>
 
-<?php if ($this->glm_get_quicksite_option('address2')):?>
-<p class="street-address"><?php echo $this->glm_get_quicksite_option('address2');?></p>
+<?php if ($this->glm_get_clientinfo_option('address2')):?>
+<p class="street-address"><?php echo $this->glm_get_clientinfo_option('address2');?></p>
 <p>
-    <span flexy:if="city" class="locality"><?php echo $this->glm_get_quicksite_option('city2');?>,</span>
-    <abbr class="region" title="<?php echo $this->glm_get_quicksite_option('state2Full');?>"><?php echo $this->glm_get_quicksite_option('state2');?></abbr>
-    <span class="postal-code"><?php echo $this->glm_get_quicksite_option('zip2');?></span>
+    <span flexy:if="city" class="locality"><?php echo $this->glm_get_clientinfo_option('city2');?>,</span>
+    <abbr class="region" title="<?php echo $this->glm_get_clientinfo_option('state2Full');?>"><?php echo $this->glm_get_clientinfo_option('state2');?></abbr>
+    <span class="postal-code"><?php echo $this->glm_get_clientinfo_option('zip2');?></span>
 </p>
 <?php endif;?>
 
-<?php if ($this->glm_get_quicksite_option('phone')):?>
+<?php if ($this->glm_get_clientinfo_option('phone')):?>
 <p class="tel">
     <span class="type">phone</span>:
-    <span class="value"><?php echo $this->glm_get_quicksite_option('phone');?></span>
+    <span class="value"><?php echo $this->glm_get_clientinfo_option('phone');?></span>
 </p>
 <?php endif;?>
-<?php if ($this->glm_get_quicksite_option('fax')):?>
+<?php if ($this->glm_get_clientinfo_option('fax')):?>
 <p class="tel">
     <span class="type">fax</span>:
-    <span class="value"><?php echo $this->glm_get_quicksite_option('fax');?></span>
+    <span class="value"><?php echo $this->glm_get_clientinfo_option('fax');?></span>
 </p>
 <?php endif;?>
 </div><!-- /#address -->
\ No newline at end of file