From c8a64a360f95729df120235ffe4afbcd9668d35a Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 15 Jan 2016 10:21:42 -0500 Subject: [PATCH] Update to use gravity forms Setting changed to set a page to link in the gravity form --- controllers/admin.php | 144 +++++++++++++++++++++++------------------- controllers/front.php | 16 +++-- index.php | 6 +- views/page.php | 16 +++++ views/text.php | 2 +- views/textArea.php | 2 +- 6 files changed, 111 insertions(+), 75 deletions(-) create mode 100644 views/page.php diff --git a/controllers/admin.php b/controllers/admin.php index e893882..14ba853 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -57,12 +57,12 @@ class glm_employment_admin static public function activate_plugin() { - staffords_employment_admin::add_capability(); + glmjobs_employment_admin::add_capability(); } static public function deactivate_plugin() { - staffords_employment_admin::remove_capability(); + glmjobs_employment_admin::remove_capability(); } static public function add_capability() @@ -85,7 +85,7 @@ class glm_employment_admin } } - public function staffords_settings_exist() + public function glmjobs_settings_exist() { if (false == get_option(GLM_EMP_SETTINGS)) { add_option(GLM_EMP_SETTINGS); @@ -94,66 +94,71 @@ class glm_employment_admin public function job_settings_init() { + //add_settings_section( + //'glmjobsjobs_setting_section_two', + //'Edit Settings', + //array($this, 'glmjobs_settings_two_section_callback'), + //'glmjobsjobs_settings' + //); + //add_settings_field( + //'thank_you_text', + //'Thank You Message', + //array($this, 'render_textarea_field'), + //'glmjobsjobs_settings', + //'glmjobsjobs_setting_section_two', + //'thank_you_text' + //); add_settings_section( - 'staffordsjobs_setting_section_two', - 'Edit Confirmations', - array($this, 'staffords_settings_two_section_callback'), - 'staffordsjobs_settings' - ); - add_settings_field( - 'thank_you_text', - 'Thank You Message', - array($this, 'render_textarea_field'), - 'staffordsjobs_settings', - 'staffordsjobs_setting_section_two', - 'thank_you_text' - ); - add_settings_section( - 'staffordsjobs_setting_section', - 'Edit Notifications', - array($this, 'staffords_settings_section_callback'), - 'staffordsjobs_settings' + 'glmjobsjobs_setting_section', + 'Edit Form Settings', + array($this, 'glmjobs_settings_section_callback'), + 'glmjobsjobs_settings' ); $fieldNames = array( array( - 'name' => 'notification_name', - 'label' => 'Online Form Notify: Name', - 'type' => 'text' - ), - array( - 'name' => 'notification_email', - 'label' => 'Online Form Notify: Email', - 'type' => 'text' - ), - array( - 'name' => 'from_name', - 'label' => 'From: Name', - 'type' => 'text' - ), - array( - 'name' => 'from_email', - 'label' => 'From: Email', - 'type' => 'text' - ), - array( - 'name' => 'replyto_name', - 'label' => 'Reply-To: Name', - 'type' => 'text' - ), - array( - 'name' => 'replyto_email', - 'label' => 'Reply-To: Email', - 'type' => 'text' - ), - array( - 'name' => 'notification_message', - 'label' => 'Notification Message', - 'type' => 'textarea' - ), + 'name' => 'employment_form_page', + 'label' => 'Page for the Form', + 'type' => 'page' + ) + //array( + //'name' => 'notification_name', + //'label' => 'Online Form Notify: Name', + //'type' => 'text' + //), + //array( + //'name' => 'notification_email', + //'label' => 'Online Form Notify: Email', + //'type' => 'text' + //), + //array( + //'name' => 'from_name', + //'label' => 'From: Name', + //'type' => 'text' + //), + //array( + //'name' => 'from_email', + //'label' => 'From: Email', + //'type' => 'text' + //), + //array( + //'name' => 'replyto_name', + //'label' => 'Reply-To: Name', + //'type' => 'text' + //), + //array( + //'name' => 'replyto_email', + //'label' => 'Reply-To: Email', + //'type' => 'text' + //), + //array( + //'name' => 'notification_message', + //'label' => 'Notification Message', + //'type' => 'textarea' + //), ); foreach ($fieldNames as $field) { - $this->staffords_add_setting_text_field( + $this->glmjobs_add_setting_text_field( $field['name'], $field['label'], $field['type'] @@ -218,7 +223,7 @@ class glm_employment_admin return true; } - public function staffords_add_setting_text_field($name, $label, $type) + public function glmjobs_add_setting_text_field($name, $label, $type) { switch ($type) { case 'text': @@ -227,8 +232,8 @@ class glm_employment_admin case 'textarea': $callback = 'render_textarea_field'; break; - case 'state': - $callback = 'glmclientinfoRenderStateSelect'; + case 'page': + $callback = 'render_page_field'; break; default: return false; @@ -238,12 +243,21 @@ class glm_employment_admin $name, $label, array($this, $callback), - 'staffordsjobs_settings', - 'staffordsjobs_setting_section', + 'glmjobsjobs_settings', + 'glmjobsjobs_setting_section', $name ); } + public function render_page_field($fieldName) + { + static $options; + if (!$options) { + $options = get_option(GLM_EMP_SETTINGS); + } + include $this->pluginDirName . 'views/page.php'; + } + public function render_text_field($fieldName) { static $options; @@ -260,17 +274,17 @@ class glm_employment_admin include $this->pluginDirName . 'views/textArea.php'; } - public function staffords_settings_section_callback() + public function glmjobs_settings_section_callback() { - echo __('Employment Form Email Notification', 'wordpress'); + echo __('Employment Form Page', 'wordpress'); } - public function staffords_settings_two_section_callback() + public function glmjobs_settings_two_section_callback() { echo __('Employment Form Thank You', 'wordpress'); } - public function staffords_option_page_capability() + public function glmjobs_option_page_capability() { return GLM_EMP_NEW_CAPABILITY; } diff --git a/controllers/front.php b/controllers/front.php index 3d0fb3e..105c8ea 100644 --- a/controllers/front.php +++ b/controllers/front.php @@ -150,7 +150,7 @@ class glm_employment_front $name = $plugin_options['replyto_name']; $email = $plugin_options['replyto_email']; $message = $plugin_options['notification_message'] . "\n"; - $message .= '' . get_bloginfo('name') . ' Admin Area.' . "\n\n"; + $message .= '' . get_bloginfo('name') . ' Admin Area.' . "\n\n"; $headers = array(); $headers[] = "From: {$fromName} <{$from}>"; $headers[] = "Reply-To: {$name} <{$email}>"; @@ -543,10 +543,16 @@ class glm_employment_front $job->glm_jobs_code = $custom['glm_jobs_code'][0]; $job->glm_jobs_property = $deps; $job->glm_jobs_category = $cats; - $current_url = esc_url(add_query_arg($wp->query_string, '', home_url($wp->request))); - $applyOnlineHref = $current_url - . ((strpos($current_url, '?')) ? '&' : '?') - . self::FORM_VAR . "=1&job=" . $job->ID; + //$current_url = esc_url(add_query_arg($wp->query_string, '', home_url($wp->request))); + $plugin_options = get_option(GLM_EMP_SETTING_NAME); + $applyOnlineHref = (isset($plugin_options['employment_form_page'])) + ? get_permalink( $plugin_options['employment_form_page'] ) + . '?current_date=' . urlencode( date( 'm/d/Y' ) ) + . '&position_name=' . urlencode( $job->post_title ) + : false; + //$applyOnlineHref = $current_url + //. ((strpos($current_url, '?')) ? '&' : '?') + //. self::FORM_VAR . "=1&job=" . $job->ID; include $this->frontViewDir . '/jobDetail.php'; return; } diff --git a/index.php b/index.php index 37a2c35..6036536 100644 --- a/index.php +++ b/index.php @@ -14,9 +14,9 @@ defined('ABSPATH') or die(); */ define('GLM_EMP_PLUGIN_PATH_FILE', __FILE__); define('GLM_EMP_VERSION', '0.0.1'); -define('GLM_EMP_SETTING_NAME', 'staffordsjobs_settings'); -define('GLM_EMP_SETTINGS', 'staffordsjobs_settings'); -define('GLM_EMP_NEW_CAPABILITY', 'edit_staffords_jobs'); +define('GLM_EMP_SETTING_NAME', 'glmjobsjobs_settings'); +define('GLM_EMP_SETTINGS', 'glmjobsjobs_settings'); +define('GLM_EMP_NEW_CAPABILITY', 'edit_glmjobs_jobs'); define('GLM_EMP_BUILT_IN_CAPABILITY', 'edit_posts'); define('GLM_EMP_VRS_OPTION_NAME', 'glm_jobs_db_version'); define('GLM_EMP_POST_TYPE', 'glm_jobs'); diff --git a/views/page.php b/views/page.php new file mode 100644 index 0000000..d0ff8be --- /dev/null +++ b/views/page.php @@ -0,0 +1,16 @@ + 0, + 'child_of' => 0, + 'selected' => $options[$fieldName], + 'echo' => 1, + 'name' => 'glmjobsjobs_settings['.$fieldName.']', + 'id' => 'glm_block_page', + 'show_option_none' => 'None', + 'post_status' => 'publish', + 'post_type' => 'page' + ) +); +?> + diff --git a/views/text.php b/views/text.php index 25f9928..f0807ed 100644 --- a/views/text.php +++ b/views/text.php @@ -1,2 +1,2 @@ -"> diff --git a/views/textArea.php b/views/textArea.php index 1c2044f..ad85e2c 100644 --- a/views/textArea.php +++ b/views/textArea.php @@ -1 +1 @@ - + -- 2.17.1