| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package Formidable |
| 4 |
*/ |
| 5 |
|
| 6 |
if(!defined('ABSPATH')) die('You are not allowed to call this page directly.'); |
| 7 |
|
| 8 |
if(class_exists('FrmSettingsController')) |
| 9 |
return; |
| 10 |
|
| 11 |
class FrmSettingsController{ |
| 12 |
public static function load_hooks(){ |
| 13 |
add_action('admin_menu', 'FrmSettingsController::menu', 45); |
| 14 |
add_action('frm_before_settings', 'FrmSettingsController::license_box'); |
| 15 |
} |
| 16 |
|
| 17 |
public static function menu(){ |
| 18 |
add_submenu_page('formidable', 'Formidable | '. __('Global Settings', 'formidable'), __('Global Settings', 'formidable'), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route'); |
| 19 |
} |
| 20 |
|
| 21 |
public static function license_box(){ |
| 22 |
$a = isset($_GET['t']) ? $_GET['t'] : 'general_settings'; |
| 23 |
include(FrmAppHelper::plugin_path() .'/classes/views/frm-settings/license_box.php'); |
| 24 |
} |
| 25 |
|
| 26 |
public static function display_form($errors=array(), $message=''){ |
| 27 |
global $frm_settings, $frm_vars; |
| 28 |
|
| 29 |
$frm_roles = FrmAppHelper::frm_capabilities(); |
| 30 |
|
| 31 |
$uploads = wp_upload_dir(); |
| 32 |
$target_path = $uploads['basedir'] . '/formidable/css'; |
| 33 |
$sections = apply_filters('frm_add_settings_section', array( |
| 34 |
'styling' => array('name' => __('Form Styling', 'formidable'), 'class' => 'FrmSettingsController', 'function' => 'styling_tab') |
| 35 |
)); |
| 36 |
|
| 37 |
$recaptcha_themes = array( |
| 38 |
'red' => __('Red', 'formidable'), |
| 39 |
'white' => __('White', 'formidable'), |
| 40 |
'blackglass' => __('Black Glass', 'formidable'), |
| 41 |
'clean' => __('Clean', 'formidable'), |
| 42 |
//'custom' => __('Custom', 'formidable'), |
| 43 |
); |
| 44 |
|
| 45 |
require(FrmAppHelper::plugin_path() .'/classes/views/frm-settings/form.php'); |
| 46 |
} |
| 47 |
|
| 48 |
public static function process_form($stop_load=false){ |
| 49 |
global $frm_settings, $frm_vars; |
| 50 |
|
| 51 |
if(!isset($_POST['process_form']) or !wp_verify_nonce($_POST['process_form'], 'process_form_nonce')) |
| 52 |
wp_die($frm_settings->admin_permission); |
| 53 |
|
| 54 |
$errors = array(); |
| 55 |
$message = ''; |
| 56 |
|
| 57 |
if(!isset($frm_vars['settings_routed']) or !$frm_vars['settings_routed']){ |
| 58 |
//$errors = $frm_settings->validate($_POST,array()); |
| 59 |
$frm_settings->update(stripslashes_deep($_POST)); |
| 60 |
|
| 61 |
if( empty($errors) ){ |
| 62 |
$frm_settings->store(); |
| 63 |
$message = __('Settings Saved', 'formidable'); |
| 64 |
} |
| 65 |
}else{ |
| 66 |
$message = __('Settings Saved', 'formidable'); |
| 67 |
} |
| 68 |
|
| 69 |
if($stop_load == 'stop_load'){ |
| 70 |
$frm_vars['settings_routed'] = true; |
| 71 |
return; |
| 72 |
} |
| 73 |
|
| 74 |
self::display_form($errors, $message); |
| 75 |
} |
| 76 |
|
| 77 |
public static function styling_tab(){ |
| 78 |
include(FrmAppHelper::plugin_path() .'/classes/views/frm-settings/styling_tab.php'); |
| 79 |
} |
| 80 |
|
| 81 |
public static function route($stop_load=false){ |
| 82 |
$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
| 83 |
$action = FrmAppHelper::get_param($action); |
| 84 |
if($action == 'process-form') |
| 85 |
return self::process_form($stop_load); |
| 86 |
else if($stop_load != 'stop_load') |
| 87 |
return self::display_form(); |
| 88 |
} |
| 89 |
} |
| 90 |
|