online apply setting from theme
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 4 Jan 2016 20:47:17 +0000 (15:47 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 4 Jan 2016 20:47:17 +0000 (15:47 -0500)
controllers/front.php

index 12524f5..610053b 100644 (file)
@@ -30,12 +30,12 @@ class glm_employment_front
     public $appId;
     public $formId;
     public $jobTitle;
+    public $finalFormPage;
 
     // class constants
     const FORM_VAR          = 'applyOnline';
     const FORM_SETTINGS_DIR = 'config';
     const FORM_VIEW_DIR     = 'views';
-    const FINAL_FORM        = 8;
     const FORM_TEMPLATE     = 'formTemplate.php';
     const SUCCESS_TEMPLATE  = 'thankYou.php';
 
@@ -56,6 +56,29 @@ class glm_employment_front
         $this->adminViewDir = $this->viewDir . '/admin';
         $this->frontViewDir = $this->viewDir . '/front';
         $this->settingDir   = $this->pluginDirName . self::FORM_SETTINGS_DIR;
+        $this->setThemeSettings();
+    }
+
+    /**
+     * setThemeSettings
+     *
+     * This will check the current theme folder for a glm-emp-config
+     * directory and if it finds one it will setup the config class variable for it.
+     * If not found it will default back to the plugins config directory.
+     *
+     * @access public
+     * @return void
+     */
+    public function setThemeSettings()
+    {
+        if ( file_exists( get_template_directory() . '/glm-emp-config/application.ini' ) ) {
+            $theme_settings = parse_ini_file(
+                get_template_directory() . '/glm-emp-config/application.ini',
+                true
+            );
+            $this->finalFormPage = $theme_settings['main_section']['final_form_page'];
+        }
+        $this->settingDir = get_template_directory() . '/glm-emp-config';
     }
 
     /**
@@ -235,7 +258,7 @@ class glm_employment_front
                     $this->store_form_data($form, $formPart);
                     // next form part
                     ++$formPart;
-                    if ($formPart == self::FINAL_FORM) {
+                    if ($formPart == $this->finalFormPage) {
                         $plugin_options = get_option(GLM_EMP_SETTING_NAME);
                         include $this->frontViewDir . '/' . self::SUCCESS_TEMPLATE;
                         unset($_SESSION['glmJobsApplication'], $_SESSION['glmJobsAppForm']);