@@ -1,244 +1,244 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmSettings { |
| 4 | - public $option_name = 'frm_options'; |
|
| 5 | - public $menu; |
|
| 6 | - public $mu_menu; |
|
| 7 | - public $preview_page_id; |
|
| 8 | - public $use_html; |
|
| 9 | - public $jquery_css; |
|
| 10 | - public $accordion_js; |
|
| 4 | + public $option_name = 'frm_options'; |
|
| 5 | + public $menu; |
|
| 6 | + public $mu_menu; |
|
| 7 | + public $preview_page_id; |
|
| 8 | + public $use_html; |
|
| 9 | + public $jquery_css; |
|
| 10 | + public $accordion_js; |
|
| 11 | 11 | public $fade_form; |
| 12 | 12 | |
| 13 | - public $success_msg; |
|
| 14 | - public $blank_msg; |
|
| 15 | - public $unique_msg; |
|
| 16 | - public $invalid_msg; |
|
| 17 | - public $failed_msg; |
|
| 18 | - public $submit_value; |
|
| 19 | - public $login_msg; |
|
| 20 | - public $admin_permission; |
|
| 21 | - |
|
| 22 | - public $email_to; |
|
| 23 | - public $load_style; |
|
| 24 | - public $custom_style; |
|
| 25 | - |
|
| 26 | - public $pubkey; |
|
| 27 | - public $privkey; |
|
| 28 | - public $re_lang; |
|
| 29 | - public $re_msg; |
|
| 13 | + public $success_msg; |
|
| 14 | + public $blank_msg; |
|
| 15 | + public $unique_msg; |
|
| 16 | + public $invalid_msg; |
|
| 17 | + public $failed_msg; |
|
| 18 | + public $submit_value; |
|
| 19 | + public $login_msg; |
|
| 20 | + public $admin_permission; |
|
| 21 | + |
|
| 22 | + public $email_to; |
|
| 23 | + public $load_style; |
|
| 24 | + public $custom_style; |
|
| 25 | + |
|
| 26 | + public $pubkey; |
|
| 27 | + public $privkey; |
|
| 28 | + public $re_lang; |
|
| 29 | + public $re_msg; |
|
| 30 | 30 | public $re_multi; |
| 31 | 31 | |
| 32 | - public function __construct() { |
|
| 33 | - if ( ! defined('ABSPATH') ) { |
|
| 34 | - die('You are not allowed to call this page directly.'); |
|
| 35 | - } |
|
| 32 | + public function __construct() { |
|
| 33 | + if ( ! defined('ABSPATH') ) { |
|
| 34 | + die('You are not allowed to call this page directly.'); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - $settings = get_transient($this->option_name); |
|
| 37 | + $settings = get_transient($this->option_name); |
|
| 38 | 38 | |
| 39 | - if ( ! is_object($settings) ) { |
|
| 40 | - $settings = $this->translate_settings($settings); |
|
| 41 | - } |
|
| 39 | + if ( ! is_object($settings) ) { |
|
| 40 | + $settings = $this->translate_settings($settings); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - foreach ( $settings as $setting_name => $setting ) { |
|
| 44 | - $this->{$setting_name} = $setting; |
|
| 45 | - unset($setting_name, $setting); |
|
| 46 | - } |
|
| 43 | + foreach ( $settings as $setting_name => $setting ) { |
|
| 44 | + $this->{$setting_name} = $setting; |
|
| 45 | + unset($setting_name, $setting); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - $this->set_default_options(); |
|
| 49 | - } |
|
| 48 | + $this->set_default_options(); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | private function translate_settings( $settings ) { |
| 52 | - if ( $settings ) { //workaround for W3 total cache conflict |
|
| 53 | - return unserialize(serialize($settings)); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - $settings = get_option($this->option_name); |
|
| 57 | - if ( is_object($settings) ) { |
|
| 58 | - set_transient($this->option_name, $settings); |
|
| 59 | - return $settings; |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - // If unserializing didn't work |
|
| 63 | - if ( $settings ) { //workaround for W3 total cache conflict |
|
| 64 | - $settings = unserialize(serialize($settings)); |
|
| 65 | - } else { |
|
| 66 | - $settings = $this; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - update_option($this->option_name, $settings); |
|
| 70 | - set_transient($this->option_name, $settings); |
|
| 71 | - |
|
| 72 | - return $settings; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * @return array |
|
| 77 | - */ |
|
| 52 | + if ( $settings ) { //workaround for W3 total cache conflict |
|
| 53 | + return unserialize(serialize($settings)); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + $settings = get_option($this->option_name); |
|
| 57 | + if ( is_object($settings) ) { |
|
| 58 | + set_transient($this->option_name, $settings); |
|
| 59 | + return $settings; |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + // If unserializing didn't work |
|
| 63 | + if ( $settings ) { //workaround for W3 total cache conflict |
|
| 64 | + $settings = unserialize(serialize($settings)); |
|
| 65 | + } else { |
|
| 66 | + $settings = $this; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + update_option($this->option_name, $settings); |
|
| 70 | + set_transient($this->option_name, $settings); |
|
| 71 | + |
|
| 72 | + return $settings; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * @return array |
|
| 77 | + */ |
|
| 78 | 78 | public function default_options() { |
| 79 | - return array( |
|
| 80 | - 'menu' => apply_filters( 'frm_default_menu', __( 'Forms', 'formidable' ) ), |
|
| 81 | - 'mu_menu' => 0, |
|
| 82 | - 'preview_page_id' => 0, |
|
| 83 | - 'use_html' => true, |
|
| 84 | - 'jquery_css' => false, |
|
| 85 | - 'accordion_js' => false, |
|
| 79 | + return array( |
|
| 80 | + 'menu' => apply_filters( 'frm_default_menu', __( 'Forms', 'formidable' ) ), |
|
| 81 | + 'mu_menu' => 0, |
|
| 82 | + 'preview_page_id' => 0, |
|
| 83 | + 'use_html' => true, |
|
| 84 | + 'jquery_css' => false, |
|
| 85 | + 'accordion_js' => false, |
|
| 86 | 86 | 'fade_form' => false, |
| 87 | 87 | |
| 88 | 88 | 're_multi' => 0, |
| 89 | 89 | |
| 90 | - 'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ), |
|
| 91 | - 'blank_msg' => __( 'This field cannot be blank.', 'formidable' ), |
|
| 92 | - 'unique_msg' => __( 'This value must be unique.', 'formidable' ), |
|
| 93 | - 'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ), |
|
| 94 | - 'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ), |
|
| 95 | - 'submit_value' => __( 'Submit', 'formidable' ), |
|
| 96 | - 'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ), |
|
| 97 | - 'admin_permission' => __( 'You do not have permission to do that', 'formidable' ), |
|
| 90 | + 'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ), |
|
| 91 | + 'blank_msg' => __( 'This field cannot be blank.', 'formidable' ), |
|
| 92 | + 'unique_msg' => __( 'This value must be unique.', 'formidable' ), |
|
| 93 | + 'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ), |
|
| 94 | + 'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ), |
|
| 95 | + 'submit_value' => __( 'Submit', 'formidable' ), |
|
| 96 | + 'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ), |
|
| 97 | + 'admin_permission' => __( 'You do not have permission to do that', 'formidable' ), |
|
| 98 | 98 | |
| 99 | - 'email_to' => '[admin_email]', |
|
| 100 | - ); |
|
| 101 | - } |
|
| 99 | + 'email_to' => '[admin_email]', |
|
| 100 | + ); |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | 103 | private function set_default_options() { |
| 104 | - $this->fill_recaptcha_settings(); |
|
| 105 | - |
|
| 106 | - if ( ! isset($this->load_style) ) { |
|
| 107 | - if ( ! isset($this->custom_style) ) { |
|
| 108 | - $this->custom_style = true; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - $this->load_style = 'all'; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - $this->fill_with_defaults(); |
|
| 115 | - |
|
| 116 | - if ( is_multisite() && is_admin() ) { |
|
| 117 | - $mu_menu = get_site_option('frm_admin_menu_name'); |
|
| 118 | - if ( $mu_menu && ! empty($mu_menu) ) { |
|
| 119 | - $this->menu = $mu_menu; |
|
| 120 | - $this->mu_menu = 1; |
|
| 121 | - } |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - $frm_roles = FrmAppHelper::frm_capabilities('pro'); |
|
| 125 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 126 | - if ( ! isset($this->$frm_role) ) { |
|
| 127 | - $this->$frm_role = 'administrator'; |
|
| 128 | - } |
|
| 129 | - } |
|
| 130 | - } |
|
| 104 | + $this->fill_recaptcha_settings(); |
|
| 105 | + |
|
| 106 | + if ( ! isset($this->load_style) ) { |
|
| 107 | + if ( ! isset($this->custom_style) ) { |
|
| 108 | + $this->custom_style = true; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + $this->load_style = 'all'; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + $this->fill_with_defaults(); |
|
| 115 | + |
|
| 116 | + if ( is_multisite() && is_admin() ) { |
|
| 117 | + $mu_menu = get_site_option('frm_admin_menu_name'); |
|
| 118 | + if ( $mu_menu && ! empty($mu_menu) ) { |
|
| 119 | + $this->menu = $mu_menu; |
|
| 120 | + $this->mu_menu = 1; |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + $frm_roles = FrmAppHelper::frm_capabilities('pro'); |
|
| 125 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 126 | + if ( ! isset($this->$frm_role) ) { |
|
| 127 | + $this->$frm_role = 'administrator'; |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | 132 | public function fill_with_defaults( $params = array() ) { |
| 133 | - $settings = $this->default_options(); |
|
| 133 | + $settings = $this->default_options(); |
|
| 134 | 134 | |
| 135 | - foreach ( $settings as $setting => $default ) { |
|
| 135 | + foreach ( $settings as $setting => $default ) { |
|
| 136 | 136 | if ( isset( $params[ 'frm_' . $setting ] ) ) { |
| 137 | 137 | $this->{$setting} = $params[ 'frm_' . $setting ]; |
| 138 | - } else if ( ! isset($this->{$setting}) ) { |
|
| 139 | - $this->{$setting} = $default; |
|
| 140 | - } |
|
| 138 | + } else if ( ! isset($this->{$setting}) ) { |
|
| 139 | + $this->{$setting} = $default; |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | 142 | if ( $setting == 'menu' && empty( $this->{$setting} ) ) { |
| 143 | 143 | $this->{$setting} = $default; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - unset($setting, $default); |
|
| 147 | - } |
|
| 148 | - } |
|
| 146 | + unset($setting, $default); |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - private function fill_recaptcha_settings() { |
|
| 151 | - $privkey = ''; |
|
| 150 | + private function fill_recaptcha_settings() { |
|
| 151 | + $privkey = ''; |
|
| 152 | 152 | $re_lang = ''; |
| 153 | 153 | |
| 154 | - if ( ! isset($this->pubkey) ) { |
|
| 155 | - // get the options from the database |
|
| 156 | - $recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha'); |
|
| 157 | - $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : ''; |
|
| 158 | - $privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey; |
|
| 159 | - $re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang; |
|
| 160 | - } |
|
| 154 | + if ( ! isset($this->pubkey) ) { |
|
| 155 | + // get the options from the database |
|
| 156 | + $recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha'); |
|
| 157 | + $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : ''; |
|
| 158 | + $privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey; |
|
| 159 | + $re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang; |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - if ( ! isset($this->re_msg) || empty($this->re_msg) ) { |
|
| 163 | - $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' ); |
|
| 164 | - } |
|
| 162 | + if ( ! isset($this->re_msg) || empty($this->re_msg) ) { |
|
| 163 | + $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' ); |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | - if ( ! isset($this->privkey) ) { |
|
| 167 | - $this->privkey = $privkey; |
|
| 168 | - } |
|
| 166 | + if ( ! isset($this->privkey) ) { |
|
| 167 | + $this->privkey = $privkey; |
|
| 168 | + } |
|
| 169 | 169 | |
| 170 | - if ( ! isset($this->re_lang) ) { |
|
| 171 | - $this->re_lang = $re_lang; |
|
| 172 | - } |
|
| 173 | - } |
|
| 170 | + if ( ! isset($this->re_lang) ) { |
|
| 171 | + $this->re_lang = $re_lang; |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - public function validate( $params, $errors ) { |
|
| 176 | - return apply_filters( 'frm_validate_settings', $errors, $params ); |
|
| 177 | - } |
|
| 175 | + public function validate( $params, $errors ) { |
|
| 176 | + return apply_filters( 'frm_validate_settings', $errors, $params ); |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | 179 | public function update( $params ) { |
| 180 | - $this->fill_with_defaults($params); |
|
| 181 | - $this->update_settings($params); |
|
| 180 | + $this->fill_with_defaults($params); |
|
| 181 | + $this->update_settings($params); |
|
| 182 | 182 | |
| 183 | - if ( $this->mu_menu ) { |
|
| 184 | - update_site_option('frm_admin_menu_name', $this->menu); |
|
| 185 | - } else if ( current_user_can('administrator') ) { |
|
| 186 | - update_site_option('frm_admin_menu_name', false); |
|
| 187 | - } |
|
| 183 | + if ( $this->mu_menu ) { |
|
| 184 | + update_site_option('frm_admin_menu_name', $this->menu); |
|
| 185 | + } else if ( current_user_can('administrator') ) { |
|
| 186 | + update_site_option('frm_admin_menu_name', false); |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - $this->update_roles($params); |
|
| 189 | + $this->update_roles($params); |
|
| 190 | 190 | |
| 191 | - do_action( 'frm_update_settings', $params ); |
|
| 192 | - } |
|
| 191 | + do_action( 'frm_update_settings', $params ); |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | 194 | private function update_settings( $params ) { |
| 195 | - $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0; |
|
| 195 | + $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0; |
|
| 196 | 196 | |
| 197 | - $this->pubkey = trim($params['frm_pubkey']); |
|
| 198 | - $this->privkey = $params['frm_privkey']; |
|
| 199 | - $this->re_lang = $params['frm_re_lang']; |
|
| 197 | + $this->pubkey = trim($params['frm_pubkey']); |
|
| 198 | + $this->privkey = $params['frm_privkey']; |
|
| 199 | + $this->re_lang = $params['frm_re_lang']; |
|
| 200 | 200 | $this->re_multi = isset( $params['frm_re_multi'] ) ? $params['frm_re_multi'] : 0; |
| 201 | 201 | |
| 202 | - $this->load_style = $params['frm_load_style']; |
|
| 203 | - $this->preview_page_id = (int) $params['frm-preview-page-id']; |
|
| 202 | + $this->load_style = $params['frm_load_style']; |
|
| 203 | + $this->preview_page_id = (int) $params['frm-preview-page-id']; |
|
| 204 | 204 | |
| 205 | - $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0; |
|
| 205 | + $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0; |
|
| 206 | 206 | $this->jquery_css = isset( $params['frm_jquery_css'] ) ? absint( $params['frm_jquery_css'] ) : 0; |
| 207 | 207 | $this->accordion_js = isset( $params['frm_accordion_js'] ) ? absint( $params['frm_accordion_js'] ) : 0; |
| 208 | 208 | $this->fade_form = isset( $params['frm_fade_form'] ) ? absint( $params['frm_fade_form'] ) : 0; |
| 209 | - } |
|
| 209 | + } |
|
| 210 | 210 | |
| 211 | 211 | private function update_roles( $params ) { |
| 212 | - global $wp_roles; |
|
| 212 | + global $wp_roles; |
|
| 213 | 213 | |
| 214 | - $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 215 | - $roles = get_editable_roles(); |
|
| 216 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 217 | - $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' ); |
|
| 214 | + $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 215 | + $roles = get_editable_roles(); |
|
| 216 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 217 | + $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' ); |
|
| 218 | 218 | |
| 219 | - // Make sure administrators always have permissions |
|
| 220 | - if ( ! in_array( 'administrator', $this->$frm_role ) ) { |
|
| 219 | + // Make sure administrators always have permissions |
|
| 220 | + if ( ! in_array( 'administrator', $this->$frm_role ) ) { |
|
| 221 | 221 | array_push( $this->$frm_role, 'administrator' ); |
| 222 | - } |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - foreach ( $roles as $role => $details ) { |
|
| 225 | - if ( in_array($role, $this->$frm_role) ) { |
|
| 226 | - $wp_roles->add_cap( $role, $frm_role ); |
|
| 227 | - } else { |
|
| 228 | - $wp_roles->remove_cap( $role, $frm_role ); |
|
| 229 | - } |
|
| 230 | - } |
|
| 224 | + foreach ( $roles as $role => $details ) { |
|
| 225 | + if ( in_array($role, $this->$frm_role) ) { |
|
| 226 | + $wp_roles->add_cap( $role, $frm_role ); |
|
| 227 | + } else { |
|
| 228 | + $wp_roles->remove_cap( $role, $frm_role ); |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | 231 | } |
| 232 | - } |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | 234 | public function store() { |
| 235 | - // Save the posted value in the database |
|
| 235 | + // Save the posted value in the database |
|
| 236 | 236 | |
| 237 | - update_option('frm_options', $this); |
|
| 237 | + update_option('frm_options', $this); |
|
| 238 | 238 | |
| 239 | - delete_transient('frm_options'); |
|
| 240 | - set_transient('frm_options', $this); |
|
| 239 | + delete_transient('frm_options'); |
|
| 240 | + set_transient('frm_options', $this); |
|
| 241 | 241 | |
| 242 | - do_action( 'frm_store_settings' ); |
|
| 243 | - } |
|
| 242 | + do_action( 'frm_store_settings' ); |
|
| 243 | + } |
|
| 244 | 244 | } |
@@ -30,19 +30,19 @@ discard block |
||
| 30 | 30 | public $re_multi; |
| 31 | 31 | |
| 32 | 32 | public function __construct() { |
| 33 | - if ( ! defined('ABSPATH') ) { |
|
| 34 | - die('You are not allowed to call this page directly.'); |
|
| 33 | + if ( ! defined( 'ABSPATH' ) ) { |
|
| 34 | + die( 'You are not allowed to call this page directly.' ); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - $settings = get_transient($this->option_name); |
|
| 37 | + $settings = get_transient( $this->option_name ); |
|
| 38 | 38 | |
| 39 | - if ( ! is_object($settings) ) { |
|
| 40 | - $settings = $this->translate_settings($settings); |
|
| 39 | + if ( ! is_object( $settings ) ) { |
|
| 40 | + $settings = $this->translate_settings( $settings ); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | foreach ( $settings as $setting_name => $setting ) { |
| 44 | 44 | $this->{$setting_name} = $setting; |
| 45 | - unset($setting_name, $setting); |
|
| 45 | + unset( $setting_name, $setting ); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $this->set_default_options(); |
@@ -50,24 +50,24 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | private function translate_settings( $settings ) { |
| 52 | 52 | if ( $settings ) { //workaround for W3 total cache conflict |
| 53 | - return unserialize(serialize($settings)); |
|
| 53 | + return unserialize( serialize( $settings ) ); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - $settings = get_option($this->option_name); |
|
| 57 | - if ( is_object($settings) ) { |
|
| 58 | - set_transient($this->option_name, $settings); |
|
| 56 | + $settings = get_option( $this->option_name ); |
|
| 57 | + if ( is_object( $settings ) ) { |
|
| 58 | + set_transient( $this->option_name, $settings ); |
|
| 59 | 59 | return $settings; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | // If unserializing didn't work |
| 63 | 63 | if ( $settings ) { //workaround for W3 total cache conflict |
| 64 | - $settings = unserialize(serialize($settings)); |
|
| 64 | + $settings = unserialize( serialize( $settings ) ); |
|
| 65 | 65 | } else { |
| 66 | 66 | $settings = $this; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - update_option($this->option_name, $settings); |
|
| 70 | - set_transient($this->option_name, $settings); |
|
| 69 | + update_option( $this->option_name, $settings ); |
|
| 70 | + set_transient( $this->option_name, $settings ); |
|
| 71 | 71 | |
| 72 | 72 | return $settings; |
| 73 | 73 | } |
@@ -103,8 +103,8 @@ discard block |
||
| 103 | 103 | private function set_default_options() { |
| 104 | 104 | $this->fill_recaptcha_settings(); |
| 105 | 105 | |
| 106 | - if ( ! isset($this->load_style) ) { |
|
| 107 | - if ( ! isset($this->custom_style) ) { |
|
| 106 | + if ( ! isset( $this->load_style ) ) { |
|
| 107 | + if ( ! isset( $this->custom_style ) ) { |
|
| 108 | 108 | $this->custom_style = true; |
| 109 | 109 | } |
| 110 | 110 | |
@@ -114,16 +114,16 @@ discard block |
||
| 114 | 114 | $this->fill_with_defaults(); |
| 115 | 115 | |
| 116 | 116 | if ( is_multisite() && is_admin() ) { |
| 117 | - $mu_menu = get_site_option('frm_admin_menu_name'); |
|
| 118 | - if ( $mu_menu && ! empty($mu_menu) ) { |
|
| 117 | + $mu_menu = get_site_option( 'frm_admin_menu_name' ); |
|
| 118 | + if ( $mu_menu && ! empty( $mu_menu ) ) { |
|
| 119 | 119 | $this->menu = $mu_menu; |
| 120 | 120 | $this->mu_menu = 1; |
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - $frm_roles = FrmAppHelper::frm_capabilities('pro'); |
|
| 124 | + $frm_roles = FrmAppHelper::frm_capabilities( 'pro' ); |
|
| 125 | 125 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
| 126 | - if ( ! isset($this->$frm_role) ) { |
|
| 126 | + if ( ! isset( $this->$frm_role ) ) { |
|
| 127 | 127 | $this->$frm_role = 'administrator'; |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -133,9 +133,9 @@ discard block |
||
| 133 | 133 | $settings = $this->default_options(); |
| 134 | 134 | |
| 135 | 135 | foreach ( $settings as $setting => $default ) { |
| 136 | - if ( isset( $params[ 'frm_' . $setting ] ) ) { |
|
| 137 | - $this->{$setting} = $params[ 'frm_' . $setting ]; |
|
| 138 | - } else if ( ! isset($this->{$setting}) ) { |
|
| 136 | + if ( isset( $params['frm_' . $setting] ) ) { |
|
| 137 | + $this->{$setting} = $params['frm_' . $setting]; |
|
| 138 | + } else if ( ! isset( $this->{$setting}) ) { |
|
| 139 | 139 | $this->{$setting} = $default; |
| 140 | 140 | } |
| 141 | 141 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | $this->{$setting} = $default; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - unset($setting, $default); |
|
| 146 | + unset( $setting, $default ); |
|
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | 149 | |
@@ -151,23 +151,23 @@ discard block |
||
| 151 | 151 | $privkey = ''; |
| 152 | 152 | $re_lang = ''; |
| 153 | 153 | |
| 154 | - if ( ! isset($this->pubkey) ) { |
|
| 154 | + if ( ! isset( $this->pubkey ) ) { |
|
| 155 | 155 | // get the options from the database |
| 156 | - $recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha'); |
|
| 157 | - $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : ''; |
|
| 158 | - $privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey; |
|
| 159 | - $re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang; |
|
| 156 | + $recaptcha_opt = is_multisite() ? get_site_option( 'recaptcha' ) : get_option( 'recaptcha' ); |
|
| 157 | + $this->pubkey = isset( $recaptcha_opt['pubkey'] ) ? $recaptcha_opt['pubkey'] : ''; |
|
| 158 | + $privkey = isset( $recaptcha_opt['privkey'] ) ? $recaptcha_opt['privkey'] : $privkey; |
|
| 159 | + $re_lang = isset( $recaptcha_opt['re_lang'] ) ? $recaptcha_opt['re_lang'] : $re_lang; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if ( ! isset($this->re_msg) || empty($this->re_msg) ) { |
|
| 162 | + if ( ! isset( $this->re_msg ) || empty( $this->re_msg ) ) { |
|
| 163 | 163 | $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' ); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - if ( ! isset($this->privkey) ) { |
|
| 166 | + if ( ! isset( $this->privkey ) ) { |
|
| 167 | 167 | $this->privkey = $privkey; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if ( ! isset($this->re_lang) ) { |
|
| 170 | + if ( ! isset( $this->re_lang ) ) { |
|
| 171 | 171 | $this->re_lang = $re_lang; |
| 172 | 172 | } |
| 173 | 173 | } |
@@ -177,24 +177,24 @@ discard block |
||
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | public function update( $params ) { |
| 180 | - $this->fill_with_defaults($params); |
|
| 181 | - $this->update_settings($params); |
|
| 180 | + $this->fill_with_defaults( $params ); |
|
| 181 | + $this->update_settings( $params ); |
|
| 182 | 182 | |
| 183 | 183 | if ( $this->mu_menu ) { |
| 184 | - update_site_option('frm_admin_menu_name', $this->menu); |
|
| 185 | - } else if ( current_user_can('administrator') ) { |
|
| 186 | - update_site_option('frm_admin_menu_name', false); |
|
| 184 | + update_site_option( 'frm_admin_menu_name', $this->menu ); |
|
| 185 | + } else if ( current_user_can( 'administrator' ) ) { |
|
| 186 | + update_site_option( 'frm_admin_menu_name', false ); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - $this->update_roles($params); |
|
| 189 | + $this->update_roles( $params ); |
|
| 190 | 190 | |
| 191 | 191 | do_action( 'frm_update_settings', $params ); |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | private function update_settings( $params ) { |
| 195 | - $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0; |
|
| 195 | + $this->mu_menu = isset( $params['frm_mu_menu'] ) ? $params['frm_mu_menu'] : 0; |
|
| 196 | 196 | |
| 197 | - $this->pubkey = trim($params['frm_pubkey']); |
|
| 197 | + $this->pubkey = trim( $params['frm_pubkey'] ); |
|
| 198 | 198 | $this->privkey = $params['frm_privkey']; |
| 199 | 199 | $this->re_lang = $params['frm_re_lang']; |
| 200 | 200 | $this->re_multi = isset( $params['frm_re_multi'] ) ? $params['frm_re_multi'] : 0; |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | $this->load_style = $params['frm_load_style']; |
| 203 | 203 | $this->preview_page_id = (int) $params['frm-preview-page-id']; |
| 204 | 204 | |
| 205 | - $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0; |
|
| 205 | + $this->use_html = isset( $params['frm_use_html'] ) ? $params['frm_use_html'] : 0; |
|
| 206 | 206 | $this->jquery_css = isset( $params['frm_jquery_css'] ) ? absint( $params['frm_jquery_css'] ) : 0; |
| 207 | 207 | $this->accordion_js = isset( $params['frm_accordion_js'] ) ? absint( $params['frm_accordion_js'] ) : 0; |
| 208 | 208 | $this->fade_form = isset( $params['frm_fade_form'] ) ? absint( $params['frm_fade_form'] ) : 0; |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | $frm_roles = FrmAppHelper::frm_capabilities(); |
| 215 | 215 | $roles = get_editable_roles(); |
| 216 | 216 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
| 217 | - $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' ); |
|
| 217 | + $this->$frm_role = (array) ( isset( $params[$frm_role] ) ? $params[$frm_role] : 'administrator' ); |
|
| 218 | 218 | |
| 219 | 219 | // Make sure administrators always have permissions |
| 220 | 220 | if ( ! in_array( 'administrator', $this->$frm_role ) ) { |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | foreach ( $roles as $role => $details ) { |
| 225 | - if ( in_array($role, $this->$frm_role) ) { |
|
| 225 | + if ( in_array( $role, $this->$frm_role ) ) { |
|
| 226 | 226 | $wp_roles->add_cap( $role, $frm_role ); |
| 227 | 227 | } else { |
| 228 | 228 | $wp_roles->remove_cap( $role, $frm_role ); |
@@ -234,10 +234,10 @@ discard block |
||
| 234 | 234 | public function store() { |
| 235 | 235 | // Save the posted value in the database |
| 236 | 236 | |
| 237 | - update_option('frm_options', $this); |
|
| 237 | + update_option( 'frm_options', $this ); |
|
| 238 | 238 | |
| 239 | - delete_transient('frm_options'); |
|
| 240 | - set_transient('frm_options', $this); |
|
| 239 | + delete_transient( 'frm_options' ); |
|
| 240 | + set_transient( 'frm_options', $this ); |
|
| 241 | 241 | |
| 242 | 242 | do_action( 'frm_store_settings' ); |
| 243 | 243 | } |