| @@ -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() { |
| @@ -11,17 +8,10 @@ | ||
| 11 | 8 | |
| 12 | 9 | add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' ); |
| 13 | 10 | } |
| 14 | 11 | |
| 15 | - /** | |
| 16 | - * Include license box template on demand. | |
| 17 | - * | |
| 18 | - * @return void | |
| 19 | - */ | |
| 20 | 12 | public static function license_box() { |
| 21 | - if ( ! current_user_can( 'activate_plugins' ) ) { | |
| 22 | - return; | |
| 23 | - } | |
| 13 | + $a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' ); | |
| 24 | 14 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' ); |
| 25 | 15 | } |
| 26 | 16 | |
| 27 | 17 | public static function display_form( $errors = array(), $message = '' ) { |
| @@ -37,13 +27,8 @@ | ||
| 37 | 27 | |
| 38 | 28 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' ); |
| 39 | 29 | } |
| 40 | 30 | |
| 41 | - /** | |
| 42 | - * Get sections to use for Global Settings. | |
| 43 | - * | |
| 44 | - * @return array<array> | |
| 45 | - */ | |
| 46 | 31 | private static function get_settings_tabs() { |
| 47 | 32 | $sections = array( |
| 48 | 33 | 'general' => array( |
| 49 | 34 | 'class' => __CLASS__, |
| @@ -62,54 +47,31 @@ | ||
| 62 | 47 | 'function' => 'permission_settings', |
| 63 | 48 | 'name' => __( 'Permissions', 'formidable' ), |
| 64 | 49 | 'icon' => 'frm_icon_font frm_lock_icon', |
| 65 | 50 | ), |
| 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 | - 'captcha' => array( | |
| 51 | + 'recaptcha' => array( | |
| 79 | 52 | 'class' => __CLASS__, |
| 80 | - 'function' => 'captcha_settings', | |
| 81 | - 'name' => __( 'Captcha', 'formidable' ), | |
| 53 | + 'function' => 'recaptcha_settings', | |
| 54 | + 'name' => __( 'reCaptcha', 'formidable' ), | |
| 82 | 55 | 'icon' => 'frm_icon_font frm_shield_check_icon', |
| 83 | 56 | ), |
| 84 | 57 | 'white_label' => array( |
| 85 | 58 | 'name' => __( 'White Labeling', 'formidable' ), |
| 86 | 59 | 'icon' => 'frm_icon_font frm_ghost_icon', |
| 87 | - 'html_class' => 'frm_show_upgrade_tab frm_noallow', | |
| 60 | + 'html_class' => 'frm_show_upgrade frm_noallow', | |
| 88 | 61 | 'data' => array( |
| 89 | - 'medium' => 'white-label', | |
| 90 | - 'upgrade' => __( 'White labeling options', 'formidable' ), | |
| 91 | - 'screenshot' => 'white-label.png', | |
| 62 | + 'medium' => 'white-label', | |
| 63 | + 'upgrade' => __( 'White labeling options', 'formidable' ), | |
| 92 | 64 | ), |
| 93 | 65 | ), |
| 94 | - 'inbox' => array( | |
| 95 | - 'name' => __( 'Inbox', 'formidable' ), | |
| 96 | - 'icon' => 'frm_icon_font frm_email_icon', | |
| 97 | - 'html_class' => 'frm_show_upgrade_tab frm_noallow', | |
| 98 | - 'data' => array( | |
| 99 | - 'medium' => 'inbox-settings', | |
| 100 | - 'upgrade' => __( 'Inbox settings', 'formidable' ), | |
| 101 | - 'screenshot' => 'inbox.png', | |
| 102 | - ), | |
| 103 | - ), | |
| 104 | 66 | ); |
| 105 | 67 | |
| 106 | 68 | if ( apply_filters( 'frm_include_addon_page', false ) ) { |
| 107 | - // If no addons need a license, skip this page | |
| 69 | + // if no addons need a license, skip this page | |
| 108 | 70 | $show_licenses = false; |
| 109 | 71 | $installed_addons = apply_filters( 'frm_installed_addons', array() ); |
| 110 | 72 | foreach ( $installed_addons as $installed_addon ) { |
| 111 | - 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' ) { | |
| 112 | 74 | $show_licenses = true; |
| 113 | 75 | break; |
| 114 | 76 | } |
| 115 | 77 | } |
| @@ -123,12 +85,8 @@ | ||
| 123 | 85 | 'ajax' => true, |
| 124 | 86 | ); |
| 125 | 87 | } |
| 126 | 88 | } |
| 127 | - | |
| 128 | - /** | |
| 129 | - * @param array<array> $sections | |
| 130 | - */ | |
| 131 | 89 | $sections = apply_filters( 'frm_add_settings_section', $sections ); |
| 132 | 90 | |
| 133 | 91 | $sections['misc'] = array( |
| 134 | 92 | 'name' => __( 'Miscellaneous', 'formidable' ), |
| @@ -207,13 +165,13 @@ | ||
| 207 | 165 | |
| 208 | 166 | /** |
| 209 | 167 | * @since 4.0 |
| 210 | 168 | */ |
| 211 | - public static function captcha_settings() { | |
| 169 | + public static function recaptcha_settings() { | |
| 212 | 170 | $frm_settings = FrmAppHelper::get_settings(); |
| 213 | 171 | $captcha_lang = FrmAppHelper::locales( 'captcha' ); |
| 214 | 172 | |
| 215 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/captcha/captcha.php' ); | |
| 173 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/recaptcha.php' ); | |
| 216 | 174 | } |
| 217 | 175 | |
| 218 | 176 | /** |
| 219 | 177 | * @since 4.0 |
| @@ -233,21 +191,14 @@ | ||
| 233 | 191 | |
| 234 | 192 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php' ); |
| 235 | 193 | } |
| 236 | 194 | |
| 237 | - /** | |
| 238 | - * Save form data submitted from the Global settings page. | |
| 239 | - * | |
| 240 | - * @param string|bool $stop_load | |
| 241 | - * | |
| 242 | - * @return void | |
| 243 | - */ | |
| 244 | 195 | public static function process_form( $stop_load = false ) { |
| 245 | 196 | global $frm_vars; |
| 246 | 197 | |
| 247 | 198 | $frm_settings = FrmAppHelper::get_settings(); |
| 199 | + | |
| 248 | 200 | $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' ); |
| 249 | - | |
| 250 | 201 | if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) { |
| 251 | 202 | wp_die( esc_html( $frm_settings->admin_permission ) ); |
| 252 | 203 | } |
| 253 | 204 | |
| @@ -253,14 +204,14 @@ | ||
| 253 | 204 | |
| 254 | 205 | $errors = array(); |
| 255 | 206 | $message = ''; |
| 256 | 207 | |
| 257 | - if ( empty( $frm_vars['settings_routed'] ) ) { | |
| 208 | + if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) { | |
| 258 | 209 | $errors = $frm_settings->validate( $_POST, array() ); |
| 259 | 210 | |
| 260 | 211 | $frm_settings->update( wp_unslash( $_POST ) ); |
| 261 | 212 | |
| 262 | - if ( ! $errors ) { | |
| 213 | + if ( empty( $errors ) ) { | |
| 263 | 214 | $frm_settings->store(); |
| 264 | 215 | $message = __( 'Settings Saved', 'formidable' ); |
| 265 | 216 | } |
| 266 | 217 | } else { |
| @@ -266,10 +217,11 @@ | ||
| 266 | 217 | } else { |
| 267 | 218 | $message = __( 'Settings Saved', 'formidable' ); |
| 268 | 219 | } |
| 269 | 220 | |
| 270 | - if ( $stop_load === 'stop_load' ) { | |
| 221 | + if ( $stop_load == 'stop_load' ) { | |
| 271 | 222 | $frm_vars['settings_routed'] = true; |
| 223 | + | |
| 272 | 224 | return; |
| 273 | 225 | } |
| 274 | 226 | |
| 275 | 227 | self::display_form( $errors, $message ); |
| @@ -341,50 +293,5 @@ | ||
| 341 | 293 | |
| 342 | 294 | wp_send_json_success(); |
| 343 | 295 | } |
| 344 | 296 | |
| 345 | - /** | |
| 346 | - * Autocomplete page admin ajax endpoint | |
| 347 | - * | |
| 348 | - * @since 4.03.06 | |
| 349 | - */ | |
| 350 | - public static function page_search() { | |
| 351 | - FrmAppHelper::permission_check( 'frm_edit_forms' ); | |
| 352 | - check_ajax_referer( 'frm_ajax', 'nonce' ); | |
| 353 | - | |
| 354 | - global $wpdb; | |
| 355 | - | |
| 356 | - $term = FrmAppHelper::get_param( 'term', '', 'get', 'sanitize_text_field' ); | |
| 357 | - $post_type = FrmAppHelper::get_param( 'post_type', 'page', 'get', 'sanitize_text_field' ); | |
| 358 | - | |
| 359 | - $where = array( | |
| 360 | - 'post_status' => 'publish', | |
| 361 | - 'post_type' => $post_type, | |
| 362 | - 'post_title LIKE' => $term, | |
| 363 | - ); | |
| 364 | - | |
| 365 | - $atts = array( | |
| 366 | - 'limit' => 25, | |
| 367 | - 'order_by' => 'post_title', | |
| 368 | - ); | |
| 369 | - | |
| 370 | - $pages = FrmDb::get_results( $wpdb->posts, $where, 'ID, post_title', $atts ); | |
| 371 | - | |
| 372 | - $results = array(); | |
| 373 | - foreach ( $pages as $page ) { | |
| 374 | - $results[] = array( | |
| 375 | - 'value' => $page->ID, | |
| 376 | - 'label' => $page->post_title, | |
| 377 | - ); | |
| 378 | - } | |
| 379 | - | |
| 380 | - wp_send_json( $results ); | |
| 381 | - } | |
| 382 | - | |
| 383 | - /** | |
| 384 | - * @deprecated 6.0 use FrmSettingsController::captcha_settings(). | |
| 385 | - */ | |
| 386 | - public static function recaptcha_settings() { | |
| 387 | - _deprecated_function( __FUNCTION__, '6.0', 'FrmSettingsController::captcha_settings()' ); | |
| 388 | - self::captcha_settings(); | |
| 389 | - } | |
| 390 | 297 | } |