| @@ -5,19 +5,19 @@ | ||
| 5 | 5 | |
| 6 | 6 | class FrmStylesController { |
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | - * @var string | |
| 9 | + * @var string $post_type | |
| 10 | 10 | */ |
| 11 | 11 | public static $post_type = 'frm_styles'; |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * @var string | |
| 14 | + * @var string $screen | |
| 15 | 15 | */ |
| 16 | 16 | public static $screen = 'formidable_page_formidable-styles'; |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | - * @var string|null | |
| 19 | + * @var string|null $message | |
| 20 | 20 | */ |
| 21 | 21 | private static $message; |
| 22 | 22 | |
| 23 | 23 | public static function load_pro_hooks() { |
| @@ -95,9 +95,9 @@ | ||
| 95 | 95 | * |
| 96 | 96 | * @return void |
| 97 | 97 | */ |
| 98 | 98 | private static function disable_form_css() { |
| 99 | - add_filter( 'get_frm_stylesheet', '__return_empty_array' ); | |
| 99 | + add_filter( 'get_frm_stylesheet', '__return_false' ); | |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
| 103 | 103 | * Removing this action prevents front end JavaScript from loading. |
| @@ -119,12 +119,12 @@ | ||
| 119 | 119 | if ( ! FrmAppHelper::is_style_editor_page() ) { |
| 120 | 120 | return; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - FrmStyleComponent::register_assets(); | |
| 124 | 123 | self::load_pro_hooks(); |
| 125 | 124 | |
| 126 | 125 | $version = FrmAppHelper::plugin_version(); |
| 126 | + wp_enqueue_script( 'jquery-ui-datepicker' ); | |
| 127 | 127 | |
| 128 | 128 | if ( FrmAppHelper::is_style_editor_page( 'edit' ) ) { |
| 129 | 129 | wp_enqueue_style( 'wp-color-picker' ); |
| 130 | 130 | } |
| @@ -152,9 +152,9 @@ | ||
| 152 | 152 | 'frm_update_settings', |
| 153 | 153 | /** |
| 154 | 154 | * Update the form data on the "Manage Styles" tab after global settings are saved. |
| 155 | 155 | */ |
| 156 | - function () { | |
| 156 | + function() { | |
| 157 | 157 | self::manage_styles(); |
| 158 | 158 | } |
| 159 | 159 | ); |
| 160 | 160 | } |
| @@ -191,9 +191,9 @@ | ||
| 191 | 191 | wp_register_style( $css_key, $file, array(), $this_version ); |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | $load_on_all = ! FrmAppHelper::is_admin() && 'all' === $frm_settings->load_style; |
| 195 | - if ( $load_on_all || $register !== 'register' ) { | |
| 195 | + if ( $load_on_all || $register != 'register' ) { | |
| 196 | 196 | wp_enqueue_style( $css_key ); |
| 197 | 197 | } |
| 198 | 198 | unset( $css_key, $file ); |
| 199 | 199 | } |
| @@ -200,9 +200,9 @@ | ||
| 200 | 200 | |
| 201 | 201 | if ( $frm_settings->load_style === 'all' ) { |
| 202 | 202 | $frm_vars['css_loaded'] = true; |
| 203 | 203 | } |
| 204 | - }//end if | |
| 204 | + } | |
| 205 | 205 | unset( $css ); |
| 206 | 206 | |
| 207 | 207 | add_filter( 'style_loader_tag', 'FrmStylesController::add_tags_to_css', 10, 2 ); |
| 208 | 208 | } |
| @@ -264,17 +264,14 @@ | ||
| 264 | 264 | |
| 265 | 265 | return $this_version; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - /** | |
| 269 | - * @param string $tag | |
| 270 | - * @param string $handle | |
| 271 | - * @return string | |
| 272 | - */ | |
| 273 | 268 | public static function add_tags_to_css( $tag, $handle ) { |
| 274 | - if ( ( 'formidable' === $handle || 'jquery-theme' === $handle ) && strpos( $tag, ' property=' ) === false ) { | |
| 269 | + if ( ( 'formidable' == $handle || 'jquery-theme' == $handle ) && strpos( $tag, ' property=' ) === false ) { | |
| 275 | 270 | $frm_settings = FrmAppHelper::get_settings(); |
| 276 | - $tag = str_replace( ' type="', ' property="stylesheet" type="', $tag ); | |
| 271 | + if ( $frm_settings->use_html ) { | |
| 272 | + $tag = str_replace( ' type="', ' property="stylesheet" type="', $tag ); | |
| 273 | + } | |
| 277 | 274 | } |
| 278 | 275 | |
| 279 | 276 | return $tag; |
| 280 | 277 | } |
| @@ -323,15 +320,9 @@ | ||
| 323 | 320 | self::setup_styles_and_scripts_for_styler(); |
| 324 | 321 | |
| 325 | 322 | $style_id = self::get_style_id_for_styler(); |
| 326 | 323 | if ( ! $style_id ) { |
| 327 | - $error_args = array( | |
| 328 | - 'title' => __( 'No styles', 'formidable' ), | |
| 329 | - 'body' => __( 'You must have a style to use the Visual Styler.', 'formidable' ), | |
| 330 | - 'cancel_url' => admin_url( 'admin.php?page=formidable' ), | |
| 331 | - ); | |
| 332 | - FrmAppController::show_error_modal( $error_args ); | |
| 333 | - return; | |
| 324 | + wp_die( esc_html__( 'Invalid route', 'formidable' ), esc_html__( 'Invalid route', 'formidable' ), 400 ); | |
| 334 | 325 | } |
| 335 | 326 | |
| 336 | 327 | $form_id = FrmAppHelper::simple_get( 'form', 'absint', 0 ); |
| 337 | 328 | if ( ! $form_id ) { |
| @@ -338,17 +329,10 @@ | ||
| 338 | 329 | $form_id = self::get_form_id_for_style( $style_id ); |
| 339 | 330 | } |
| 340 | 331 | |
| 341 | 332 | $form = FrmForm::getOne( $form_id ); |
| 342 | - | |
| 343 | 333 | if ( ! is_object( $form ) ) { |
| 344 | - $error_args = array( | |
| 345 | - 'title' => __( 'No forms', 'formidable' ), | |
| 346 | - 'body' => __( 'You must have a form to use the Visual Styler.', 'formidable' ), | |
| 347 | - 'cancel_url' => admin_url( 'admin.php?page=formidable' ), | |
| 348 | - ); | |
| 349 | - FrmAppController::show_error_modal( $error_args ); | |
| 350 | - return; | |
| 334 | + wp_die( esc_html__( 'Invalid route', 'formidable' ), esc_html__( 'Invalid route', 'formidable' ), 400 ); | |
| 351 | 335 | } |
| 352 | 336 | |
| 353 | 337 | $frm_style = new FrmStyle( $style_id ); |
| 354 | 338 | $active_style = $frm_style->get_one(); |
| @@ -358,9 +342,11 @@ | ||
| 358 | 342 | |
| 359 | 343 | /** |
| 360 | 344 | * @since 6.0 |
| 361 | 345 | * |
| 362 | - * @param array{form:\stdClass} $data | |
| 346 | + * @param array { | |
| 347 | + * @type stdClass $form | |
| 348 | + * } | |
| 363 | 349 | */ |
| 364 | 350 | do_action( 'frm_before_render_style_page', compact( 'form' ) ); |
| 365 | 351 | |
| 366 | 352 | self::render_style_page( $active_style, $form, $default_style ); |
| @@ -413,12 +399,11 @@ | ||
| 413 | 399 | |
| 414 | 400 | if ( ! $form_id ) { |
| 415 | 401 | // TODO: Show a message why a random form is being shown (because no form is assigned to the style). |
| 416 | 402 | // Fallback to any form. |
| 417 | - $where = array( | |
| 403 | + $where = array( | |
| 418 | 404 | 'status' => 'published', |
| 419 | - // Make sure it's not a repeater. | |
| 420 | - 'parent_form_id' => array( null, 0 ), | |
| 405 | + 'parent_form_id' => array( null, 0 ), // Make sure it's not a repeater. | |
| 421 | 406 | ); |
| 422 | 407 | $form_id = FrmDb::get_var( 'frm_forms', $where, 'id' ); |
| 423 | 408 | } |
| 424 | 409 | |
| @@ -432,9 +417,9 @@ | ||
| 432 | 417 | */ |
| 433 | 418 | private static function disable_admin_page_styling_on_submit_buttons() { |
| 434 | 419 | add_filter( |
| 435 | 420 | 'frm_submit_button_class', |
| 436 | - function ( $classes ) { | |
| 421 | + function( $classes ) { | |
| 437 | 422 | $classes[] = 'frm_no_style_button'; |
| 438 | 423 | return $classes; |
| 439 | 424 | } |
| 440 | 425 | ); |
| @@ -478,15 +463,15 @@ | ||
| 478 | 463 | * @param int $style_id |
| 479 | 464 | */ |
| 480 | 465 | $style_id = apply_filters( 'frm_saved_form_style_id', $style_id ); |
| 481 | 466 | |
| 482 | - if ( ! $style_id && '0' !== FrmAppHelper::get_post_param( 'style_id', '', 'sanitize_text_field' ) ) { | |
| 467 | + if ( ! $style_id && '0' !== FrmAppHelper::get_post_param( 'style_id', 'sanitize_text_field', '' ) ) { | |
| 483 | 468 | // "0" is a special value used for the enable/disable toggle. |
| 484 | 469 | wp_die( esc_html__( 'Invalid style value', 'formidable' ), esc_html__( 'Invalid style value', 'formidable' ), 400 ); |
| 485 | 470 | return; |
| 486 | 471 | } |
| 487 | 472 | |
| 488 | - $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); | |
| 473 | + $form_id = FrmAppHelper::get_post_param( 'form_id', 'absint', 0 ); | |
| 489 | 474 | if ( ! $form_id ) { |
| 490 | 475 | wp_die( esc_html__( 'No form specified', 'formidable' ), esc_html__( 'No form specified', 'formidable' ), 400 ); |
| 491 | 476 | return; |
| 492 | 477 | } |
| @@ -504,10 +489,9 @@ | ||
| 504 | 489 | if ( $style_id === $default_style->ID && empty( $form->options['chat'] ) ) { |
| 505 | 490 | $style_id = 1; |
| 506 | 491 | } |
| 507 | 492 | |
| 508 | - // We want to save a string for consistency. FrmStylesHelper::get_form_count_for_style expects the custom style ID is a string. | |
| 509 | - $form->options['custom_style'] = (string) $style_id; | |
| 493 | + $form->options['custom_style'] = (string) $style_id; // We want to save a string for consistency. FrmStylesHelper::get_form_count_for_style expects the custom style ID is a string. | |
| 510 | 494 | |
| 511 | 495 | global $wpdb; |
| 512 | 496 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 513 | 497 | |
| @@ -539,9 +523,9 @@ | ||
| 539 | 523 | $plugin_url = FrmAppHelper::plugin_url(); |
| 540 | 524 | $version = FrmAppHelper::plugin_version(); |
| 541 | 525 | $js_dependencies = array( 'wp-i18n', 'wp-hooks', 'formidable_dom' ); |
| 542 | 526 | |
| 543 | - if ( FrmAppHelper::pro_is_installed() && is_callable( 'FrmProAppHelper::use_jquery_datepicker' ) && FrmProAppHelper::use_jquery_datepicker() ) { | |
| 527 | + if ( FrmAppHelper::pro_is_installed() ) { | |
| 544 | 528 | $js_dependencies[] = 'jquery-ui-datepicker'; |
| 545 | 529 | } |
| 546 | 530 | |
| 547 | 531 | wp_register_script( 'formidable_style', $plugin_url . '/js/admin/style.js', $js_dependencies, $version ); |
| @@ -549,9 +533,8 @@ | ||
| 549 | 533 | wp_print_styles( 'formidable_style' ); |
| 550 | 534 | |
| 551 | 535 | wp_print_styles( 'formidable' ); |
| 552 | 536 | wp_enqueue_script( 'formidable_style' ); |
| 553 | - wp_set_script_translations( 'formidable_style', 'formidable' ); | |
| 554 | 537 | } |
| 555 | 538 | |
| 556 | 539 | /** |
| 557 | 540 | * Render the style page (with a more limited and typed scope than calling it from self::style directly). |
| @@ -558,8 +541,9 @@ | ||
| 558 | 541 | * |
| 559 | 542 | * @since 6.0 |
| 560 | 543 | * |
| 561 | 544 | * @param stdClass|WP_Post $active_style |
| 545 | + * @param array<WP_Post> $styles | |
| 562 | 546 | * @param stdClass $form |
| 563 | 547 | * @param WP_Post $default_style |
| 564 | 548 | * @return void |
| 565 | 549 | */ |
| @@ -564,15 +548,13 @@ | ||
| 564 | 548 | * @return void |
| 565 | 549 | */ |
| 566 | 550 | private static function render_style_page( $active_style, $form, $default_style ) { |
| 567 | 551 | $style_views_path = self::get_views_path(); |
| 568 | - // Edit, list (default), new_style. | |
| 569 | - $view = FrmAppHelper::simple_get( 'frm_action', 'sanitize_text_field', 'list' ); | |
| 570 | - $frm_style = new FrmStyle( $active_style->ID ); | |
| 552 | + $view = FrmAppHelper::simple_get( 'frm_action', 'sanitize_text_field', 'list' ); // edit, list (default), new_style. | |
| 553 | + $frm_style = new FrmStyle( $active_style->ID ); | |
| 571 | 554 | |
| 572 | 555 | if ( 'new_style' !== $view && ! FrmAppHelper::simple_get( 'form' ) && ! FrmAppHelper::simple_get( 'style_id' ) ) { |
| 573 | - // Have the Appearance > Forms link fallback to the edit view. Otherwise we want to use 'list' as the default. | |
| 574 | - $view = 'edit'; | |
| 556 | + $view = 'edit'; // Have the Appearance > Forms link fallback to the edit view. Otherwise we want to use 'list' as the default. | |
| 575 | 557 | } |
| 576 | 558 | |
| 577 | 559 | if ( in_array( $view, array( 'edit', 'new_style', 'duplicate' ), true ) ) { |
| 578 | 560 | self::add_meta_boxes(); |
| @@ -635,21 +617,21 @@ | ||
| 635 | 617 | * Filter form classes so the form uses the preview style, not the form's active style. |
| 636 | 618 | * |
| 637 | 619 | * @since 6.0 |
| 638 | 620 | * |
| 639 | - * @param stdClass|WP_Post $style A new style is not a WP_Post object. | |
| 621 | + * @param WP_Post|stdClass $style A new style is not a WP_Post object. | |
| 640 | 622 | * @return void |
| 641 | 623 | */ |
| 642 | 624 | private static function force_form_style( $style ) { |
| 643 | 625 | add_filter( |
| 644 | 626 | 'frm_add_form_style_class', |
| 645 | - function ( $class ) use ( $style ) { | |
| 646 | - $split = array_filter( | |
| 627 | + function( $class ) use ( $style ) { | |
| 628 | + $split = array_filter( | |
| 647 | 629 | explode( ' ', $class ), |
| 648 | 630 | /** |
| 649 | 631 | * @param string $class |
| 650 | 632 | */ |
| 651 | - function ( $class ) { | |
| 633 | + function( $class ) { | |
| 652 | 634 | return $class && 0 !== strpos( $class, 'frm_style_' ); |
| 653 | 635 | } |
| 654 | 636 | ); |
| 655 | 637 | $split[] = 'frm_style_' . $style->post_name; |
| @@ -666,8 +648,9 @@ | ||
| 666 | 648 | * @return void |
| 667 | 649 | */ |
| 668 | 650 | public static function save_style() { |
| 669 | 651 | $frm_style = new FrmStyle(); |
| 652 | + $message = ''; | |
| 670 | 653 | $post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_title' ); |
| 671 | 654 | $style_nonce = FrmAppHelper::get_post_param( 'frm_style', '', 'sanitize_text_field' ); |
| 672 | 655 | |
| 673 | 656 | if ( $post_id === false || ! wp_verify_nonce( $style_nonce, 'frm_style_nonce' ) ) { |
| @@ -678,10 +661,9 @@ | ||
| 678 | 661 | |
| 679 | 662 | $id = $frm_style->update( $post_id ); |
| 680 | 663 | if ( ! $post_id && $id ) { |
| 681 | 664 | self::maybe_redirect_after_save( $id ); |
| 682 | - // Set the post id to the new style so it will be loaded for editing. | |
| 683 | - $post_id = reset( $id ); | |
| 665 | + $post_id = reset( $id ); // Set the post id to the new style so it will be loaded for editing. | |
| 684 | 666 | } |
| 685 | 667 | |
| 686 | 668 | self::$message = __( 'Your styling settings have been saved.', 'formidable' ); |
| 687 | 669 | } |
| @@ -724,9 +706,9 @@ | ||
| 724 | 706 | return; |
| 725 | 707 | } |
| 726 | 708 | |
| 727 | 709 | parse_str( $query, $parsed_query ); |
| 728 | - $form_id = ! empty( $parsed_query['form'] ) ? absint( $parsed_query['form'] ) : 0; | |
| 710 | + $form_id = ! empty( $parsed_query['form'] ) ? absint( $parsed_query['form'] ) : 0; | |
| 729 | 711 | |
| 730 | 712 | $style = new stdClass(); |
| 731 | 713 | $style->ID = end( $ids ); |
| 732 | 714 | wp_safe_redirect( esc_url_raw( FrmStylesHelper::get_edit_url( $style, $form_id ) ) ); |
| @@ -743,9 +725,8 @@ | ||
| 743 | 725 | public static function manage( $message = '', $forms = array() ) { |
| 744 | 726 | $frm_style = new FrmStyle(); |
| 745 | 727 | $styles = $frm_style->get_all(); |
| 746 | 728 | $default_style = $frm_style->get_default_style( $styles ); |
| 747 | - $frm_settings = FrmAppHelper::get_settings(); | |
| 748 | 729 | |
| 749 | 730 | if ( ! $forms ) { |
| 750 | 731 | $forms = FrmForm::get_published_forms(); |
| 751 | 732 | } |
| @@ -763,14 +744,14 @@ | ||
| 763 | 744 | global $wpdb; |
| 764 | 745 | |
| 765 | 746 | $forms = FrmForm::get_published_forms(); |
| 766 | 747 | foreach ( $forms as $form ) { |
| 767 | - if ( ! isset( $_POST['style'] ) || ! isset( $_POST['style'][ $form->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 748 | + $new_style = ( isset( $_POST['style'] ) && isset( $_POST['style'][ $form->id ] ) ) ? sanitize_text_field( wp_unslash( $_POST['style'][ $form->id ] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 749 | + $previous_style = ( isset( $_POST['prev_style'] ) && isset( $_POST['prev_style'][ $form->id ] ) ) ? sanitize_text_field( wp_unslash( $_POST['prev_style'][ $form->id ] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 750 | + if ( $new_style == $previous_style ) { | |
| 768 | 751 | continue; |
| 769 | 752 | } |
| 770 | 753 | |
| 771 | - $new_style = sanitize_text_field( wp_unslash( $_POST['style'][ $form->id ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 772 | - | |
| 773 | 754 | $form->options['custom_style'] = $new_style; |
| 774 | 755 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 775 | 756 | unset( $form ); |
| 776 | 757 | } |
| @@ -904,26 +885,22 @@ | ||
| 904 | 885 | echo json_encode( $defaults ); |
| 905 | 886 | wp_die(); |
| 906 | 887 | } |
| 907 | 888 | |
| 908 | - $frm_style = new FrmStyle(); | |
| 909 | - $default_template_style = $frm_style->get_default_template_style( $style_id ); | |
| 910 | - $where = array( | |
| 889 | + $frm_style = new FrmStyle(); | |
| 890 | + $defaults = $frm_style->get_defaults(); | |
| 891 | + $default_post_content = FrmAppHelper::prepare_and_encode( $defaults ); | |
| 892 | + $where = array( | |
| 911 | 893 | 'ID' => $style_id, |
| 912 | 894 | 'post_type' => self::$post_type, |
| 913 | 895 | ); |
| 914 | - | |
| 915 | - $style_object = $frm_style->get_new(); | |
| 916 | - $style_object->post_content = json_decode( $default_template_style, true ); | |
| 917 | - | |
| 918 | 896 | global $wpdb; |
| 919 | - $wpdb->update( $wpdb->posts, array( 'post_content' => $default_template_style ), $where ); | |
| 897 | + $wpdb->update( $wpdb->posts, array( 'post_content' => $default_post_content ), $where ); | |
| 920 | 898 | |
| 921 | - // Save the settings after resetting to default or the old style will still appear. | |
| 922 | - $frm_style->save_settings(); | |
| 899 | + $frm_style->save_settings(); // Save the settings after resetting to default or the old style will still appear. | |
| 923 | 900 | |
| 924 | 901 | $data = array( |
| 925 | - 'style' => FrmStylesCardHelper::get_style_param_for_card( $style_object ), | |
| 902 | + 'style' => FrmStylesCardHelper::get_style_param_for_card( $frm_style->get_new() ), | |
| 926 | 903 | ); |
| 927 | 904 | wp_send_json_success( $data ); |
| 928 | 905 | wp_die(); |
| 929 | 906 | } |
| @@ -938,15 +915,12 @@ | ||
| 938 | 915 | public static function change_styling() { |
| 939 | 916 | FrmAppHelper::permission_check( 'frm_change_settings' ); |
| 940 | 917 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 941 | 918 | |
| 942 | - $is_loaded_via_ajax = true; | |
| 943 | - $frm_style = new FrmStyle(); | |
| 919 | + $frm_style = new FrmStyle(); | |
| 920 | + $defaults = false; // Intentionally avoid defaults here so nothing gets removed from our style. | |
| 921 | + $style = ''; | |
| 944 | 922 | |
| 945 | - // Intentionally avoid defaults here so nothing gets removed from our style. | |
| 946 | - $defaults = array(); | |
| 947 | - $style = ''; | |
| 948 | - | |
| 949 | 923 | echo '<style type="text/css">'; |
| 950 | 924 | include FrmAppHelper::plugin_path() . '/css/_single_theme.css.php'; |
| 951 | 925 | echo '</style>'; |
| 952 | 926 | wp_die(); |
| @@ -1043,30 +1017,12 @@ | ||
| 1043 | 1017 | */ |
| 1044 | 1018 | $output = apply_filters( 'frm_saved_css', $output ); |
| 1045 | 1019 | |
| 1046 | 1020 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1047 | - | |
| 1048 | - self::maybe_hide_sample_form_error_message(); | |
| 1049 | - | |
| 1050 | 1021 | wp_die(); |
| 1051 | 1022 | } |
| 1052 | 1023 | |
| 1053 | 1024 | /** |
| 1054 | - * Add an extra style rule to hide a broken style warning. | |
| 1055 | - * To avoid cluttering the front end with any unnecessary styles this is only added when the referer URL matches the styler. | |
| 1056 | - * | |
| 1057 | - * @since 6.2.3 | |
| 1058 | - * | |
| 1059 | - * @return void | |
| 1060 | - */ | |
| 1061 | - public static function maybe_hide_sample_form_error_message() { | |
| 1062 | - $referer = FrmAppHelper::get_server_value( 'HTTP_REFERER' ); | |
| 1063 | - if ( false !== strpos( $referer, 'admin.php?page=formidable-styles' ) ) { | |
| 1064 | - echo '#frm_broken_styles_warning { display: none; }'; | |
| 1065 | - } | |
| 1066 | - } | |
| 1067 | - | |
| 1068 | - /** | |
| 1069 | 1025 | * Replaces relative URL with absolute URL. |
| 1070 | 1026 | * |
| 1071 | 1027 | * @since 4.11.03 |
| 1072 | 1028 | * |
| @@ -1104,9 +1060,9 @@ | ||
| 1104 | 1060 | return; |
| 1105 | 1061 | } |
| 1106 | 1062 | |
| 1107 | 1063 | $frm_settings = FrmAppHelper::get_settings(); |
| 1108 | - if ( $frm_settings->load_style !== 'none' ) { | |
| 1064 | + if ( $frm_settings->load_style != 'none' ) { | |
| 1109 | 1065 | wp_enqueue_style( 'formidable' ); |
| 1110 | 1066 | $frm_vars['css_loaded'] = true; |
| 1111 | 1067 | } |
| 1112 | 1068 | } |
| @@ -1125,9 +1081,9 @@ | ||
| 1125 | 1081 | |
| 1126 | 1082 | /** |
| 1127 | 1083 | * Get the style post object for a target form. |
| 1128 | 1084 | * |
| 1129 | - * @param bool|object|string $form | |
| 1085 | + * @param object|string|boolean $form | |
| 1130 | 1086 | * @return WP_Post|null |
| 1131 | 1087 | */ |
| 1132 | 1088 | public static function get_form_style( $form = 'default' ) { |
| 1133 | 1089 | $style = FrmFormsHelper::get_form_style( $form ); |
| @@ -1160,11 +1116,12 @@ | ||
| 1160 | 1116 | return $class; |
| 1161 | 1117 | } |
| 1162 | 1118 | |
| 1163 | 1119 | /** |
| 1164 | - * @since 3.0 | |
| 1165 | 1120 | * @param object $style |
| 1166 | 1121 | * @param string $class |
| 1122 | + * | |
| 1123 | + * @since 3.0 | |
| 1167 | 1124 | */ |
| 1168 | 1125 | private static function maybe_add_rtl_class( $style, &$class ) { |
| 1169 | 1126 | $is_rtl = isset( $style->post_content['direction'] ) && 'rtl' === $style->post_content['direction']; |
| 1170 | 1127 | if ( $is_rtl ) { |
| @@ -1209,86 +1166,10 @@ | ||
| 1209 | 1166 | |
| 1210 | 1167 | return $important; |
| 1211 | 1168 | } |
| 1212 | 1169 | |
| 1213 | - /** | |
| 1214 | - * Duplicate of WordPress do_accordion_section function, it adds an additional svg icon support. | |
| 1215 | - * | |
| 1216 | - * @since 6.8.3 | |
| 1217 | - * | |
| 1218 | - * @return int | |
| 1219 | - */ | |
| 1220 | - public static function do_accordion_sections( $screen, $context, $data_object ) { | |
| 1221 | - global $wp_meta_boxes; | |
| 1222 | - | |
| 1223 | - // the symbol id from icons.svg | |
| 1224 | - $icon_ids = array( | |
| 1225 | - 'ranking-fields-style' => 'frm_chart_bar_icon', | |
| 1226 | - 'section-fields-style' => 'frm-form-title-style', | |
| 1227 | - ); | |
| 1228 | - | |
| 1229 | - wp_enqueue_script( 'accordion' ); | |
| 1230 | - | |
| 1231 | - if ( empty( $screen ) ) { | |
| 1232 | - $screen = get_current_screen(); | |
| 1233 | - } elseif ( is_string( $screen ) ) { | |
| 1234 | - $screen = convert_to_screen( $screen ); | |
| 1235 | - } | |
| 1236 | - | |
| 1237 | - $page = $screen->id; | |
| 1238 | - | |
| 1239 | - ?> | |
| 1240 | - <div id="side-sortables" class="accordion-container"> | |
| 1241 | - <ul class="outer-border"> | |
| 1242 | - <?php | |
| 1243 | - $i = 0; | |
| 1244 | - $first_open = false; | |
| 1245 | - | |
| 1246 | - if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) { | |
| 1247 | - foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { | |
| 1248 | - if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { | |
| 1249 | - foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { | |
| 1250 | - if ( false === $box || ! $box['title'] ) { | |
| 1251 | - continue; | |
| 1252 | - } | |
| 1253 | - | |
| 1254 | - ++$i; | |
| 1255 | - $icon_id = array_key_exists( $box['id'], $icon_ids ) ? $icon_ids[ $box['id'] ] : 'frm-' . $box['id']; | |
| 1256 | - | |
| 1257 | - $open_class = ''; | |
| 1258 | - if ( ! $first_open ) { | |
| 1259 | - $first_open = true; | |
| 1260 | - $open_class = 'open'; | |
| 1261 | - } | |
| 1262 | - | |
| 1263 | - $accordion_content_id = 'frm_style_section_' . $box['id']; | |
| 1264 | - ?> | |
| 1265 | - <li class="control-section accordion-section <?php echo esc_attr( $open_class ); ?> <?php echo esc_attr( $box['id'] ); ?>" id="<?php echo esc_attr( $box['id'] ); ?>"> | |
| 1266 | - <h3 class="accordion-section-title hndle"> | |
| 1267 | - <?php | |
| 1268 | - FrmAppHelper::icon_by_class( 'frmfont ' . $icon_id . ' frm_svg24' ); | |
| 1269 | - echo esc_html( $box['title'] ); | |
| 1270 | - ?> | |
| 1271 | - <button type="button" aria-expanded="<?php echo esc_attr( 'open' === $open_class ? 'true' : 'false' ); ?>" aria-controls="<?php echo esc_attr( $accordion_content_id ); ?>" aria-label="<?php echo esc_attr( $box['title'] ); ?>"> | |
| 1272 | - <?php FrmAppHelper::icon_by_class( 'frmfont frm_arrowdown8_icon' ); ?> | |
| 1273 | - </button> | |
| 1274 | - </h3> | |
| 1275 | - <div class="accordion-section-content <?php postbox_classes( $box['id'], $page ); ?>" id="<?php echo esc_attr( $accordion_content_id ); ?>"> | |
| 1276 | - <div class="inside"> | |
| 1277 | - <?php call_user_func( $box['callback'], $data_object, $box ); ?> | |
| 1278 | - </div><!-- .inside --> | |
| 1279 | - </div><!-- .accordion-section-content --> | |
| 1280 | - </li><!-- .accordion-section --> | |
| 1281 | - <?php | |
| 1282 | - }//end foreach | |
| 1283 | - }//end if | |
| 1284 | - }//end foreach | |
| 1285 | - }//end if | |
| 1286 | - ?> | |
| 1287 | - </ul><!-- .outer-border --> | |
| 1288 | - </div><!-- .accordion-container --> | |
| 1289 | - <?php | |
| 1290 | - return $i; | |
| 1170 | + public static function do_accordion_sections( $screen, $context, $object ) { | |
| 1171 | + return do_accordion_sections( $screen, $context, $object ); | |
| 1291 | 1172 | } |
| 1292 | 1173 | |
| 1293 | 1174 | /** |
| 1294 | 1175 | * Rename a style via an AJAX action. |