Breaking plugin up master
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 3 Nov 2014 17:05:10 +0000 (12:05 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 3 Nov 2014 17:05:10 +0000 (12:05 -0500)
MVC for plugin
controllers
admin and front controllers
models
for the widget
views
view files any and all html is in view files

GlmQuickSite.php
controllers/Admin.php [new file with mode: 0644]
controllers/Front.php [new file with mode: 0644]
models/QuickSite_Widget.php [new file with mode: 0644]
views/deniedAccess.php [new file with mode: 0644]
views/optionsPage.php [new file with mode: 0644]
views/stateSelect.php [new file with mode: 0644]
views/text.php [new file with mode: 0644]
views/textArea.php [new file with mode: 0644]
views/vCard.php [new file with mode: 0644]

index a747f80..9dedfce 100644 (file)
  */
 define('GLM_NEW_CAPABILITY', 'glmquicksite_edit_client');
 define('BUILT_IN_CAPABILITY', 'edit_posts');
-add_action( 'admin_menu', 'glmQuickSite_add_admin_menu' );
-add_action( 'admin_init', 'glmQuickSite_settings_init' );
-register_activation_hook(__FILE__, 'glmQuickSite_install_plugin_data');
-register_deactivation_hook(__FILE__, 'glmQuickSite_remove_plugin_data');
 
-function add_capability() {
-    $roles = get_editable_roles();
-    foreach ($GLOBALS['wp_roles']->role_objects as $key => $role) {
-        if (isset($roles[$key]) && $role->has_cap(BUILT_IN_CAPABILITY)) {
-            $role->add_cap(GLM_NEW_CAPABILITY);
-        }
-    }
-}
-
-function remove_capability() {
-    $roles = get_editable_roles();
-    foreach ($GLOBALS['wp_roles']->role_objects as $key => $role) {
-        if (isset($roles[$key]) && $role->has_cap(GLM_NEW_CAPABILITY)) {
-            $role->remove_cap(GLM_NEW_CAPABILITY);
-        }
-    }
-}
-
-function glmQuickSite_install_plugin_data(){
-    add_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( 'glmquicksite_states', $states );
-}
-
-function glmQuickSite_remove_plugin_data() {
-    remove_capability();
-    delete_option( 'glmquicksite_settings' );
-    delete_option( 'glmquicksite_states' );
-
-}
-
-function glmQuickSite_add_admin_menu(  ) {
-
-    add_menu_page(
-        'Gaslight Client Info',
-        'GLM Client Info',
-        GLM_NEW_CAPABILITY,
-        'glmquicksite',
-        'glmquicksite_options_page',
-        'dashicons-id'
-    );
-
-}
-
-
-function glmQuickSite_settings_exist(  ) {
-
-    if( false == get_option( 'glmquicksite_settings' ) ) {
-
-        add_option( 'glmquicksite_settings' );
-
-    }
-
-}
-
-function glmQuickSiteAddSettingTextField($name, $label, $type) {
-    switch ($type) {
-    case 'text':
-        $callback = 'glmQuickSiteRenderText';
-        break;
-    case 'textarea':
-        $callback = 'glmQuickSiteRenderTextArea';
-        break;
-    case 'state':
-        $callback = 'glmQuickSiteRenderStateSelect';
-        break;
-    default:
-        return false;
-        break;
-    }
-    add_settings_field(
-        $name,
-        __( $label, 'wordpress' ),
-        $callback,
-        'pluginPage',
-        'glmQuickSite_pluginPage_section',
-        $name
-    );
-}
-
-
-function glmQuickSite_settings_init(  ) {
-    register_setting( 'pluginPage', 'glmQuickSite_settings' );
-    add_filter('option_page_capability_pluginPage', 'glmQuickSite_option_page_capability');
-
-    add_settings_section(
-        'glmQuickSite_pluginPage_section',
-        __( 'Edit your Client Info', 'wordpress' ),
-        'glmQuickSite_settings_section_callback',
-        'pluginPage'
-    );
-
-    $fieldNames = array(
-        array(
-            'name'  => 'businessName',
-            'label' => 'Business Name',
-            'type'  => 'text'
-        ),
-        array(
-            'name'  => 'address',
-            'label' => 'Address',
-            'type'  => 'text'
-        ),
-        array(
-            'name'  => 'city',
-            'label' => 'City',
-            'type'  => 'text'
-        ),
-        array(
-            'name'  => 'state',
-            'label' => 'State',
-            'type'  => 'state'
-        ),
-        array(
-            'name'  => 'zip',
-            'label' => 'Zip',
-            'type'  => 'text'
-        ),
-        array(
-            'name'  => 'address2',
-            'label' => 'Address 2',
-            'type'  => 'text'
-        ),
-        array(
-            'name'  => 'city2',
-            'label' => 'City 2',
-            'type'  => 'text'
-        ),
-        array(
-            'name'  => 'state2',
-            'label' => 'State 2',
-            'type'  => 'state'
-        ),
-        array(
-            'name'  => 'zip2',
-            'label' => 'Zip 2',
-            'type'  => 'text'
-        ),
-        array(
-            'name'  => 'phone',
-            'label' => 'Phone',
-            'type'  => 'text'
-        ),
-        array(
-            'name'  => 'fax',
-            'label' => 'Fax',
-            'type'  => 'text'
-        ),
-        array(
-            'name'  => 'extra',
-            'label' => 'Extra Content',
-            'type'  => 'textarea'
-        ),
-    );
-
-    foreach ($fieldNames as $field) {
-        glmQuickSiteAddSettingTextField($field['name'], $field['label'], $field['type']);
-    }
-}
-
-function glmQuickSiteRenderText($fieldName) {
-    static $options;
-    if (!$options) {
-        $options = get_option( 'glmQuickSite_settings' );
-    }
-?>
-    <input type="text" name="glmQuickSite_settings[<?php echo $fieldName;?>]"
-           value="<?php echo str_replace('"', '&quote;', $options[$fieldName]); ?>">
-<?php
-}
-
-function glmQuickSiteRenderTextArea($fieldName) {
-    static $options;
-    $options = get_option( 'glmQuickSite_settings' );
-?>
-    <textarea cols="40" rows="5" name="glmQuickSite_settings[<?php echo $fieldName;?>]"><?php echo htmlspecialchars($options[$fieldName]); ?></textarea>
-<?php
-}
-
-function glmQuickSiteRenderStateSelect($fieldName) {
-    static $options;
-    $options = get_option( 'glmQuickSite_settings' );
-    $states = get_option( 'glmQuickSite_states' );
-?>
-    <select name="glmQuickSite_settings[<?php echo $fieldName;?>]">
-    <?php foreach ($states as $stateAbbr => $stateName) :?>
-        <option value="<?php echo $stateAbbr;?>"<?php if ($options[$fieldName] == $stateAbbr) {echo ' selected';};?>>
-        <?php echo $stateName;?>
-        </option>
-    <?php endforeach;?>
-    </select>
-<?php
-}
-
-
-function glmQuickSite_settings_section_callback(  ) {
-
-    echo __( 'Business Name, Address and phone numbers', 'wordpress' );
-
-}
-
-function glmQuickSite_option_page_capability($capability) {
-    return GLM_NEW_CAPABILITY;
-}
-
-function glmquicksite_options_page(  ) {
-    if (current_user_can(GLM_NEW_CAPABILITY)) {
-?>
-<div class="wrap">
-
-    <form action='options.php' method='post'>
-
-        <h2>GLM Client Info</h2>
-
-<?php
-    settings_fields( 'pluginPage' );
-    do_settings_sections( 'pluginPage' );
-    submit_button();
-?>
-
-    </form>
-</div>
-<?php
-    } else {
-        ?>
-    <div class="wrap"><p>You do not have permission to edit Client Info</p></div>
-        <?php
-    }
-}
-
-?>
+// call the Admin Controller to setup the Admin of the plugin
+require_once 'controllers/Admin.php';
+$adminController = new QuickSite_Admin_Controller(
+    plugin_dir_path(__FILE__)
+);
+
+// call the Front Controller to setup the widget
+require_once 'controllers/Front.php';
+$frontController = new QuickSite_Front_controller(
+    plugin_dir_path(__FILE__)
+);
diff --git a/controllers/Admin.php b/controllers/Admin.php
new file mode 100644 (file)
index 0000000..d074919
--- /dev/null
@@ -0,0 +1,338 @@
+<?php
+
+/**
+ * Admin.php
+ *
+ * PHP version 5.3
+ *
+ * @category  Toolkit
+ * @package   Package
+ * @author    Steve Sutton <steve@gaslightmedia.com>
+ * @copyright 2013 Gaslight Media
+ * @license   Gaslight Media
+ * @version   SVN: (0.1)
+ * @link      <>
+ */
+
+/**
+ * Toolkit_Package_Admin
+ *
+ * Description of Admin
+ *
+ * @category  Toolkit
+ * @package   Package
+ * @author    Steve Sutton <steve@gaslightmedia.com>
+ * @copyright 2013 Gaslight Media
+ * @license   Gaslight Media
+ * @release   Release: (0.1)
+ * @link      <>
+ */
+class QuickSite_Admin_Controller
+{
+    public $path;
+
+    public function __construct($path)
+    {
+        $this->path = $path;
+        add_action('admin_menu', array($this, 'glmQuickSite_add_admin_menu'));
+        add_action('admin_init', array($this, 'glmQuickSite_settings_init'));
+        register_activation_hook(__FILE__, array($this, 'glmQuickSite_install_plugin_data'));
+        register_deactivation_hook(__FILE__, array($this, 'glmQuickSite_remove_plugin_data'));
+    }
+
+    public function add_capability()
+    {
+        $roles = get_editable_roles();
+        foreach ($GLOBALS['wp_roles']->role_objects as $key => $role) {
+            if (isset($roles[$key]) && $role->has_cap(BUILT_IN_CAPABILITY)) {
+                $role->add_cap(GLM_NEW_CAPABILITY);
+            }
+        }
+    }
+
+    public function remove_capability()
+    {
+        $roles = get_editable_roles();
+        foreach ($GLOBALS['wp_roles']->role_objects as $key => $role) {
+            if (isset($roles[$key]) && $role->has_cap(GLM_NEW_CAPABILITY)) {
+                $role->remove_cap(GLM_NEW_CAPABILITY);
+            }
+        }
+    }
+
+    public function glmQuickSite_install_plugin_data()
+    {
+        add_capability();
+        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);
+        }
+    }
+
+    public function glmQuickSite_remove_plugin_data()
+    {
+        remove_capability();
+    }
+
+    public function glmQuickSite_uninstall()
+    {
+        delete_option('glmquicksite_settings');
+        delete_option('glmquicksite_states');
+    }
+
+    public function glmQuickSite_add_admin_menu()
+    {
+        add_menu_page(
+            'Gaslight Client Info',
+            'GLM Client Info',
+            GLM_NEW_CAPABILITY,
+            'glmquicksite',
+            array($this, 'glmquicksite_options_page'),
+            'dashicons-id'
+        );
+    }
+
+    public function glmQuickSite_settings_exist()
+    {
+        if (false == get_option('glmquicksite_settings')) {
+            add_option('glmquicksite_settings');
+        }
+    }
+
+    public function glmQuickSiteAddSettingTextField($name, $label, $type)
+    {
+        switch ($type) {
+            case 'text':
+                $callback = 'glmQuickSiteRenderText';
+                break;
+            case 'textarea':
+                $callback = 'glmQuickSiteRenderTextArea';
+                break;
+            case 'state':
+                $callback = 'glmQuickSiteRenderStateSelect';
+                break;
+            default:
+                return false;
+                break;
+        }
+        add_settings_field(
+            $name,
+            __($label, 'wordpress'),
+            array($this, $callback),
+            'pluginPage',
+            'glmQuickSite_pluginPage_section',
+            $name
+        );
+    }
+
+    public function glmQuickSite_settings_init()
+    {
+        register_setting('pluginPage', 'glmQuickSite_settings');
+        add_filter('option_page_capability_pluginPage',
+                   'glmQuickSite_option_page_capability');
+
+        add_settings_section(
+            'glmQuickSite_pluginPage_section',
+            __('Edit your Client Info', 'wordpress'),
+            array($this, 'glmQuickSite_settings_section_callback'),
+            'pluginPage'
+        );
+
+        $fieldNames = array(
+            array(
+                'name'  => 'businessName',
+                'label' => 'Business Name',
+                'type'  => 'text'
+            ),
+            array(
+                'name'  => 'address',
+                'label' => 'Address',
+                'type'  => 'text'
+            ),
+            array(
+                'name'  => 'city',
+                'label' => 'City',
+                'type'  => 'text'
+            ),
+            array(
+                'name'  => 'state',
+                'label' => 'State',
+                'type'  => 'state'
+            ),
+            array(
+                'name'  => 'zip',
+                'label' => 'Zip',
+                'type'  => 'text'
+            ),
+            array(
+                'name'  => 'address2',
+                'label' => 'Address 2',
+                'type'  => 'text'
+            ),
+            array(
+                'name'  => 'city2',
+                'label' => 'City 2',
+                'type'  => 'text'
+            ),
+            array(
+                'name'  => 'state2',
+                'label' => 'State 2',
+                'type'  => 'state'
+            ),
+            array(
+                'name'  => 'zip2',
+                'label' => 'Zip 2',
+                'type'  => 'text'
+            ),
+            array(
+                'name'  => 'phone',
+                'label' => 'Phone',
+                'type'  => 'text'
+            ),
+            array(
+                'name'  => 'fax',
+                'label' => 'Fax',
+                'type'  => 'text'
+            ),
+            array(
+                'name'  => 'extra',
+                'label' => 'Extra Content',
+                'type'  => 'textarea'
+            ),
+        );
+
+        foreach ($fieldNames as $field) {
+            $this->glmQuickSiteAddSettingTextField($field['name'], $field['label'],
+                                            $field['type']);
+        }
+    }
+
+    public function glmQuickSiteRenderText($fieldName)
+    {
+        static $options;
+        if (!$options) {
+            $options = get_option('glmQuickSite_settings');
+        }
+        include $this->path . 'views/text.php';
+    }
+
+    public function glmQuickSiteRenderTextArea($fieldName)
+    {
+        static $options;
+        $options = get_option('glmQuickSite_settings');
+        include $this->path . 'views/textArea.php';
+    }
+
+    public function glmQuickSiteRenderStateSelect($fieldName)
+    {
+        static $options;
+        $options = get_option('glmQuickSite_settings');
+        $states  = get_option('glmQuickSite_states');
+        include $this->path . 'views/stateSelect.php';
+    }
+
+    public function glmQuickSite_settings_section_callback()
+    {
+        echo __('Business Name, Address and phone numbers', 'wordpress');
+    }
+
+    public function glmQuickSite_option_page_capability($capability)
+    {
+        return GLM_NEW_CAPABILITY;
+    }
+
+    public function glmquicksite_options_page()
+    {
+        if (current_user_can(GLM_NEW_CAPABILITY)) {
+            include $this->path . 'views/optionsPage.php';
+        } else {
+            include $this->path . 'views/deniedAccess.php';
+        }
+    }
+
+}
diff --git a/controllers/Front.php b/controllers/Front.php
new file mode 100644 (file)
index 0000000..a180138
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+
+/**
+ * Front.php
+ *
+ * PHP version 5.3
+ *
+ * @category  Toolkit
+ * @package   Package
+ * @author    Steve Sutton <steve@gaslightmedia.com>
+ * @copyright 2013 Gaslight Media
+ * @license   Gaslight Media
+ * @version   SVN: (0.1)
+ * @link      <>
+ */
+
+/**
+ * Toolkit_Package_Front
+ *
+ * Description of Front
+ *
+ * @category  Toolkit
+ * @package   Package
+ * @author    Steve Sutton <steve@gaslightmedia.com>
+ * @copyright 2013 Gaslight Media
+ * @license   Gaslight Media
+ * @release   Release: (0.1)
+ * @link      <>
+ */
+class QuickSite_Front_controller
+{
+
+    /**
+     * Plugin Path
+     * 
+     * @var type String
+     */
+    public $path;
+
+    /**
+     * Initializes Front Controller class
+     *
+     * @param type $path Plugin path
+     */
+    function __construct($path)
+    {
+        $this->path = $path;
+        add_action('widgets_init', array($this, 'glmQuickSite_register_widget'));
+    }
+
+    /**
+     * Register the QuickSite Widget with WordPress
+     */
+    function glmQuickSite_register_widget()
+    {
+        include $this->path . 'models/QuickSite_Widget.php';
+        register_widget('QuickSite_Widget');
+    }
+
+}
diff --git a/models/QuickSite_Widget.php b/models/QuickSite_Widget.php
new file mode 100644 (file)
index 0000000..4a634da
--- /dev/null
@@ -0,0 +1,87 @@
+<?php
+
+/**
+ * QuickSite_Widget.php
+ *
+ * PHP version 5.3
+ *
+ * @category  Toolkit
+ * @package   Package
+ * @author    Steve Sutton <steve@gaslightmedia.com>
+ * @copyright 2013 Gaslight Media
+ * @license   Gaslight Media
+ * @version   SVN: (0.1)
+ * @link      <>
+ */
+
+/**
+ * Toolkit_Package_QuickSite_Widget
+ *
+ * Description of QuickSite_Widget
+ *
+ * @category  Toolkit
+ * @package   Package
+ * @author    Steve Sutton <steve@gaslightmedia.com>
+ * @copyright 2013 Gaslight Media
+ * @license   Gaslight Media
+ * @release   Release: (0.1)
+ * @link      <>
+ */
+class QuickSite_Widget
+    extends WP_widget
+{
+
+    private $pluginDirPath;
+
+    /**
+     * Class Initializer
+     */
+    public function __construct()
+    {
+        parent::__construct(
+            'QuickSite_Widget',
+            __('QuickSite Widget', 'text_domain'),
+            array('description' => __('A Gaslight Widget', 'text_domain'))
+        );
+    }
+
+    /**
+     * Output widget
+     *
+     * Includes the template file for the widget.
+     * Template file is plain old php for your fastest template engine yet!
+     *
+     * @param type $args     Widget Args
+     * @param type $instance Widget Instance
+     *
+     * @return string
+     */
+    public function widget($args, $instance)
+    {
+        $path = plugin_dir_path(__FILE__);
+        include $path . '../views/vCard.php';
+    }
+
+    /**
+     * Return the quicksite option for the given key
+     *
+     * @param type $name Name of the quicksite option to return
+     *
+     * @return string Option
+     */
+    function glm_get_quicksite_option($name)
+    {
+        $settings = get_option('glmQuickSite_settings');
+        $states   = get_option('glmQuickSite_states');
+        if ($name == 'stateFull' && $settings['state']) {
+            return $states[$settings['state']];
+        }
+        if ($name == 'state2Full' && $settings['state2']) {
+            return $states[$settings['state2']];
+        }
+        return ($settings && $settings[$name])
+            ? $settings[$name]
+            : null;
+    }
+
+}
diff --git a/views/deniedAccess.php b/views/deniedAccess.php
new file mode 100644 (file)
index 0000000..d8b6753
--- /dev/null
@@ -0,0 +1 @@
+<div class="wrap"><p>You do not have permission to edit Client Info</p></div>
\ No newline at end of file
diff --git a/views/optionsPage.php b/views/optionsPage.php
new file mode 100644 (file)
index 0000000..ffb53f5
--- /dev/null
@@ -0,0 +1,10 @@
+<div class="wrap">
+    <form action="options.php" method="post">
+        <h2>Gaslight Client Info</h2>
+        <?php
+            settings_fields('pluginPage');
+            do_settings_sections('pluginPage');
+            submit_button();
+        ?>
+    </form>
+</div>
\ No newline at end of file
diff --git a/views/stateSelect.php b/views/stateSelect.php
new file mode 100644 (file)
index 0000000..c561bd6
--- /dev/null
@@ -0,0 +1,9 @@
+<select name="glmQuickSite_settings[<?php echo $fieldName; ?>]">
+    <?php foreach ($states as $stateAbbr => $stateName) : ?>
+        <option value="<?php echo $stateAbbr; ?>"<?php if ($options[$fieldName] == $stateAbbr) {
+        echo ' selected';
+    }; ?>>
+        <?php echo $stateName; ?>
+        </option>
+<?php endforeach; ?>
+</select>
\ No newline at end of file
diff --git a/views/text.php b/views/text.php
new file mode 100644 (file)
index 0000000..61473f8
--- /dev/null
@@ -0,0 +1,2 @@
+<input type="text" name="glmQuickSite_settings[<?php echo $fieldName;?>]"
+           value="<?php echo str_replace('"', '&quote;', $options[$fieldName]); ?>">
\ No newline at end of file
diff --git a/views/textArea.php b/views/textArea.php
new file mode 100644 (file)
index 0000000..cb8ba6a
--- /dev/null
@@ -0,0 +1 @@
+<textarea cols="40" rows="5" name="glmQuickSite_settings[<?php echo $fieldName;?>]"><?php echo htmlspecialchars($options[$fieldName]); ?></textarea>
\ No newline at end of file
diff --git a/views/vCard.php b/views/vCard.php
new file mode 100644 (file)
index 0000000..6cc5ad3
--- /dev/null
@@ -0,0 +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>
+<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>
+</p>
+
+<?php if ($this->glm_get_quicksite_option('address2')):?>
+<p class="street-address"><?php echo $this->glm_get_quicksite_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>
+</p>
+<?php endif;?>
+
+<?php if ($this->glm_get_quicksite_option('phone')):?>
+<p class="tel">
+    <span class="type">phone</span>:
+    <span class="value"><?php echo $this->glm_get_quicksite_option('phone');?></span>
+</p>
+<?php endif;?>
+<?php if ($this->glm_get_quicksite_option('fax')):?>
+<p class="tel">
+    <span class="type">fax</span>:
+    <span class="value"><?php echo $this->glm_get_quicksite_option('fax');?></span>
+</p>
+<?php endif;?>
+</div><!-- /#address -->
\ No newline at end of file