Added fields, separated address 1 from 2
authorLaury GvR <laury@gaslightmedia.com>
Wed, 1 Jun 2016 18:09:02 +0000 (14:09 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Wed, 1 Jun 2016 18:09:02 +0000 (14:09 -0400)
controllers/Admin.php
css/admin/admin.css [new file with mode: 0644]
glm-client-info.php
js/admin/admin.js [new file with mode: 0644]
views/optionsPage.php
views/vCard.php

index 10fe3f4..be4df3d 100644 (file)
@@ -36,6 +36,8 @@ 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'));
+        add_action('wp_enqueue_scripts', array($this, 'load_stylesheet'));
+        add_action('wp_enqueue_scripts', array($this, 'load_script'));
 
     }
 
@@ -186,7 +188,7 @@ class Glmclientinfo_Admin_Controller
         }
     }
 
-    public function glmclientinfoAddSettingTextField($name, $label, $type)
+    public function glmclientinfoAddSettingTextField($name, $label, $type, $clientInfoSection)
     {
         switch ($type) {
             case 'text':
@@ -206,33 +208,55 @@ class Glmclientinfo_Admin_Controller
             $name,
             __($label, 'wordpress'),
             array($this, $callback),
-            'pluginPage',
-            'glmclientinfo_pluginPage_section',
+            $clientInfoSection,
+            'glmclientinfo_clientInfoPrimary_section',
             $name
         );
     }
 
     public function glmclientinfo_settings_init()
     {
-        register_setting('pluginPage', 'glmclientinfo_settings');
+        register_setting('clientInfoPrimary', 'glmclientinfo_settings');
         add_filter(
-            'option_page_capability_pluginPage',
+            'option_page_capability_clientInfoPrimary',
+            array($this, 'glmclientinfo_option_page_capability')
+        );
+        register_setting('clientInfoSecondary', 'glmclientinfo_settings');
+        add_filter(
+            'option_page_capability_clientInfoPrimary',
+            array($this, 'glmclientinfo_option_page_capability')
+        );
+        register_setting('clientBusinessName', 'glmclientinfo_settings');
+        add_filter(
+            'option_page_capability_clientInfoPrimary',
             array($this, 'glmclientinfo_option_page_capability')
         );
 
         add_settings_section(
-            'glmclientinfo_pluginPage_section',
-            __('Edit your Client Info', 'wordpress'),
+            'glmclientinfo_clientInfoPrimary_section',
+            __('Edit Primary Client Info', 'wordpress'),
             array($this, 'glmclientinfo_settings_section_callback'),
-            'pluginPage'
+            'clientInfoPrimary'
         );
-
+        add_settings_section(
+            'glmclientinfo_clientInfoPrimary_section',
+            __('Edit Secondary Client Info', 'wordpress'),
+            array($this, 'glmclientinfo_settings_section_callback'),
+            'clientInfoSecondary'
+        );
+        add_settings_section(
+            'glmclientinfo_clientInfoPrimary_section',
+            __('Edit Client Business Name', 'wordpress'),
+            array($this, 'glmclientinfo_settings_section_callback'),
+            'clientBusinessName'
+        );
+        $businessName = array(
+            'name'  => 'businessName',
+            'label' => 'Business Name',
+            'type'  => 'text'
+        );
+        
         $fieldNames = array(
-            array(
-                'name'  => 'businessName',
-                'label' => 'Business Name',
-                'type'  => 'text'
-            ),
             array(
                 'name'  => 'address',
                 'label' => 'Address',
@@ -253,58 +277,115 @@ class Glmclientinfo_Admin_Controller
                 'label' => 'Zip',
                 'type'  => 'text'
             ),
+            array(
+                'name'  => 'email',
+                'label' => 'Email',
+                'type'  => 'text'
+            ),
+            array(
+                'name'  => 'phone',
+                'label' => 'Phone',
+                'type'  => 'text'
+            ),
+            array(
+                'name'  => 'tollfree',
+                'label' => 'Toll Free',
+                'type'  => 'text'
+            ),
+            array(
+                'name'  => 'gpslat',
+                'label' => 'GPS Lat.',
+                'type'  => 'text'
+            ),
+            array(
+                'name'  => 'gpslon',
+                'label' => 'GPS Lon.',
+                'type'  => 'text'
+            ),
+            array(
+                'name'  => 'fax',
+                'label' => 'Fax',
+                'type'  => 'text'
+            ),
+            array(
+                'name'  => 'extra',
+                'label' => 'Extra Content',
+                'type'  => 'textarea'
+            ),
+        );
+        $fieldNames2 = array(
             array(
                 'name'  => 'address2',
-                'label' => 'Address 2',
+                'label' => 'Secondary Address',
                 'type'  => 'text'
             ),
             array(
                 'name'  => 'city2',
-                'label' => 'City 2',
+                'label' => 'Secondary City',
                 'type'  => 'text'
             ),
             array(
                 'name'  => 'state2',
-                'label' => 'State 2',
+                'label' => 'Secondary State',
                 'type'  => 'state'
             ),
             array(
                 'name'  => 'zip2',
-                'label' => 'Zip 2',
+                'label' => 'Secondary Zip',
                 'type'  => 'text'
             ),
             array(
-                'name'  => 'email',
-                'label' => 'Email',
+                'name'  => 'email2',
+                'label' => 'Secondary Email',
                 'type'  => 'text'
             ),
             array(
-                'name'  => 'phone',
-                'label' => 'Phone',
+                'name'  => 'phone2',
+                'label' => 'Secondary Phone',
                 'type'  => 'text'
             ),
             array(
-                'name'  => 'phone2',
-                'label' => 'Phone 2',
+                'name'  => 'tollfree2',
+                'label' => 'Secondary Toll Free',
                 'type'  => 'text'
             ),
             array(
-                'name'  => 'fax',
-                'label' => 'Fax',
+                'name'  => 'fax2',
+                'label' => 'Secondary Fax',
                 'type'  => 'text'
             ),
             array(
-                'name'  => 'extra',
-                'label' => 'Extra Content',
-                'type'  => 'textarea'
+                'name'  => 'gpslat2',
+                'label' => 'Secondary GPS Lat.',
+                'type'  => 'text'
+            ),
+            array(
+                'name'  => 'gpslon2',
+                'label' => 'Secondary GPS Lon.',
+                'type'  => 'text'
             ),
         );
-
+        
+        $this->glmclientinfoAddSettingTextField(
+            $businessName['name'],
+            $businessName['label'],
+            $businessName['type'],
+                "clientBusinessName"
+        );
         foreach ($fieldNames as $field) {
             $this->glmclientinfoAddSettingTextField(
                 $field['name'],
                 $field['label'],
-                $field['type']
+                $field['type'],
+                "clientInfoPrimary"
+            );
+        }
+        foreach ($fieldNames2 as $field) {
+            $this->glmclientinfoAddSettingTextField(
+                $field['name'],
+                $field['label'],
+                $field['type'],
+                "clientInfoSecondary"
             );
         }
     }
@@ -335,7 +416,7 @@ class Glmclientinfo_Admin_Controller
 
     public function glmclientinfo_settings_section_callback()
     {
-        echo __('Business Name, Address and phone numbers', 'wordpress');
+//        echo __('Business Name, Address and phone numbers', 'wordpress');
     }
 
     public function glmclientinfo_option_page_capability($capability)
@@ -352,4 +433,20 @@ class Glmclientinfo_Admin_Controller
         }
     }
 
+    public function load_stylesheet()
+    {
+        wp_enqueue_style('client-admin-css',plugins_url('glm-client-info/css/admin/admin.css' , $this->pluginDirName));
+    }
+    public function load_script()
+    {        
+        wp_register_script(
+            'client-info-admin-js',
+            plugins_url('glm-client-info/js/admin/admin.js' , $this->pluginDirName),
+            array(),
+            '0.0.1',
+            'all'
+        );
+        wp_enqueue_script('client-info-admin-js');
+
+    }
 }
diff --git a/css/admin/admin.css b/css/admin/admin.css
new file mode 100644 (file)
index 0000000..e69de29
index b2e0018..17b1efb 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * Plugin Name: GLM Client Info
  * Description: Option Setting for the name address and phone numbers. Includes Widget
- * Version: 1.0.3
+ * Version: 1.0.4
  * Author: Steve Sutton
  * Author URI: http://www.gaslightmedia.com
  * License: All right reserved
diff --git a/js/admin/admin.js b/js/admin/admin.js
new file mode 100644 (file)
index 0000000..e69de29
index ffb53f5..7106eb8 100644 (file)
@@ -1,10 +1,59 @@
 <div class="wrap">
     <form action="options.php" method="post">
-        <h2>Gaslight Client Info</h2>
-        <?php
-            settings_fields('pluginPage');
-            do_settings_sections('pluginPage');
-            submit_button();
-        ?>
+        <h1>Gaslight Client Info</h1>
+        <div style="clear: both;">
+            <?php submit_button();?>
+        </div>
+        <div id="glm-client-info-wrapper" class="row">
+            <?php
+                settings_fields('clientBusinessName');
+                do_settings_sections('clientBusinessName');
+            ?>
+            <div id="glm-client-info-primary" class="glm-client-info-section"><br>
+                <?php
+                    settings_fields('clientInfoPrimary');
+                    do_settings_sections('clientInfoPrimary');
+                ?>
+            </div>
+            <input id="showSecondaryInfo" name="showSecondaryInfo" type="checkbox"><label for="showSecondaryInfo">Show Secondary Info</label>
+            <div id="glm-client-info-secondary" class="glm-client-info-section">
+                <?php
+                    settings_fields('clientInfoSecondary');
+                    do_settings_sections('clientInfoSecondary');
+                ?>
+            </div>
+            <div style="clear: both; text-align: center;">
+                <?php submit_button();?>
+            </div>
+        </div>
     </form>
-</div>
\ No newline at end of file
+</div>
+<script>
+    jQuery( document ).ready(function() { 
+        if (jQuery( window ).width() > 640) {
+            jQuery('.glm-client-info-section').width('50%').css("float","left");
+        } else {
+            jQuery('.glm-client-info-section').width('100%');
+        }
+        jQuery( window ).resize(function() {
+            if (jQuery( window ).width() > 640) {
+                jQuery('.glm-client-info-section').width('50%').css("float","left");
+            } else {
+                jQuery('.glm-client-info-section').width('100%');
+            }
+        });
+        if (jQuery('#showSecondaryInfo').is(':checked')) {
+            jQuery("#glm-client-info-secondary").show();
+            
+        } else {
+            jQuery("#glm-client-info-secondary").hide();
+        }
+        jQuery('#showSecondaryInfo').change(function(){
+            if (this.checked) {
+                jQuery("#glm-client-info-secondary").show();
+            } else {
+                jQuery("#glm-client-info-secondary").hide();
+            }
+        });
+    });
+</script>
\ No newline at end of file
index 6aed12e..7160c18 100644 (file)
@@ -1,34 +1,82 @@
 <div class="vcard">
-<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_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>
+    <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_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_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_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_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_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_clientinfo_option('phone')):?>
-<p class="tel">
-    <span class="type">phone</span>:
-    <span class="value"><?php echo $this->glm_get_clientinfo_option('phone');?></span>
-</p>
-<?php endif;?>
-<?php if ($this->glm_get_clientinfo_option('fax')):?>
-<p class="tel">
-    <span class="type">fax</span>:
-    <span class="value"><?php echo $this->glm_get_clientinfo_option('fax');?></span>
-</p>
-<?php endif;?>
-<?php if ($this->glm_get_clientinfo_option('extra')):?>
-    <?php echo $this->glm_get_clientinfo_option('extra');?>
-<?php endif;?>
-</div><!-- /#address -->
+    <?php if ($this->glm_get_clientinfo_option('phone')):?>
+    <p class="tel">
+        <span class="type">phone</span>:
+        <span class="value"><?php echo $this->glm_get_clientinfo_option('phone');?></span>
+    </p>
+    <?php endif;?>
+    <?php if ($this->glm_get_clientinfo_option('phone2')):?>
+    <p class="tel">
+        <span class="type">phone 2</span>:
+        <span class="value"><?php echo $this->glm_get_clientinfo_option('phone2');?></span>
+    </p>
+    <?php endif;?>
+    <?php if ($this->glm_get_clientinfo_option('tollfree')):?>
+    <p class="tel">
+        <span class="type">tollfree</span>:
+        <span class="value"><?php echo $this->glm_get_clientinfo_option('tollfree');?></span>
+    </p>
+    <?php endif;?>
+    <?php if ($this->glm_get_clientinfo_option('tollfree2')):?>
+    <p class="tel">
+        <span class="type">tollfree 2</span>:
+        <span class="value"><?php echo $this->glm_get_clientinfo_option('tollfree2');?></span>
+    </p>
+    <?php endif;?>
+    <?php if ($this->glm_get_clientinfo_option('fax')):?>
+    <p class="tel">
+        <span class="type">fax</span>:
+        <span class="value"><?php echo $this->glm_get_clientinfo_option('fax');?></span>
+    </p>
+    <?php endif;?>
+    <?php if ($this->glm_get_clientinfo_option('fax2')):?>
+    <p class="tel">
+        <span class="type">fax 2</span>:
+        <span class="value"><?php echo $this->glm_get_clientinfo_option('fax2');?></span>
+    </p>
+    <?php endif;?>
+    <?php if ($this->glm_get_clientinfo_option('gpslat')):?>
+    <p class="tel">
+        <span class="type">gpslat</span>:
+        <span class="value"><?php echo $this->glm_get_clientinfo_option('gpslat');?></span>
+    </p>
+    <?php endif;?>
+    <?php if ($this->glm_get_clientinfo_option('gpslon')):?>
+    <p class="tel">
+        <span class="type">gpslon</span>:
+        <span class="value"><?php echo $this->glm_get_clientinfo_option('gpslon');?></span>
+    </p>
+    <?php endif;?>
+    <?php if ($this->glm_get_clientinfo_option('gpslat2')):?>
+    <p class="tel">
+        <span class="type">gpslat 2</span>:
+        <span class="value"><?php echo $this->glm_get_clientinfo_option('gpslat2');?></span>
+    </p>
+    <?php endif;?>
+    <?php if ($this->glm_get_clientinfo_option('gpslon2')):?>
+    <p class="tel">
+        <span class="type">gpslon 2</span>:
+        <span class="value"><?php echo $this->glm_get_clientinfo_option('gpslon2');?></span>
+    </p>
+    <?php endif;?>
+    <?php if ($this->glm_get_clientinfo_option('extra')):?>
+        <?php echo $this->glm_get_clientinfo_option('extra');?>
+    <?php endif;?>
+</div><!-- /#vcard -->