| @@ -11,17 +11,10 @@ | ||
| 11 | 11 | |
| 12 | 12 | add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' ); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - /** | |
| 16 | - * Include license box template on demand. | |
| 17 | - * | |
| 18 | - * @return void | |
| 19 | - */ | |
| 20 | 15 | public static function license_box() { |
| 21 | - if ( ! current_user_can( 'activate_plugins' ) ) { | |
| 22 | - return; | |
| 23 | - } | |
| 16 | + $a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' ); | |
| 24 | 17 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' ); |
| 25 | 18 | } |
| 26 | 19 | |
| 27 | 20 | public static function display_form( $errors = array(), $message = '' ) { |
| @@ -37,13 +30,8 @@ | ||
| 37 | 30 | |
| 38 | 31 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' ); |
| 39 | 32 | } |
| 40 | 33 | |
| 41 | - /** | |
| 42 | - * Get sections to use for Global Settings. | |
| 43 | - * | |
| 44 | - * @return array<array> | |
| 45 | - */ | |
| 46 | 34 | private static function get_settings_tabs() { |
| 47 | 35 | $sections = array( |
| 48 | 36 | 'general' => array( |
| 49 | 37 | 'class' => __CLASS__, |
| @@ -62,24 +50,12 @@ | ||
| 62 | 50 | 'function' => 'permission_settings', |
| 63 | 51 | 'name' => __( 'Permissions', 'formidable' ), |
| 64 | 52 | 'icon' => 'frm_icon_font frm_lock_icon', |
| 65 | 53 | ), |
| 66 | - 'custom_css' => array( | |
| 67 | - 'class' => 'FrmStylesController', | |
| 68 | - 'function' => 'custom_css', | |
| 69 | - 'name' => __( 'Custom CSS', 'formidable' ), | |
| 70 | - 'icon' => 'frm_icon_font frm_code_icon', | |
| 71 | - ), | |
| 72 | - 'manage_styles' => array( | |
| 73 | - 'class' => 'FrmStylesController', | |
| 74 | - 'function' => 'manage', | |
| 75 | - 'name' => __( 'Manage Styles', 'formidable' ), | |
| 76 | - 'icon' => 'frm_icon_font frm_pallet_icon', | |
| 77 | - ), | |
| 78 | 54 | 'captcha' => array( |
| 79 | 55 | 'class' => __CLASS__, |
| 80 | 56 | 'function' => 'captcha_settings', |
| 81 | - 'name' => __( 'Captcha', 'formidable' ), | |
| 57 | + 'name' => __( 'CAPTCHA', 'formidable' ), | |
| 82 | 58 | 'icon' => 'frm_icon_font frm_shield_check_icon', |
| 83 | 59 | ), |
| 84 | 60 | 'white_label' => array( |
| 85 | 61 | 'name' => __( 'White Labeling', 'formidable' ), |
| @@ -103,9 +79,9 @@ | ||
| 103 | 79 | ), |
| 104 | 80 | ); |
| 105 | 81 | |
| 106 | 82 | if ( apply_filters( 'frm_include_addon_page', false ) ) { |
| 107 | - // If no addons need a license, skip this page | |
| 83 | + // if no addons need a license, skip this page | |
| 108 | 84 | $show_licenses = false; |
| 109 | 85 | $installed_addons = apply_filters( 'frm_installed_addons', array() ); |
| 110 | 86 | foreach ( $installed_addons as $installed_addon ) { |
| 111 | 87 | if ( ! $installed_addon->is_parent_licence && $installed_addon->plugin_name != 'Formidable Pro' && $installed_addon->needs_license ) { |
| @@ -123,12 +99,8 @@ | ||
| 123 | 99 | 'ajax' => true, |
| 124 | 100 | ); |
| 125 | 101 | } |
| 126 | 102 | } |
| 127 | - | |
| 128 | - /** | |
| 129 | - * @param array<array> $sections | |
| 130 | - */ | |
| 131 | 103 | $sections = apply_filters( 'frm_add_settings_section', $sections ); |
| 132 | 104 | |
| 133 | 105 | $sections['misc'] = array( |
| 134 | 106 | 'name' => __( 'Miscellaneous', 'formidable' ), |
| @@ -184,38 +156,17 @@ | ||
| 184 | 156 | wp_die(); |
| 185 | 157 | } |
| 186 | 158 | |
| 187 | 159 | /** |
| 188 | - * Render the general global settings section. | |
| 189 | - * | |
| 190 | 160 | * @since 4.0 |
| 191 | - * | |
| 192 | - * @return void | |
| 193 | 161 | */ |
| 194 | 162 | public static function general_settings() { |
| 195 | 163 | $frm_settings = FrmAppHelper::get_settings(); |
| 196 | - $uploads = wp_upload_dir(); | |
| 197 | - $target_path = $uploads['basedir'] . '/formidable/css'; | |
| 198 | 164 | |
| 199 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/general.php'; | |
| 200 | - } | |
| 165 | + $uploads = wp_upload_dir(); | |
| 166 | + $target_path = $uploads['basedir'] . '/formidable/css'; | |
| 201 | 167 | |
| 202 | - /** | |
| 203 | - * Render the global currency selector if Pro is up to date. | |
| 204 | - * | |
| 205 | - * @param FrmSettings $frm_settings | |
| 206 | - * @param string $more_html | |
| 207 | - * @return void | |
| 208 | - */ | |
| 209 | - public static function maybe_render_currency_selector( $frm_settings, $more_html ) { | |
| 210 | - if ( false !== strpos( $more_html, 'id="frm_currency"' ) ) { | |
| 211 | - // Avoid rendering the Currency setting if it gets rendered from the frm_settings_form hook. | |
| 212 | - // This is for backward compatibility. If Pro is outdated there won't be two currency dropdowns. | |
| 213 | - return; | |
| 214 | - } | |
| 215 | - | |
| 216 | - $currencies = FrmCurrencyHelper::get_currencies(); | |
| 217 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/_currency.php'; | |
| 168 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/general.php' ); | |
| 218 | 169 | } |
| 219 | 170 | |
| 220 | 171 | /** |
| 221 | 172 | * @since 4.0 |
| @@ -254,21 +205,14 @@ | ||
| 254 | 205 | |
| 255 | 206 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php' ); |
| 256 | 207 | } |
| 257 | 208 | |
| 258 | - /** | |
| 259 | - * Save form data submitted from the Global settings page. | |
| 260 | - * | |
| 261 | - * @param string|bool $stop_load | |
| 262 | - * | |
| 263 | - * @return void | |
| 264 | - */ | |
| 265 | 209 | public static function process_form( $stop_load = false ) { |
| 266 | 210 | global $frm_vars; |
| 267 | 211 | |
| 268 | 212 | $frm_settings = FrmAppHelper::get_settings(); |
| 213 | + | |
| 269 | 214 | $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' ); |
| 270 | - | |
| 271 | 215 | if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) { |
| 272 | 216 | wp_die( esc_html( $frm_settings->admin_permission ) ); |
| 273 | 217 | } |
| 274 | 218 | |
| @@ -274,14 +218,14 @@ | ||
| 274 | 218 | |
| 275 | 219 | $errors = array(); |
| 276 | 220 | $message = ''; |
| 277 | 221 | |
| 278 | - if ( empty( $frm_vars['settings_routed'] ) ) { | |
| 222 | + if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) { | |
| 279 | 223 | $errors = $frm_settings->validate( $_POST, array() ); |
| 280 | 224 | |
| 281 | 225 | $frm_settings->update( wp_unslash( $_POST ) ); |
| 282 | 226 | |
| 283 | - if ( ! $errors ) { | |
| 227 | + if ( empty( $errors ) ) { | |
| 284 | 228 | $frm_settings->store(); |
| 285 | 229 | $message = __( 'Settings Saved', 'formidable' ); |
| 286 | 230 | } |
| 287 | 231 | } else { |
| @@ -287,10 +231,11 @@ | ||
| 287 | 231 | } else { |
| 288 | 232 | $message = __( 'Settings Saved', 'formidable' ); |
| 289 | 233 | } |
| 290 | 234 | |
| 291 | - if ( $stop_load === 'stop_load' ) { | |
| 235 | + if ( $stop_load == 'stop_load' ) { | |
| 292 | 236 | $frm_vars['settings_routed'] = true; |
| 237 | + | |
| 293 | 238 | return; |
| 294 | 239 | } |
| 295 | 240 | |
| 296 | 241 | self::display_form( $errors, $message ); |
| @@ -401,11 +346,11 @@ | ||
| 401 | 346 | wp_send_json( $results ); |
| 402 | 347 | } |
| 403 | 348 | |
| 404 | 349 | /** |
| 405 | - * @deprecated 6.0 use FrmSettingsController::captcha_settings(). | |
| 350 | + * @deprecated x.x use FrmSettingsController::captcha_settings(). | |
| 406 | 351 | */ |
| 407 | 352 | public static function recaptcha_settings() { |
| 408 | - _deprecated_function( __FUNCTION__, '6.0', 'FrmSettingsController::captcha_settings()' ); | |
| 353 | + _deprecated_function( __FUNCTION__, 'x.x', 'FrmSettingsController::captcha_settings()' ); | |
| 409 | 354 | self::captcha_settings(); |
| 410 | 355 | } |
| 411 | 356 | } |