From 4aeb12cbd1a6329998b0c216c7ff5580b0eb9080 Mon Sep 17 00:00:00 2001 From: Laury GvR Date: Wed, 1 Jun 2016 14:09:02 -0400 Subject: [PATCH] Added fields, separated address 1 from 2 --- controllers/Admin.php | 161 +++++++++++++++++++++++++++++++++--------- css/admin/admin.css | 0 glm-client-info.php | 2 +- js/admin/admin.js | 0 views/optionsPage.php | 63 +++++++++++++++-- views/vCard.php | 110 +++++++++++++++++++++-------- 6 files changed, 265 insertions(+), 71 deletions(-) create mode 100644 css/admin/admin.css create mode 100644 js/admin/admin.js diff --git a/controllers/Admin.php b/controllers/Admin.php index 10fe3f4..be4df3d 100644 --- a/controllers/Admin.php +++ b/controllers/Admin.php @@ -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 index 0000000..e69de29 diff --git a/glm-client-info.php b/glm-client-info.php index b2e0018..17b1efb 100644 --- a/glm-client-info.php +++ b/glm-client-info.php @@ -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 index 0000000..e69de29 diff --git a/views/optionsPage.php b/views/optionsPage.php index ffb53f5..7106eb8 100644 --- a/views/optionsPage.php +++ b/views/optionsPage.php @@ -1,10 +1,59 @@
-

Gaslight Client Info

- +

Gaslight Client Info

+
+ +
+
+ +

+ +
+ +
+ +
+
+ +
+
-
\ No newline at end of file + + \ No newline at end of file diff --git a/views/vCard.php b/views/vCard.php index 6aed12e..7160c18 100644 --- a/views/vCard.php +++ b/views/vCard.php @@ -1,34 +1,82 @@
-

glm_get_clientinfo_option('businessName');?>

-

glm_get_clientinfo_option('address');?>

-

- glm_get_clientinfo_option('city');?>, - glm_get_clientinfo_option('state');?> - glm_get_clientinfo_option('zip');?> -

+

glm_get_clientinfo_option('businessName');?>

+

glm_get_clientinfo_option('address');?>

+

+ glm_get_clientinfo_option('city');?>, + glm_get_clientinfo_option('state');?> + glm_get_clientinfo_option('zip');?> +

-glm_get_clientinfo_option('address2')):?> -

glm_get_clientinfo_option('address2');?>

-

- glm_get_clientinfo_option('city2');?>, - glm_get_clientinfo_option('state2');?> - glm_get_clientinfo_option('zip2');?> -

- + glm_get_clientinfo_option('address2')):?> +

glm_get_clientinfo_option('address2');?>

+

+ glm_get_clientinfo_option('city2');?>, + glm_get_clientinfo_option('state2');?> + glm_get_clientinfo_option('zip2');?> +

+ -glm_get_clientinfo_option('phone')):?> -

- phone: - glm_get_clientinfo_option('phone');?> -

- -glm_get_clientinfo_option('fax')):?> -

- fax: - glm_get_clientinfo_option('fax');?> -

- -glm_get_clientinfo_option('extra')):?> - glm_get_clientinfo_option('extra');?> - -
+ glm_get_clientinfo_option('phone')):?> +

+ phone: + glm_get_clientinfo_option('phone');?> +

+ + glm_get_clientinfo_option('phone2')):?> +

+ phone 2: + glm_get_clientinfo_option('phone2');?> +

+ + glm_get_clientinfo_option('tollfree')):?> +

+ tollfree: + glm_get_clientinfo_option('tollfree');?> +

+ + glm_get_clientinfo_option('tollfree2')):?> +

+ tollfree 2: + glm_get_clientinfo_option('tollfree2');?> +

+ + glm_get_clientinfo_option('fax')):?> +

+ fax: + glm_get_clientinfo_option('fax');?> +

+ + glm_get_clientinfo_option('fax2')):?> +

+ fax 2: + glm_get_clientinfo_option('fax2');?> +

+ + glm_get_clientinfo_option('gpslat')):?> +

+ gpslat: + glm_get_clientinfo_option('gpslat');?> +

+ + glm_get_clientinfo_option('gpslon')):?> +

+ gpslon: + glm_get_clientinfo_option('gpslon');?> +

+ + glm_get_clientinfo_option('gpslat2')):?> +

+ gpslat 2: + glm_get_clientinfo_option('gpslat2');?> +

+ + glm_get_clientinfo_option('gpslon2')):?> +

+ gpslon 2: + glm_get_clientinfo_option('gpslon2');?> +

+ + glm_get_clientinfo_option('extra')):?> + glm_get_clientinfo_option('extra');?> + + -- 2.17.1