Update to use gravity forms
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 15 Jan 2016 15:21:42 +0000 (10:21 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 15 Jan 2016 15:21:42 +0000 (10:21 -0500)
Setting changed to set a page to link in the gravity form

controllers/admin.php
controllers/front.php
index.php
views/page.php [new file with mode: 0644]
views/text.php
views/textArea.php

index e893882..14ba853 100644 (file)
@@ -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;
     }
index 3d0fb3e..105c8ea 100644 (file)
@@ -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  .= '<a href="' . admin_url() . 'edit.php?post_type=staffords_jobs&page=applications">' . get_bloginfo('name') . ' Admin Area</a>.' . "\n\n";
+        $message  .= '<a href="' . admin_url() . 'edit.php?post_type=glmjobs_jobs&page=applications">' . get_bloginfo('name') . ' Admin Area</a>.' . "\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;
     }
index 37a2c35..6036536 100644 (file)
--- 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 (file)
index 0000000..d0ff8be
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+wp_dropdown_pages(
+    array(
+        'depth'            => 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'
+    )
+);
+?>
+</select>
index 25f9928..f0807ed 100644 (file)
@@ -1,2 +1,2 @@
-<input type="text" name="staffordsjobs_settings[<?php echo $fieldName;?>]"
+<input type="text" name="glmjobsjobs_settings[<?php echo $fieldName;?>]"
            value="<?php echo str_replace('"', '&quote;', $options[$fieldName]); ?>">
index 1c2044f..ad85e2c 100644 (file)
@@ -1 +1 @@
-<textarea cols="40" rows="5" name="staffordsjobs_settings[<?php echo $fieldName;?>]"><?php echo htmlspecialchars($options[$fieldName]); ?></textarea>
+<textarea cols="40" rows="5" name="glmjobsjobs_settings[<?php echo $fieldName;?>]"><?php echo htmlspecialchars($options[$fieldName]); ?></textarea>