From: Steve Sutton Date: Wed, 10 Feb 2016 18:23:46 +0000 (-0500) Subject: New featured added for gravity forms X-Git-Tag: v0.4.0^2~1 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=53cbe551c1b9e63fd08cc038faef873e43bb2ba3;p=WP-Plugins%2Fstaffords-employment.git New featured added for gravity forms Update setting to select page that will be linked in to Apply Online. Gravity forms can then be put on that page. --- diff --git a/controllers/admin.php b/controllers/admin.php index 86eb043..900c702 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -94,82 +94,87 @@ class staffords_employment_admin public function job_settings_init() { - 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_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', + 'Edit Form Settings', array($this, 'staffords_settings_section_callback'), 'staffordsjobs_settings' ); $fieldNames = array( array( - 'name' => 'notification_name', - 'label' => 'Staffords Notify: Name', - 'type' => 'text' - ), - array( - 'name' => 'notification_email', - 'label' => 'Staffords 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' - ), - ); - $terms = get_terms( - STAFFORDS_EMP_TAX_DEPARTMENTS, - array( - 'hide_empty' => false + 'name' => 'employment_form_page', + 'label' => 'Page for the Form', + 'type' => 'page' ) + //array( + //'name' => 'notification_name', + //'label' => 'Staffords Notify: Name', + //'type' => 'text' + //), + //array( + //'name' => 'notification_email', + //'label' => 'Staffords 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 ($terms as $term) { - $termArray[] = $term->name; - $fieldNames[] = array( - 'name' => $term->slug . '_notification_name', - 'label' => $term->name . ': Name', - 'type' => 'text' - ); - $fieldNames[] = array( - 'name' => $term->slug . '_notification_email', - 'label' => $term->name . ': Email', - 'type' => 'text' - ); - } + //$terms = get_terms( + //STAFFORDS_EMP_TAX_DEPARTMENTS, + //array( + //'hide_empty' => false + //) + //); + //foreach ($terms as $term) { + //$termArray[] = $term->name; + //$fieldNames[] = array( + //'name' => $term->slug . '_notification_name', + //'label' => $term->name . ': Name', + //'type' => 'text' + //); + //$fieldNames[] = array( + //'name' => $term->slug . '_notification_email', + //'label' => $term->name . ': Email', + //'type' => 'text' + //); + //} foreach ($fieldNames as $field) { $this->staffords_add_setting_text_field( @@ -249,6 +254,9 @@ class staffords_employment_admin case 'state': $callback = 'glmclientinfoRenderStateSelect'; break; + case 'page': + $callback = 'render_page_field'; + break; default: return false; break; @@ -263,6 +271,15 @@ class staffords_employment_admin ); } + public function render_page_field($fieldName) + { + static $options; + if (!$options) { + $options = get_option(STAFFORDS_EMP_SETTINGS); + } + include $this->pluginDirName . 'views/page.php'; + } + public function render_text_field($fieldName) { static $options; @@ -281,7 +298,7 @@ class staffords_employment_admin public function staffords_settings_section_callback() { - echo __('Employment Form Email Notification', 'wordpress'); + echo __('Employment Form Page', 'wordpress'); } public function staffords_settings_two_section_callback() diff --git a/controllers/front.php b/controllers/front.php index 6900500..146f0a4 100644 --- a/controllers/front.php +++ b/controllers/front.php @@ -565,10 +565,12 @@ class staffords_employment_front $job->staffords_jobs_code = $custom['staffords_jobs_code'][0]; $job->staffords_jobs_property = $deps; $job->staffords_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(STAFFORDS_EMP_SETTING_NAME); + $applyOnlineHref = (isset($plugin_options['employment_form_page'])) + ? get_permalink( $plugin_options['employment_form_page'] ) + . '?position_name=' . urlencode( $job->post_title ) + : false; include $this->frontViewDir . '/jobDetail.php'; return; } diff --git a/views/page.php b/views/page.php new file mode 100644 index 0000000..ebd3561 --- /dev/null +++ b/views/page.php @@ -0,0 +1,16 @@ + 0, + 'child_of' => 0, + 'selected' => $options[$fieldName], + 'echo' => 1, + 'name' => STAFFORDS_EMP_SETTINGS . '['.$fieldName.']', + 'id' => 'glm_block_page', + 'show_option_none' => 'None', + 'post_status' => 'publish', + 'post_type' => 'page' + ) +); +?> +