| @@ -4,25 +4,13 @@ | ||
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | class FrmSettingsController { |
| 7 | 7 | |
| 8 | - /** | |
| 9 | - * Payments sections are removed from the top level and added to a payments section. | |
| 10 | - * | |
| 11 | - * @since 6.22.1 | |
| 12 | - * | |
| 13 | - * @var array | |
| 14 | - */ | |
| 15 | - private static $removed_payments_sections = array(); | |
| 16 | - | |
| 17 | - /** | |
| 18 | - * @return void | |
| 19 | - */ | |
| 20 | 8 | public static function menu() { |
| 21 | 9 | // Make sure admins can see the menu items |
| 22 | 10 | FrmAppHelper::force_capability( 'frm_change_settings' ); |
| 23 | 11 | |
| 24 | - add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 12 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' ); | |
| 25 | 13 | } |
| 26 | 14 | |
| 27 | 15 | /** |
| 28 | 16 | * Include license box template on demand. |
| @@ -35,27 +23,19 @@ | ||
| 35 | 23 | } |
| 36 | 24 | include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php'; |
| 37 | 25 | } |
| 38 | 26 | |
| 39 | - /** | |
| 40 | - * @param array $errors | |
| 41 | - * @param string $message | |
| 42 | - * | |
| 43 | - * @return void | |
| 44 | - */ | |
| 45 | 27 | public static function display_form( $errors = array(), $message = '' ) { |
| 46 | 28 | global $frm_vars; |
| 47 | 29 | |
| 48 | 30 | $frm_settings = FrmAppHelper::get_settings(); |
| 49 | - $uploads = wp_upload_dir(); | |
| 50 | - $target_path = $uploads['basedir'] . '/formidable/css'; | |
| 51 | - $sections = self::get_settings_tabs(); | |
| 52 | - $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' ); | |
| 53 | 31 | |
| 54 | - if ( in_array( $current, array( 'stripe_settings', 'square_settings', 'authorize_net_settings', 'paypal_settings' ), true ) ) { | |
| 55 | - $current = 'payments_settings'; | |
| 56 | - } | |
| 32 | + $uploads = wp_upload_dir(); | |
| 33 | + $target_path = $uploads['basedir'] . '/formidable/css'; | |
| 57 | 34 | |
| 35 | + $sections = self::get_settings_tabs(); | |
| 36 | + $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' ); | |
| 37 | + | |
| 58 | 38 | require FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php'; |
| 59 | 39 | } |
| 60 | 40 | |
| 61 | 41 | /** |
| @@ -65,75 +45,61 @@ | ||
| 65 | 45 | */ |
| 66 | 46 | private static function get_settings_tabs() { |
| 67 | 47 | $sections = array( |
| 68 | 48 | 'general' => array( |
| 69 | - 'class' => self::class, | |
| 49 | + 'class' => __CLASS__, | |
| 70 | 50 | 'function' => 'general_settings', |
| 71 | 51 | 'name' => __( 'General Settings', 'formidable' ), |
| 72 | - 'icon' => 'frmfont frm_settings_icon', | |
| 52 | + 'icon' => 'frm_icon_font frm_settings_icon', | |
| 73 | 53 | ), |
| 74 | 54 | 'messages' => array( |
| 75 | - 'class' => self::class, | |
| 55 | + 'class' => __CLASS__, | |
| 76 | 56 | 'function' => 'message_settings', |
| 77 | 57 | 'name' => __( 'Message Defaults', 'formidable' ), |
| 78 | - 'icon' => 'frmfont frm_stamp_icon', | |
| 58 | + 'icon' => 'frm_icon_font frm_stamp_icon', | |
| 79 | 59 | ), |
| 80 | 60 | 'permissions' => array( |
| 81 | - 'class' => self::class, | |
| 61 | + 'class' => __CLASS__, | |
| 82 | 62 | 'function' => 'permission_settings', |
| 83 | 63 | 'name' => __( 'Permissions', 'formidable' ), |
| 84 | - 'icon' => 'frmfont frm_lock_icon', | |
| 64 | + 'icon' => 'frm_icon_font frm_lock_icon', | |
| 85 | 65 | ), |
| 86 | - 'payments' => array( | |
| 87 | - 'name' => __( 'Payments', 'formidable' ), | |
| 88 | - 'icon' => 'frmfont frm_simple_cc_icon', | |
| 89 | - 'class' => self::class, | |
| 90 | - 'function' => 'payments_settings', | |
| 91 | - ), | |
| 92 | 66 | 'custom_css' => array( |
| 93 | 67 | 'class' => 'FrmStylesController', |
| 94 | 68 | 'function' => 'custom_css', |
| 95 | 69 | 'name' => __( 'Custom CSS', 'formidable' ), |
| 96 | - 'icon' => 'frmfont frm_code_icon', | |
| 70 | + 'icon' => 'frm_icon_font frm_code_icon', | |
| 97 | 71 | ), |
| 98 | 72 | 'manage_styles' => array( |
| 99 | 73 | 'class' => 'FrmStylesController', |
| 100 | 74 | 'function' => 'manage', |
| 101 | 75 | 'name' => __( 'Manage Styles', 'formidable' ), |
| 102 | - 'icon' => 'frmfont frm_pallet_icon', | |
| 76 | + 'icon' => 'frm_icon_font frm_pallet_icon', | |
| 103 | 77 | ), |
| 104 | 78 | 'captcha' => array( |
| 105 | - 'class' => self::class, | |
| 79 | + 'class' => __CLASS__, | |
| 106 | 80 | 'function' => 'captcha_settings', |
| 107 | - 'name' => __( 'Captcha/Spam', 'formidable' ), | |
| 108 | - 'icon' => 'frmfont frm_shield_check_icon', | |
| 81 | + 'name' => __( 'Captcha', 'formidable' ), | |
| 82 | + 'icon' => 'frm_icon_font frm_shield_check_icon', | |
| 109 | 83 | ), |
| 110 | - 'email' => array( | |
| 111 | - 'class' => self::class, | |
| 112 | - 'function' => 'email_settings', | |
| 113 | - 'name' => __( 'Email', 'formidable' ), | |
| 114 | - 'icon' => 'frmfont frm_email_icon', | |
| 115 | - ), | |
| 116 | 84 | 'white_label' => array( |
| 117 | 85 | 'name' => __( 'White Labeling', 'formidable' ), |
| 118 | - 'icon' => 'frmfont frm_ghost_icon', | |
| 86 | + 'icon' => 'frm_icon_font frm_ghost_icon', | |
| 119 | 87 | 'html_class' => 'frm_show_upgrade_tab frm_noallow', |
| 120 | 88 | 'data' => array( |
| 121 | 89 | 'medium' => 'white-label', |
| 122 | 90 | 'upgrade' => __( 'White labeling options', 'formidable' ), |
| 123 | 91 | 'screenshot' => 'white-label.png', |
| 124 | - 'learn-more' => FrmAppHelper::get_doc_url( 'features/white-label-form-builder-wordpress', 'white-labeling-global-settings', false ), | |
| 125 | 92 | ), |
| 126 | 93 | ), |
| 127 | 94 | 'inbox' => array( |
| 128 | 95 | 'name' => __( 'Inbox', 'formidable' ), |
| 129 | - 'icon' => 'frmfont frm_email_icon', | |
| 96 | + 'icon' => 'frm_icon_font frm_email_icon', | |
| 130 | 97 | 'html_class' => 'frm_show_upgrade_tab frm_noallow', |
| 131 | 98 | 'data' => array( |
| 132 | 99 | 'medium' => 'inbox-settings', |
| 133 | 100 | 'upgrade' => __( 'Inbox settings', 'formidable' ), |
| 134 | 101 | 'screenshot' => 'inbox.png', |
| 135 | - 'learn-more' => FrmAppHelper::get_doc_url( 'global-settings-overview/#kb-inbox', 'inbox-global-settings' ), | |
| 136 | 102 | ), |
| 137 | 103 | ), |
| 138 | 104 | ); |
| 139 | 105 | |
| @@ -140,11 +106,10 @@ | ||
| 140 | 106 | if ( apply_filters( 'frm_include_addon_page', false ) ) { |
| 141 | 107 | // If no addons need a license, skip this page |
| 142 | 108 | $show_licenses = false; |
| 143 | 109 | $installed_addons = apply_filters( 'frm_installed_addons', array() ); |
| 144 | - | |
| 145 | 110 | foreach ( $installed_addons as $installed_addon ) { |
| 146 | - if ( ! $installed_addon->is_parent_licence && $installed_addon->plugin_name !== 'Formidable Pro' && $installed_addon->needs_license ) { | |
| 111 | + if ( ! $installed_addon->is_parent_licence && $installed_addon->plugin_name != 'Formidable Pro' && $installed_addon->needs_license ) { | |
| 147 | 112 | $show_licenses = true; |
| 148 | 113 | break; |
| 149 | 114 | } |
| 150 | 115 | } |
| @@ -163,14 +128,13 @@ | ||
| 163 | 128 | /** |
| 164 | 129 | * @param array<array> $sections |
| 165 | 130 | */ |
| 166 | 131 | $sections = apply_filters( 'frm_add_settings_section', $sections ); |
| 167 | - self::remove_payments_sections( $sections ); | |
| 168 | 132 | |
| 169 | 133 | $sections['misc'] = array( |
| 170 | 134 | 'name' => __( 'Miscellaneous', 'formidable' ), |
| 171 | - 'icon' => 'frmfont frm_shuffle_icon', | |
| 172 | - 'class' => self::class, | |
| 135 | + 'icon' => 'frm_icon_font frm_shuffle_icon', | |
| 136 | + 'class' => __CLASS__, | |
| 173 | 137 | 'function' => 'misc_settings', |
| 174 | 138 | ); |
| 175 | 139 | |
| 176 | 140 | foreach ( $sections as $key => $section ) { |
| @@ -177,9 +141,9 @@ | ||
| 177 | 141 | $original = $section; |
| 178 | 142 | $defaults = array( |
| 179 | 143 | 'html_class' => '', |
| 180 | 144 | 'name' => ucfirst( $key ), |
| 181 | - 'icon' => 'frmfont frm_settings_icon', | |
| 145 | + 'icon' => 'frm_icon_font frm_settings_icon', | |
| 182 | 146 | 'anchor' => $key . '_settings', |
| 183 | 147 | 'data' => array(), |
| 184 | 148 | ); |
| 185 | 149 | |
| @@ -199,53 +163,8 @@ | ||
| 199 | 163 | |
| 200 | 164 | return $sections; |
| 201 | 165 | } |
| 202 | 166 | |
| 203 | - /** | |
| 204 | - * Remove the payments sections (PayPal, Square, Stripe, Authorize.Net) | |
| 205 | - * and show them all on the payments section in separate tabs. | |
| 206 | - * | |
| 207 | - * @since 6.22.1 | |
| 208 | - * | |
| 209 | - * @param array $sections | |
| 210 | - * | |
| 211 | - * @return void | |
| 212 | - */ | |
| 213 | - private static function remove_payments_sections( &$sections ) { | |
| 214 | - $payment_section_keys = array( 'paypal', 'square', 'stripe', 'authorize_net' ); | |
| 215 | - | |
| 216 | - foreach ( $sections as $key => $section ) { | |
| 217 | - if ( in_array( $key, $payment_section_keys, true ) ) { | |
| 218 | - self::$removed_payments_sections[ $key ] = $section; | |
| 219 | - unset( $sections[ $key ] ); | |
| 220 | - } | |
| 221 | - } | |
| 222 | - | |
| 223 | - uksort( self::$removed_payments_sections, array( self::class, 'payment_sections_sort_callback' ) ); | |
| 224 | - } | |
| 225 | - | |
| 226 | - /** | |
| 227 | - * Sort the payments sections (PayPal, Square, Stripe, Authorize.Net) | |
| 228 | - * | |
| 229 | - * @since 6.22.1 | |
| 230 | - * | |
| 231 | - * @param string $a | |
| 232 | - * @param string $b | |
| 233 | - * | |
| 234 | - * @return int | |
| 235 | - */ | |
| 236 | - private static function payment_sections_sort_callback( $a, $b ) { | |
| 237 | - $order = array( 'stripe', 'square', 'paypal', 'authorize_net' ); | |
| 238 | - $first_key = array_search( $a, $order, true ); | |
| 239 | - $second_key = array_search( $b, $order, true ); | |
| 240 | - | |
| 241 | - if ( false === $first_key || false === $second_key ) { | |
| 242 | - return 0; | |
| 243 | - } | |
| 244 | - | |
| 245 | - return $first_key - $second_key; | |
| 246 | - } | |
| 247 | - | |
| 248 | 167 | public static function load_settings_tab() { |
| 249 | 168 | FrmAppHelper::permission_check( 'frm_change_settings' ); |
| 250 | 169 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 251 | 170 | |
| @@ -250,9 +169,8 @@ | ||
| 250 | 169 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 251 | 170 | |
| 252 | 171 | $section = FrmAppHelper::get_post_param( 'tab', '', 'sanitize_text_field' ); |
| 253 | 172 | $sections = self::get_settings_tabs(); |
| 254 | - | |
| 255 | 173 | if ( ! isset( $sections[ $section ] ) ) { |
| 256 | 174 | wp_die(); |
| 257 | 175 | } |
| 258 | 176 | |
| @@ -260,11 +178,10 @@ | ||
| 260 | 178 | |
| 261 | 179 | if ( isset( $section['class'] ) ) { |
| 262 | 180 | call_user_func( array( $section['class'], $section['function'] ) ); |
| 263 | 181 | } else { |
| 264 | - call_user_func( $section['function'] ?? $section ); | |
| 182 | + call_user_func( ( isset( $section['function'] ) ? $section['function'] : $section ) ); | |
| 265 | 183 | } |
| 266 | - | |
| 267 | 184 | wp_die(); |
| 268 | 185 | } |
| 269 | 186 | |
| 270 | 187 | /** |
| @@ -285,12 +202,12 @@ | ||
| 285 | 202 | /** |
| 286 | 203 | * Render the global currency selector if Pro is up to date. |
| 287 | 204 | * |
| 288 | 205 | * @param FrmSettings $frm_settings |
| 289 | - * | |
| 206 | + * @param string $more_html | |
| 290 | 207 | * @return void |
| 291 | 208 | */ |
| 292 | - public static function maybe_render_currency_selector( $frm_settings ) { | |
| 209 | + public static function maybe_render_currency_selector( $frm_settings, $more_html ) { | |
| 293 | 210 | if ( is_callable( 'FrmProSettingsController::add_currency_settings' ) ) { |
| 294 | 211 | FrmProSettingsController::add_currency_settings(); |
| 295 | 212 | return; |
| 296 | 213 | } |
| @@ -300,20 +217,17 @@ | ||
| 300 | 217 | } |
| 301 | 218 | |
| 302 | 219 | /** |
| 303 | 220 | * @since 4.0 |
| 304 | - * | |
| 305 | - * @return void | |
| 306 | 221 | */ |
| 307 | 222 | public static function message_settings() { |
| 308 | 223 | $frm_settings = FrmAppHelper::get_settings(); |
| 224 | + | |
| 309 | 225 | include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/messages.php'; |
| 310 | 226 | } |
| 311 | 227 | |
| 312 | 228 | /** |
| 313 | 229 | * @since 4.0 |
| 314 | - * | |
| 315 | - * @return void | |
| 316 | 230 | */ |
| 317 | 231 | public static function captcha_settings() { |
| 318 | 232 | $frm_settings = FrmAppHelper::get_settings(); |
| 319 | 233 | $captcha_lang = FrmAppHelper::locales( 'captcha' ); |
| @@ -321,23 +235,9 @@ | ||
| 321 | 235 | include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/captcha/captcha.php'; |
| 322 | 236 | } |
| 323 | 237 | |
| 324 | 238 | /** |
| 325 | - * Shows email settings. | |
| 326 | - * | |
| 327 | - * @since 6.25 | |
| 328 | - * | |
| 329 | - * @return void | |
| 330 | - */ | |
| 331 | - public static function email_settings() { | |
| 332 | - $frm_settings = FrmAppHelper::get_settings(); | |
| 333 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/email/email-styles.php'; | |
| 334 | - } | |
| 335 | - | |
| 336 | - /** | |
| 337 | 239 | * @since 4.0 |
| 338 | - * | |
| 339 | - * @return void | |
| 340 | 240 | */ |
| 341 | 241 | public static function permission_settings() { |
| 342 | 242 | $frm_settings = FrmAppHelper::get_settings(); |
| 343 | 243 | $frm_roles = FrmAppHelper::frm_capabilities(); |
| @@ -345,30 +245,13 @@ | ||
| 345 | 245 | include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/permissions.php'; |
| 346 | 246 | } |
| 347 | 247 | |
| 348 | 248 | /** |
| 349 | - * @return void | |
| 350 | - */ | |
| 351 | - public static function payments_settings() { | |
| 352 | - $payment_sections = self::$removed_payments_sections; | |
| 353 | - $tab = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' ); | |
| 354 | - | |
| 355 | - if ( $tab && in_array( $tab, array( 'stripe_settings', 'square_settings', 'authorize_net_settings', 'paypal_settings' ), true ) ) { | |
| 356 | - $tab = str_replace( '_settings', '', $tab ); | |
| 357 | - } else { | |
| 358 | - $tab = 'stripe'; | |
| 359 | - } | |
| 360 | - | |
| 361 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/payments.php'; | |
| 362 | - } | |
| 363 | - | |
| 364 | - /** | |
| 365 | 249 | * @since 4.0 |
| 366 | - * | |
| 367 | - * @return void | |
| 368 | 250 | */ |
| 369 | 251 | public static function misc_settings() { |
| 370 | 252 | $frm_settings = FrmAppHelper::get_settings(); |
| 253 | + | |
| 371 | 254 | include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/misc.php'; |
| 372 | 255 | } |
| 373 | 256 | |
| 374 | 257 | /** |
| @@ -421,10 +304,8 @@ | ||
| 421 | 304 | /** |
| 422 | 305 | * Include the Update button on the global settings page. |
| 423 | 306 | * |
| 424 | 307 | * @since 4.0.02 |
| 425 | - * | |
| 426 | - * @return void | |
| 427 | 308 | */ |
| 428 | 309 | public static function save_button() { |
| 429 | 310 | echo '<input class="button-primary frm-button-primary" type="submit" |
| 430 | 311 | value="' . esc_attr__( 'Update', 'formidable' ) . '"/>'; |
| @@ -429,13 +310,8 @@ | ||
| 429 | 310 | echo '<input class="button-primary frm-button-primary" type="submit" |
| 430 | 311 | value="' . esc_attr__( 'Update', 'formidable' ) . '"/>'; |
| 431 | 312 | } |
| 432 | 313 | |
| 433 | - /** | |
| 434 | - * @param bool|string $stop_load | |
| 435 | - * | |
| 436 | - * @return void | |
| 437 | - */ | |
| 438 | 314 | public static function route( $stop_load = false ) { |
| 439 | 315 | $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
| 440 | 316 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 441 | 317 | FrmAppHelper::include_svg(); |
| @@ -441,9 +317,9 @@ | ||
| 441 | 317 | FrmAppHelper::include_svg(); |
| 442 | 318 | |
| 443 | 319 | if ( $action === 'process-form' ) { |
| 444 | 320 | self::process_form( $stop_load ); |
| 445 | - } elseif ( $stop_load !== 'stop_load' ) { | |
| 321 | + } elseif ( $stop_load != 'stop_load' ) { | |
| 446 | 322 | self::display_form(); |
| 447 | 323 | } |
| 448 | 324 | } |
| 449 | 325 | |
| @@ -450,12 +326,10 @@ | ||
| 450 | 326 | /** |
| 451 | 327 | * Add CTA to the bottom on the plugin settings pages. |
| 452 | 328 | * |
| 453 | 329 | * @since 3.04.02 |
| 454 | - * | |
| 455 | - * @return void | |
| 456 | 330 | */ |
| 457 | - public static function settings_cta() { | |
| 331 | + public static function settings_cta( $view ) { | |
| 458 | 332 | if ( get_option( 'frm_lite_settings_upgrade', false ) ) { |
| 459 | 333 | return; |
| 460 | 334 | } |
| 461 | 335 | |
| @@ -470,9 +344,9 @@ | ||
| 470 | 344 | public static function settings_cta_dismiss() { |
| 471 | 345 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 472 | 346 | FrmAppHelper::permission_check( 'frm_change_settings' ); |
| 473 | 347 | |
| 474 | - update_option( 'frm_lite_settings_upgrade', time(), false ); | |
| 348 | + update_option( 'frm_lite_settings_upgrade', time(), 'no' ); | |
| 475 | 349 | |
| 476 | 350 | wp_send_json_success(); |
| 477 | 351 | } |
| 478 | 352 | |
| @@ -500,11 +374,11 @@ | ||
| 500 | 374 | 'limit' => 25, |
| 501 | 375 | 'order_by' => 'post_title', |
| 502 | 376 | ); |
| 503 | 377 | |
| 504 | - $pages = FrmDb::get_results( $wpdb->posts, $where, 'ID, post_title', $atts ); | |
| 378 | + $pages = FrmDb::get_results( $wpdb->posts, $where, 'ID, post_title', $atts ); | |
| 379 | + | |
| 505 | 380 | $results = array(); |
| 506 | - | |
| 507 | 381 | foreach ( $pages as $page ) { |
| 508 | 382 | $results[] = array( |
| 509 | 383 | 'value' => $page->ID, |
| 510 | 384 | 'label' => $page->post_title, |
| @@ -511,25 +385,6 @@ | ||
| 511 | 385 | ); |
| 512 | 386 | } |
| 513 | 387 | |
| 514 | 388 | wp_send_json( $results ); |
| 515 | - } | |
| 516 | - | |
| 517 | - /** | |
| 518 | - * Shows a fake color picker. | |
| 519 | - * | |
| 520 | - * @since 6.25 | |
| 521 | - * | |
| 522 | - * @param string $color Color value. | |
| 523 | - * | |
| 524 | - * @return void | |
| 525 | - */ | |
| 526 | - public static function fake_color_picker( $color ) { | |
| 527 | - ?> | |
| 528 | - <div class="wp-picker-container"> | |
| 529 | - <button type="button" class="button wp-color-result" aria-expanded="false" aria-disabled="true" tabindex="-1" style="background-color:<?php echo esc_attr( $color ); ?>;"><?php // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong ?> | |
| 530 | - <span class="wp-color-result-text" style="color:#a7aaad;"><?php esc_html_e( 'Select Color', 'formidable' ); ?></span> | |
| 531 | - </button> | |
| 532 | - </div> | |
| 533 | - <?php | |
| 534 | 389 | } |
| 535 | 390 | } |