| @@ -1,8 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 3 | - die( 'You are not allowed to call this page directly.' ); | |
| 4 | -} | |
| 5 | 2 | |
| 6 | 3 | class FrmSettingsController { |
| 7 | 4 | |
| 8 | 5 | public static function menu() { |
| @@ -30,13 +27,8 @@ | ||
| 30 | 27 | |
| 31 | 28 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' ); |
| 32 | 29 | } |
| 33 | 30 | |
| 34 | - /** | |
| 35 | - * Get sections to use for Global Settings. | |
| 36 | - * | |
| 37 | - * @return array<array> | |
| 38 | - */ | |
| 39 | 31 | private static function get_settings_tabs() { |
| 40 | 32 | $sections = array( |
| 41 | 33 | 'general' => array( |
| 42 | 34 | 'class' => __CLASS__, |
| @@ -55,54 +47,31 @@ | ||
| 55 | 47 | 'function' => 'permission_settings', |
| 56 | 48 | 'name' => __( 'Permissions', 'formidable' ), |
| 57 | 49 | 'icon' => 'frm_icon_font frm_lock_icon', |
| 58 | 50 | ), |
| 59 | - 'custom_css' => array( | |
| 60 | - 'class' => 'FrmStylesController', | |
| 61 | - 'function' => 'custom_css', | |
| 62 | - 'name' => __( 'Custom CSS', 'formidable' ), | |
| 63 | - 'icon' => 'frm_icon_font frm_code_icon', | |
| 64 | - ), | |
| 65 | - 'manage_styles' => array( | |
| 66 | - 'class' => 'FrmStylesController', | |
| 67 | - 'function' => 'manage', | |
| 68 | - 'name' => __( 'Manage Styles', 'formidable' ), | |
| 69 | - 'icon' => 'frm_icon_font frm_pallet_icon', | |
| 70 | - ), | |
| 71 | - 'captcha' => array( | |
| 51 | + 'recaptcha' => array( | |
| 72 | 52 | 'class' => __CLASS__, |
| 73 | - 'function' => 'captcha_settings', | |
| 74 | - 'name' => __( 'Captcha', 'formidable' ), | |
| 53 | + 'function' => 'recaptcha_settings', | |
| 54 | + 'name' => __( 'reCaptcha', 'formidable' ), | |
| 75 | 55 | 'icon' => 'frm_icon_font frm_shield_check_icon', |
| 76 | 56 | ), |
| 77 | 57 | 'white_label' => array( |
| 78 | 58 | 'name' => __( 'White Labeling', 'formidable' ), |
| 79 | 59 | 'icon' => 'frm_icon_font frm_ghost_icon', |
| 80 | - 'html_class' => 'frm_show_upgrade_tab frm_noallow', | |
| 60 | + 'html_class' => 'frm_show_upgrade frm_noallow', | |
| 81 | 61 | 'data' => array( |
| 82 | - 'medium' => 'white-label', | |
| 83 | - 'upgrade' => __( 'White labeling options', 'formidable' ), | |
| 84 | - 'screenshot' => 'white-label.png', | |
| 62 | + 'medium' => 'white-label', | |
| 63 | + 'upgrade' => __( 'White labeling options', 'formidable' ), | |
| 85 | 64 | ), |
| 86 | 65 | ), |
| 87 | - 'inbox' => array( | |
| 88 | - 'name' => __( 'Inbox', 'formidable' ), | |
| 89 | - 'icon' => 'frm_icon_font frm_email_icon', | |
| 90 | - 'html_class' => 'frm_show_upgrade_tab frm_noallow', | |
| 91 | - 'data' => array( | |
| 92 | - 'medium' => 'inbox-settings', | |
| 93 | - 'upgrade' => __( 'Inbox settings', 'formidable' ), | |
| 94 | - 'screenshot' => 'inbox.png', | |
| 95 | - ), | |
| 96 | - ), | |
| 97 | 66 | ); |
| 98 | 67 | |
| 99 | 68 | if ( apply_filters( 'frm_include_addon_page', false ) ) { |
| 100 | - // If no addons need a license, skip this page | |
| 69 | + // if no addons need a license, skip this page | |
| 101 | 70 | $show_licenses = false; |
| 102 | 71 | $installed_addons = apply_filters( 'frm_installed_addons', array() ); |
| 103 | 72 | foreach ( $installed_addons as $installed_addon ) { |
| 104 | - if ( ! $installed_addon->is_parent_licence && $installed_addon->plugin_name != 'Formidable Pro' && $installed_addon->needs_license ) { | |
| 73 | + if ( ! $installed_addon->is_parent_licence && $installed_addon->plugin_name != 'Formidable Pro' ) { | |
| 105 | 74 | $show_licenses = true; |
| 106 | 75 | break; |
| 107 | 76 | } |
| 108 | 77 | } |
| @@ -116,12 +85,8 @@ | ||
| 116 | 85 | 'ajax' => true, |
| 117 | 86 | ); |
| 118 | 87 | } |
| 119 | 88 | } |
| 120 | - | |
| 121 | - /** | |
| 122 | - * @param array<array> $sections | |
| 123 | - */ | |
| 124 | 89 | $sections = apply_filters( 'frm_add_settings_section', $sections ); |
| 125 | 90 | |
| 126 | 91 | $sections['misc'] = array( |
| 127 | 92 | 'name' => __( 'Miscellaneous', 'formidable' ), |
| @@ -200,13 +165,13 @@ | ||
| 200 | 165 | |
| 201 | 166 | /** |
| 202 | 167 | * @since 4.0 |
| 203 | 168 | */ |
| 204 | - public static function captcha_settings() { | |
| 169 | + public static function recaptcha_settings() { | |
| 205 | 170 | $frm_settings = FrmAppHelper::get_settings(); |
| 206 | 171 | $captcha_lang = FrmAppHelper::locales( 'captcha' ); |
| 207 | 172 | |
| 208 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/captcha/captcha.php' ); | |
| 173 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/recaptcha.php' ); | |
| 209 | 174 | } |
| 210 | 175 | |
| 211 | 176 | /** |
| 212 | 177 | * @since 4.0 |
| @@ -226,21 +191,14 @@ | ||
| 226 | 191 | |
| 227 | 192 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php' ); |
| 228 | 193 | } |
| 229 | 194 | |
| 230 | - /** | |
| 231 | - * Save form data submitted from the Global settings page. | |
| 232 | - * | |
| 233 | - * @param string|bool $stop_load | |
| 234 | - * | |
| 235 | - * @return void | |
| 236 | - */ | |
| 237 | 195 | public static function process_form( $stop_load = false ) { |
| 238 | 196 | global $frm_vars; |
| 239 | 197 | |
| 240 | 198 | $frm_settings = FrmAppHelper::get_settings(); |
| 199 | + | |
| 241 | 200 | $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' ); |
| 242 | - | |
| 243 | 201 | if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) { |
| 244 | 202 | wp_die( esc_html( $frm_settings->admin_permission ) ); |
| 245 | 203 | } |
| 246 | 204 | |
| @@ -246,14 +204,14 @@ | ||
| 246 | 204 | |
| 247 | 205 | $errors = array(); |
| 248 | 206 | $message = ''; |
| 249 | 207 | |
| 250 | - if ( empty( $frm_vars['settings_routed'] ) ) { | |
| 208 | + if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) { | |
| 251 | 209 | $errors = $frm_settings->validate( $_POST, array() ); |
| 252 | 210 | |
| 253 | 211 | $frm_settings->update( wp_unslash( $_POST ) ); |
| 254 | 212 | |
| 255 | - if ( ! $errors ) { | |
| 213 | + if ( empty( $errors ) ) { | |
| 256 | 214 | $frm_settings->store(); |
| 257 | 215 | $message = __( 'Settings Saved', 'formidable' ); |
| 258 | 216 | } |
| 259 | 217 | } else { |
| @@ -259,10 +217,11 @@ | ||
| 259 | 217 | } else { |
| 260 | 218 | $message = __( 'Settings Saved', 'formidable' ); |
| 261 | 219 | } |
| 262 | 220 | |
| 263 | - if ( $stop_load === 'stop_load' ) { | |
| 221 | + if ( $stop_load == 'stop_load' ) { | |
| 264 | 222 | $frm_vars['settings_routed'] = true; |
| 223 | + | |
| 265 | 224 | return; |
| 266 | 225 | } |
| 267 | 226 | |
| 268 | 227 | self::display_form( $errors, $message ); |
| @@ -334,50 +293,5 @@ | ||
| 334 | 293 | |
| 335 | 294 | wp_send_json_success(); |
| 336 | 295 | } |
| 337 | 296 | |
| 338 | - /** | |
| 339 | - * Autocomplete page admin ajax endpoint | |
| 340 | - * | |
| 341 | - * @since 4.03.06 | |
| 342 | - */ | |
| 343 | - public static function page_search() { | |
| 344 | - FrmAppHelper::permission_check( 'frm_edit_forms' ); | |
| 345 | - check_ajax_referer( 'frm_ajax', 'nonce' ); | |
| 346 | - | |
| 347 | - global $wpdb; | |
| 348 | - | |
| 349 | - $term = FrmAppHelper::get_param( 'term', '', 'get', 'sanitize_text_field' ); | |
| 350 | - $post_type = FrmAppHelper::get_param( 'post_type', 'page', 'get', 'sanitize_text_field' ); | |
| 351 | - | |
| 352 | - $where = array( | |
| 353 | - 'post_status' => 'publish', | |
| 354 | - 'post_type' => $post_type, | |
| 355 | - 'post_title LIKE' => $term, | |
| 356 | - ); | |
| 357 | - | |
| 358 | - $atts = array( | |
| 359 | - 'limit' => 25, | |
| 360 | - 'order_by' => 'post_title', | |
| 361 | - ); | |
| 362 | - | |
| 363 | - $pages = FrmDb::get_results( $wpdb->posts, $where, 'ID, post_title', $atts ); | |
| 364 | - | |
| 365 | - $results = array(); | |
| 366 | - foreach ( $pages as $page ) { | |
| 367 | - $results[] = array( | |
| 368 | - 'value' => $page->ID, | |
| 369 | - 'label' => $page->post_title, | |
| 370 | - ); | |
| 371 | - } | |
| 372 | - | |
| 373 | - wp_send_json( $results ); | |
| 374 | - } | |
| 375 | - | |
| 376 | - /** | |
| 377 | - * @deprecated 6.0 use FrmSettingsController::captcha_settings(). | |
| 378 | - */ | |
| 379 | - public static function recaptcha_settings() { | |
| 380 | - _deprecated_function( __FUNCTION__, '6.0', 'FrmSettingsController::captcha_settings()' ); | |
| 381 | - self::captcha_settings(); | |
| 382 | - } | |
| 383 | 297 | } |