PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.23
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.23
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/controllers/FrmStylesController.php +56 -181 6.276.23 View file →
@@ -19,11 +19,8 @@
19 19 * @var string|null
20 20 */
21 21 private static $message;
22 22
23 - /**
24 - * @return void
25 - */
26 23 public static function load_pro_hooks() {
27 24 if ( FrmAppHelper::pro_is_installed() ) {
28 25 FrmProStylesController::load_pro_hooks();
29 26 }
@@ -28,11 +25,8 @@
28 25 FrmProStylesController::load_pro_hooks();
29 26 }
30 27 }
31 28
32 - /**
33 - * @return void
34 - */
35 29 public static function register_post_types() {
36 30 register_post_type(
37 31 self::$post_type,
38 32 array(
@@ -73,10 +67,10 @@
73 67 *
74 68 * @return void
75 69 */
76 70 public static function menu() {
77 - add_submenu_page( 'formidable', 'Formidable | ' . __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
78 - add_submenu_page( 'themes.php', 'Formidable | ' . __( 'Styles', 'formidable' ), __( 'Forms', 'formidable' ), 'frm_change_settings', 'formidable-styles2', 'FrmStylesController::route' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
71 + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route' );
72 + add_submenu_page( 'themes.php', 'Formidable | ' . __( 'Styles', 'formidable' ), __( 'Forms', 'formidable' ), 'frm_change_settings', 'formidable-styles2', 'FrmStylesController::route' );
79 73 }
80 74
81 75 /**
82 76 * Remove filters for the visual styler preview.
@@ -137,11 +131,10 @@
137 131
138 132 wp_enqueue_style( 'frm-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_css' ), array(), $version );
139 133
140 134 $style = apply_filters( 'frm_style_head', false );
141 -
142 135 if ( $style ) {
143 - wp_enqueue_style( 'frm-single-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_load_css&flat=1' ) . '&' . http_build_query( $style->post_content ), array(), $version ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
136 + wp_enqueue_style( 'frm-single-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_load_css&flat=1' ) . '&' . http_build_query( $style->post_content ), array(), $version );
144 137 }
145 138 }
146 139
147 140 /**
@@ -168,9 +161,8 @@
168 161
169 162 /**
170 163 * @param string $register Either 'enqueue' or 'register'.
171 164 * @param bool $force True to enqueue/register the style if a form has not been loaded.
172 - *
173 165 * @return void
174 166 */
175 167 public static function enqueue_css( $register = 'enqueue', $force = false ) {
176 168 global $frm_vars;
@@ -182,9 +174,8 @@
182 174 return;
183 175 }
184 176
185 177 $frm_settings = FrmAppHelper::get_settings();
186 -
187 178 if ( $frm_settings->load_style === 'none' ) {
188 179 return;
189 180 }
190 181
@@ -200,9 +191,8 @@
200 191 wp_register_style( $css_key, $file, array(), $this_version );
201 192 }
202 193
203 194 $load_on_all = ! FrmAppHelper::is_admin() && 'all' === $frm_settings->load_style;
204 -
205 195 if ( $load_on_all || $register !== 'register' ) {
206 196 wp_enqueue_style( $css_key );
207 197 }
208 198 unset( $css_key, $file );
@@ -233,20 +223,17 @@
233 223 }
234 224
235 225 /**
236 226 * @param array $stylesheet_urls
237 - *
238 227 * @return void
239 228 */
240 229 private static function get_url_to_custom_style( &$stylesheet_urls ) {
241 230 $file_name = '/css/' . self::get_file_name();
242 -
243 231 if ( is_readable( FrmAppHelper::plugin_path() . $file_name ) ) {
244 232 $url = FrmAppHelper::plugin_url() . $file_name;
245 233 } else {
246 234 $url = admin_url( 'admin-ajax.php?action=frmpro_css' );
247 235 }
248 -
249 236 $stylesheet_urls['formidable'] = $url;
250 237 }
251 238
252 239 /**
@@ -252,30 +239,23 @@
252 239 /**
253 240 * Use a different stylesheet per site in a multisite install
254 241 *
255 242 * @since 3.0.03
256 - *
257 - * @return string
258 243 */
259 244 public static function get_file_name() {
260 245 if ( is_multisite() ) {
261 246 $blog_id = get_current_blog_id();
262 - return 'formidableforms' . absint( $blog_id ) . '.css';
247 + $name = 'formidableforms' . absint( $blog_id ) . '.css';
248 + } else {
249 + $name = 'formidableforms.css';
263 250 }
264 251
265 - return 'formidableforms.css';
252 + return $name;
266 253 }
267 254
268 - /**
269 - * @param string $css_key
270 - * @param string $version
271 - *
272 - * @return string
273 - */
274 255 private static function get_css_version( $css_key, $version ) {
275 - if ( 'formidable' === $css_key ) {
256 + if ( 'formidable' == $css_key ) {
276 257 $this_version = get_option( 'frm_last_style_update' );
277 -
278 258 if ( ! $this_version ) {
279 259 $this_version = $version;
280 260 }
281 261 } else {
@@ -287,14 +267,14 @@
287 267
288 268 /**
289 269 * @param string $tag
290 270 * @param string $handle
291 - *
292 271 * @return string
293 272 */
294 273 public static function add_tags_to_css( $tag, $handle ) {
295 - if ( ( 'formidable' === $handle || 'jquery-theme' === $handle ) && ! str_contains( $tag, ' property=' ) ) {
296 - $tag = str_replace( ' type="', ' property="stylesheet" type="', $tag );
274 + if ( ( 'formidable' === $handle || 'jquery-theme' === $handle ) && strpos( $tag, ' property=' ) === false ) {
275 + $frm_settings = FrmAppHelper::get_settings();
276 + $tag = str_replace( ' type="', ' property="stylesheet" type="', $tag );
297 277 }
298 278
299 279 return $tag;
300 280 }
@@ -342,11 +322,10 @@
342 322
343 323 self::setup_styles_and_scripts_for_styler();
344 324
345 325 $style_id = self::get_style_id_for_styler();
346 -
347 326 if ( ! $style_id ) {
348 - $error_args = array(
327 + $error_args = array(
349 328 'title' => __( 'No styles', 'formidable' ),
350 329 'body' => __( 'You must have a style to use the Visual Styler.', 'formidable' ),
351 330 'cancel_url' => admin_url( 'admin.php?page=formidable' ),
352 331 );
@@ -354,9 +333,8 @@
354 333 return;
355 334 }
356 335
357 336 $form_id = FrmAppHelper::simple_get( 'form', 'absint', 0 );
358 -
359 337 if ( ! $form_id ) {
360 338 $form_id = self::get_form_id_for_style( $style_id );
361 339 }
362 340
@@ -362,9 +340,9 @@
362 340
363 341 $form = FrmForm::getOne( $form_id );
364 342
365 343 if ( ! is_object( $form ) ) {
366 - $error_args = array(
344 + $error_args = array(
367 345 'title' => __( 'No forms', 'formidable' ),
368 346 'body' => __( 'You must have a form to use the Visual Styler.', 'formidable' ),
369 347 'cancel_url' => admin_url( 'admin.php?page=formidable' ),
370 348 );
@@ -394,9 +372,8 @@
394 372 * @return int
395 373 */
396 374 private static function get_style_id_for_styler() {
397 375 $action = FrmAppHelper::simple_get( 'frm_action' );
398 -
399 376 if ( 'duplicate' === $action ) {
400 377 // The duplicate action uses style_id instead of id for better backward compatibility.
401 378 return FrmAppHelper::simple_get( 'style_id', 'absint', 0 );
402 379 }
@@ -401,9 +378,8 @@
401 378 return FrmAppHelper::simple_get( 'style_id', 'absint', 0 );
402 379 }
403 380
404 381 $style_id = FrmAppHelper::simple_get( 'id', 'absint', 0 );
405 -
406 382 if ( $style_id ) {
407 383 // Always use the style ID from the URL if one is specified.
408 384 return $style_id;
409 385 }
@@ -408,9 +384,8 @@
408 384 return $style_id;
409 385 }
410 386
411 387 $request_form_id = FrmAppHelper::simple_get( 'form', 'absint', 0 );
412 -
413 388 if ( $request_form_id && is_callable( 'FrmProStylesController::get_active_style_for_form' ) ) {
414 389 return FrmProStylesController::get_active_style_for_form( $request_form_id )->ID;
415 390 }
416 391
@@ -422,9 +397,8 @@
422 397 *
423 398 * @since 6.0
424 399 *
425 400 * @param int $style_id
426 - *
427 401 * @return int
428 402 */
429 403 private static function get_form_id_for_style( $style_id ) {
430 404 $check = serialize( array( 'custom_style' => (string) $style_id ) );
@@ -437,8 +411,9 @@
437 411 )
438 412 );
439 413
440 414 if ( ! $form_id ) {
415 + // TODO: Show a message why a random form is being shown (because no form is assigned to the style).
441 416 // Fallback to any form.
442 417 $where = array(
443 418 'status' => 'published',
444 419 // Make sure it's not a repeater.
@@ -470,10 +445,11 @@
470 445 *
471 446 * @return WP_Post
472 447 */
473 448 private static function get_default_style() {
474 - $frm_style = new FrmStyle( 'default' );
475 - return $frm_style->get_one();
449 + $frm_style = new FrmStyle( 'default' );
450 + $default_style = $frm_style->get_one();
451 + return $default_style;
476 452 }
477 453
478 454 /**
479 455 * Save style for form (from Styler list page) via a POST action.
@@ -483,15 +459,13 @@
483 459 * @return void
484 460 */
485 461 private static function save_form_style() {
486 462 $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form_style', 'frm_save_form_style_nonce' );
487 -
488 463 if ( $permission_error !== false ) {
489 464 wp_die( 'Unable to save form', '', 403 );
490 465 }
491 466
492 467 $style_id = FrmAppHelper::get_post_param( 'style_id', 0, 'absint' );
493 -
494 468 if ( $style_id && ! self::confirm_style_exists_before_setting( $style_id ) ) {
495 469 wp_die( esc_html__( 'Invalid target style', 'formidable' ), esc_html__( 'Invalid target style', 'formidable' ), 400 );
496 470 return;
497 471 }
@@ -511,9 +485,8 @@
511 485 return;
512 486 }
513 487
514 488 $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
515 -
516 489 if ( ! $form_id ) {
517 490 wp_die( esc_html__( 'No form specified', 'formidable' ), esc_html__( 'No form specified', 'formidable' ), 400 );
518 491 return;
519 492 }
@@ -518,21 +491,17 @@
518 491 return;
519 492 }
520 493
521 494 $form = FrmForm::getOne( $form_id );
522 -
523 495 if ( ! $form ) {
524 496 wp_die( esc_html__( 'Form does not exist', 'formidable' ), esc_html__( 'Form does not exist', 'formidable' ), 400 );
525 497 return;
526 498 }
527 499
528 - $previous_style_id = $form->options['custom_style'];
529 -
530 500 // If the default style is selected, use the "Always use default" legacy option instead of the default style.
531 501 // There's also a check here for conversational forms.
532 502 // Without the check it isn't possible to select "Default" because "Always use default" will convert to "Lines" dynamically.
533 503 $default_style = self::get_default_style();
534 -
535 504 if ( $style_id === $default_style->ID && empty( $form->options['chat'] ) ) {
536 505 $style_id = 1;
537 506 }
538 507
@@ -538,27 +507,13 @@
538 507
539 508 // We want to save a string for consistency. FrmStylesHelper::get_form_count_for_style expects the custom style ID is a string.
540 509 $form->options['custom_style'] = (string) $style_id;
541 510
542 - if ( $previous_style_id === $form->options['custom_style'] ) {
543 - // Exit early before updating DB if nothing actually changed.
544 - self::$message = __( 'Successfully updated style.', 'formidable' );
545 - return;
546 - }
547 -
548 511 global $wpdb;
549 512 $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) );
550 513
551 514 FrmForm::clear_form_cache();
552 515
553 - /**
554 - * @since 6.25.1
555 - *
556 - * @param int $form_id
557 - * @param int $style_id
558 - */
559 - do_action( 'frm_after_changed_form_style', absint( $form_id ), absint( $style_id ) );
560 -
561 516 self::$message = __( 'Successfully updated style.', 'formidable' );
562 517 }
563 518
564 519 /**
@@ -564,9 +519,8 @@
564 519 /**
565 520 * Validate that we're assigning a form to a style that actually exists before assigning it to a form.
566 521 *
567 522 * @param int $style_id
568 - *
569 523 * @return bool True if the style actually exists.
570 524 */
571 525 private static function confirm_style_exists_before_setting( $style_id ) {
572 526 global $wpdb;
@@ -606,9 +560,8 @@
606 560 *
607 561 * @param stdClass|WP_Post $active_style
608 562 * @param stdClass $form
609 563 * @param WP_Post $default_style
610 - *
611 564 * @return void
612 565 */
613 566 private static function render_style_page( $active_style, $form, $default_style ) {
614 567 $style_views_path = self::get_views_path();
@@ -683,9 +636,8 @@
683 636 *
684 637 * @since 6.0
685 638 *
686 639 * @param stdClass|WP_Post $style A new style is not a WP_Post object.
687 - *
688 640 * @return void
689 641 */
690 642 private static function force_form_style( $style ) {
691 643 add_filter(
@@ -696,9 +648,9 @@
696 648 /**
697 649 * @param string $class
698 650 */
699 651 function ( $class ) {
700 - return $class && ! str_starts_with( $class, 'frm_style_' );
652 + return $class && 0 !== strpos( $class, 'frm_style_' );
701 653 }
702 654 );
703 655 $split[] = 'frm_style_' . $style->post_name;
704 656 return implode( ' ', $split );
@@ -724,9 +676,8 @@
724 676 return;
725 677 }
726 678
727 679 $id = $frm_style->update( $post_id );
728 -
729 680 if ( ! $post_id && $id ) {
730 681 self::maybe_redirect_after_save( $id );
731 682 // Set the post id to the new style so it will be loaded for editing.
732 683 $post_id = reset( $id );
@@ -731,15 +682,8 @@
731 682 // Set the post id to the new style so it will be loaded for editing.
732 683 $post_id = reset( $id );
733 684 }
734 685
735 - /**
736 - * @since 6.25.1
737 - *
738 - * @param int $post_id
739 - */
740 - do_action( 'frm_after_saved_style', absint( $post_id ) );
741 -
742 686 self::$message = __( 'Your styling settings have been saved.', 'formidable' );
743 687 }
744 688
745 689 /**
@@ -758,20 +702,19 @@
758 702 *
759 703 * @since 6.0
760 704 *
761 705 * @param array $ids
762 - *
763 706 * @return void
764 707 */
765 708 private static function maybe_redirect_after_save( $ids ) {
766 - $referer = FrmAppHelper::get_server_value( 'HTTP_REFERER' );
767 - $parsed = parse_url( $referer );
768 - $query = $parsed['query'];
709 + $referer = FrmAppHelper::get_server_value( 'HTTP_REFERER' );
710 + $parsed = parse_url( $referer );
711 + $query = $parsed['query'];
712 +
769 713 $current_action = false;
770 714 $actions_to_redirect = array( 'duplicate', 'new_style' );
771 -
772 715 foreach ( $actions_to_redirect as $action ) {
773 - if ( str_contains( $query, 'frm_action=' . $action ) ) {
716 + if ( false !== strpos( $query, 'frm_action=' . $action ) ) {
774 717 $current_action = $action;
775 718 break;
776 719 }
777 720 }
@@ -781,9 +724,10 @@
781 724 return;
782 725 }
783 726
784 727 parse_str( $query, $parsed_query );
785 - $form_id = ! empty( $parsed_query['form'] ) ? absint( $parsed_query['form'] ) : 0;
728 + $form_id = ! empty( $parsed_query['form'] ) ? absint( $parsed_query['form'] ) : 0;
729 +
786 730 $style = new stdClass();
787 731 $style->ID = end( $ids );
788 732 wp_safe_redirect( esc_url_raw( FrmStylesHelper::get_edit_url( $style, $form_id ) ) );
789 733 die();
@@ -793,9 +737,8 @@
793 737 * @since 6.0
794 738 *
795 739 * @param string $message
796 740 * @param array|object $forms
797 - *
798 741 * @return void
799 742 */
800 743 public static function manage( $message = '', $forms = array() ) {
801 744 $frm_style = new FrmStyle();
@@ -819,9 +762,8 @@
819 762 private static function manage_styles() {
820 763 global $wpdb;
821 764
822 765 $forms = FrmForm::get_published_forms();
823 -
824 766 foreach ( $forms as $form ) {
825 767 if ( ! isset( $_POST['style'] ) || ! isset( $_POST['style'][ $form->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
826 768 continue;
827 769 }
@@ -837,28 +779,15 @@
837 779 /**
838 780 * Echo content for the Custom CSS page.
839 781 *
840 782 * @param string $message
841 - * @param array $extra_args An array of extra arguments.
842 - *
843 783 * @return void
844 784 */
845 - public static function custom_css( $message = '', $extra_args = array() ) {
846 - $id = $extra_args['id'] ?? 'frm_codemirror_box';
847 - $settings = self::enqueue_codemirror( $id, $extra_args['placeholder'] ?? '' );
848 - $id = $settings ? $id : 'frm_custom_css_box';
849 - $show_errors = $extra_args['show_errors'] ?? true;
850 - $custom_css = $extra_args['custom_css'] ?? self::get_custom_css();
851 - $heading = $extra_args['heading'] ?? __( 'You can add custom css here or in your theme style.css. Any CSS added here will be used anywhere the Formidable CSS is loaded.', 'formidable' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
852 - $textarea_params = ! empty( $extra_args['textarea_params'] ) ? $extra_args['textarea_params'] : array(
853 - 'name' => 'frm_custom_css',
854 - 'id' => $id,
855 - );
785 + public static function custom_css( $message = '' ) {
786 + $settings = self::enqueue_codemirror();
787 + $id = $settings ? 'frm_codemirror_box' : 'frm_custom_css_box';
788 + $custom_css = self::get_custom_css();
856 789
857 - if ( $settings ) {
858 - $textarea_params['class'] = 'hide-if-js';
859 - }
860 -
861 790 include FrmAppHelper::plugin_path() . '/classes/views/styles/custom_css.php';
862 791 }
863 792
864 793 /**
@@ -865,33 +794,22 @@
865 794 * Get custom CSS code entered in the Custom CSS page.
866 795 *
867 796 * @since 6.0
868 797 *
869 - * @param array|null $single_style_settings The single style settings.
870 - *
871 798 * @return string
872 799 */
873 - public static function get_custom_css( $single_style_settings = null ) {
874 - if ( $single_style_settings ) {
875 - // If the single style settings are passed, return the custom CSS from the single style settings.
876 - if ( ! empty( $single_style_settings['single_style_custom_css'] ) && ! empty( $single_style_settings['enable_style_custom_css'] ) ) {
877 - return $single_style_settings['single_style_custom_css'];
878 - }
879 -
880 - return '';
881 - }
882 -
800 + public static function get_custom_css() {
883 801 $settings = FrmAppHelper::get_settings();
884 -
885 802 if ( is_string( $settings->custom_css ) ) {
886 803 return $settings->custom_css;
887 804 }
888 805
889 806 // If it does not exist, check the default style as a fallback.
890 - $frm_style = new FrmStyle();
891 - $style = $frm_style->get_default_style();
807 + $frm_style = new FrmStyle();
808 + $style = $frm_style->get_default_style();
809 + $custom_css = $style->post_content['custom_css'];
892 810
893 - return $style->post_content['custom_css'];
811 + return $custom_css;
894 812 }
895 813
896 814 /**
897 815 * Enqueue assets for codemirror, built into WordPress since 4.9.
@@ -898,14 +816,11 @@
898 816 * The Custom CSS page uses codemirror.
899 817 *
900 818 * @since 6.0 Previously this code was embedded in self::custom_css.
901 819 *
902 - * @param string $id The ID of the codemirror box.
903 - * @param string $placeholder The placeholder text for the codemirror box.
904 - *
905 820 * @return array|false
906 821 */
907 - private static function enqueue_codemirror( $id = 'frm_codemirror_box', $placeholder = '' ) {
822 + private static function enqueue_codemirror() {
908 823 if ( ! function_exists( 'wp_enqueue_code_editor' ) ) {
909 824 // The WordPress version is likely older than 4.9.
910 825 return false;
911 826 }
@@ -918,9 +833,8 @@
918 833 'tabSize' => 2,
919 834 // As the codemirror box only appears once you click into the Custom CSS tab, we need to auto-refresh.
920 835 // Otherwise the line numbers all end up with a 1px width causing overlap issues with the text in the content.
921 836 'autoRefresh' => true,
922 - 'placeholder' => $placeholder,
923 837 ),
924 838 )
925 839 );
926 840
@@ -927,11 +841,9 @@
927 841 if ( $settings ) {
928 842 wp_add_inline_script(
929 843 'code-editor',
930 844 sprintf(
931 - 'jQuery( function() { window.%s_wp_editor = wp.codeEditor.initialize( \'%s\', %s ); } );',
932 - $id,
933 - $id,
845 + 'jQuery( function() { wp.codeEditor.initialize( \'frm_codemirror_box\', %s ); } );',
934 846 wp_json_encode( $settings )
935 847 )
936 848 );
937 849 }
@@ -983,9 +895,8 @@
983 895 FrmAppHelper::permission_check( 'frm_change_settings' );
984 896 check_ajax_referer( 'frm_ajax', 'nonce' );
985 897
986 898 $style_id = FrmAppHelper::get_post_param( 'style_id', '', 'absint' );
987 -
988 899 if ( ! $style_id ) {
989 900 // A style ID is not sent when resetting on the edit page.
990 901 // Instead of resetting the style, send the defaults back so the inputs can be updated with JavaScript.
991 902 $frm_style = new FrmStyle();
@@ -1076,9 +987,8 @@
1076 987
1077 988 /**
1078 989 * @param array $atts
1079 990 * @param array $sec
1080 - *
1081 991 * @return void
1082 992 */
1083 993 public static function include_style_section( $atts, $sec ) {
1084 994 extract( $atts ); // phpcs:ignore WordPress.PHP.DontExtract
@@ -1149,10 +1059,9 @@
1149 1059 * @return void
1150 1060 */
1151 1061 public static function maybe_hide_sample_form_error_message() {
1152 1062 $referer = FrmAppHelper::get_server_value( 'HTTP_REFERER' );
1153 -
1154 - if ( str_contains( $referer, 'admin.php?page=formidable-styles' ) ) {
1063 + if ( false !== strpos( $referer, 'admin.php?page=formidable-styles' ) ) {
1155 1064 echo '#frm_broken_styles_warning { display: none; }';
1156 1065 }
1157 1066 }
1158 1067
@@ -1161,9 +1070,8 @@
1161 1070 *
1162 1071 * @since 4.11.03
1163 1072 *
1164 1073 * @param string $css CSS content.
1165 - *
1166 1074 * @return string
1167 1075 */
1168 1076 public static function replace_relative_url( $css ) {
1169 1077 $plugin_url = trailingslashit( FrmAppHelper::plugin_url() );
@@ -1186,21 +1094,18 @@
1186 1094 * Check if the Formidable styling should be loaded,
1187 1095 * then enqueue it for the footer
1188 1096 *
1189 1097 * @since 2.0
1190 - *
1191 - * @return void
1192 1098 */
1193 1099 public static function enqueue_style() {
1194 1100 global $frm_vars;
1195 1101
1196 - if ( ! empty( $frm_vars['css_loaded'] ) ) {
1102 + if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) {
1197 1103 // The CSS has already been loaded.
1198 1104 return;
1199 1105 }
1200 1106
1201 1107 $frm_settings = FrmAppHelper::get_settings();
1202 -
1203 1108 if ( $frm_settings->load_style !== 'none' ) {
1204 1109 wp_enqueue_style( 'formidable' );
1205 1110 $frm_vars['css_loaded'] = true;
1206 1111 }
@@ -1212,9 +1117,11 @@
1212 1117 * @return array<WP_Post>
1213 1118 */
1214 1119 public static function get_style_opts() {
1215 1120 $frm_style = new FrmStyle();
1216 - return $frm_style->get_all();
1121 + $styles = $frm_style->get_all();
1122 +
1123 + return $styles;
1217 1124 }
1218 1125
1219 1126 /**
1220 1127 * Get the style post object for a target form.
@@ -1219,16 +1126,14 @@
1219 1126 /**
1220 1127 * Get the style post object for a target form.
1221 1128 *
1222 1129 * @param bool|object|string $form
1223 - *
1224 1130 * @return WP_Post|null
1225 1131 */
1226 1132 public static function get_form_style( $form = 'default' ) {
1227 1133 $style = FrmFormsHelper::get_form_style( $form );
1228 1134
1229 - // phpcs:ignore Universal.Operators.StrictComparisons
1230 - if ( ! $style || 1 == $style ) {
1135 + if ( empty( $style ) || 1 == $style ) {
1231 1136 $style = 'default';
1232 1137 }
1233 1138
1234 1139 $frm_style = new FrmStyle( $style );
@@ -1237,13 +1142,10 @@
1237 1142
1238 1143 /**
1239 1144 * @param string $class
1240 1145 * @param string $style
1241 - *
1242 - * @return string
1243 1146 */
1244 1147 public static function get_form_style_class( $class, $style ) {
1245 - // phpcs:ignore Universal.Operators.StrictComparisons
1246 1148 if ( 1 == $style ) {
1247 1149 $style = 'default';
1248 1150 }
1249 1151
@@ -1259,17 +1161,13 @@
1259 1161 }
1260 1162
1261 1163 /**
1262 1164 * @since 3.0
1263 - *
1264 1165 * @param object $style
1265 1166 * @param string $class
1266 - *
1267 - * @return void
1268 1167 */
1269 1168 private static function maybe_add_rtl_class( $style, &$class ) {
1270 1169 $is_rtl = isset( $style->post_content['direction'] ) && 'rtl' === $style->post_content['direction'];
1271 -
1272 1170 if ( $is_rtl ) {
1273 1171 $class .= ' frm_rtl';
1274 1172 }
1275 1173 }
@@ -1274,28 +1172,17 @@
1274 1172 }
1275 1173 }
1276 1174
1277 1175 /**
1278 - * @param string $val Style setting key.
1279 - * @param int|string $form Form ID or 'default'.
1280 - *
1281 - * @return mixed
1176 + * @param string $val
1282 1177 */
1283 1178 public static function get_style_val( $val, $form = 'default' ) {
1284 1179 $style = self::get_form_style( $form );
1285 -
1286 1180 if ( $style && isset( $style->post_content[ $val ] ) ) {
1287 1181 return $style->post_content[ $val ];
1288 1182 }
1289 -
1290 - return null;
1291 1183 }
1292 1184
1293 - /**
1294 - * @param array $default_styles
1295 - *
1296 - * @return array
1297 - */
1298 1185 public static function show_entry_styles( $default_styles ) {
1299 1186 $frm_style = new FrmStyle( 'default' );
1300 1187 $style = $frm_style->get_one();
1301 1188
@@ -1304,15 +1191,13 @@
1304 1191 }
1305 1192
1306 1193 foreach ( $default_styles as $name => $val ) {
1307 1194 $setting = $name;
1308 -
1309 - if ( 'border_width' === $name ) {
1195 + if ( 'border_width' == $name ) {
1310 1196 $setting = 'field_border_width';
1311 - } elseif ( 'alt_bg_color' === $name ) {
1197 + } elseif ( 'alt_bg_color' == $name ) {
1312 1198 $setting = 'bg_color_active';
1313 1199 }
1314 -
1315 1200 $default_styles[ $name ] = $style->post_content[ $setting ];
1316 1201 unset( $name, $val );
1317 1202 }
1318 1203
@@ -1318,16 +1203,11 @@
1318 1203
1319 1204 return $default_styles;
1320 1205 }
1321 1206
1322 - /**
1323 - * @param string $important
1324 - * @param array $field
1325 - *
1326 - * @return string
1327 - */
1328 1207 public static function &important_style( $important, $field ) {
1329 1208 $important = self::get_style_val( 'important_style', $field['form_id'] );
1209 +
1330 1210 return $important;
1331 1211 }
1332 1212
1333 1213 /**
@@ -1334,15 +1214,11 @@
1334 1214 * Duplicate of WordPress do_accordion_section function, it adds an additional svg icon support.
1335 1215 *
1336 1216 * @since 6.8.3
1337 1217 *
1338 - * @param string|WP_Screen $screen Screen ID or screen object.
1339 - * @param string $context Meta box context.
1340 - * @param mixed $data_object Data object passed to callbacks.
1341 - *
1342 1218 * @return int
1343 1219 */
1344 - public static function do_accordion_sections( $screen, $context, $data_object ) { // phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh
1220 + public static function do_accordion_sections( $screen, $context, $data_object ) {
1345 1221 global $wp_meta_boxes;
1346 1222
1347 1223 // the symbol id from icons.svg
1348 1224 $icon_ids = array(
@@ -1351,9 +1227,9 @@
1351 1227 );
1352 1228
1353 1229 wp_enqueue_script( 'accordion' );
1354 1230
1355 - if ( ! $screen ) {
1231 + if ( empty( $screen ) ) {
1356 1232 $screen = get_current_screen();
1357 1233 } elseif ( is_string( $screen ) ) {
1358 1234 $screen = convert_to_screen( $screen );
1359 1235 }
@@ -1375,11 +1251,11 @@
1375 1251 continue;
1376 1252 }
1377 1253
1378 1254 ++$i;
1379 - $icon_id = array_key_exists( $box['id'], $icon_ids ) ? $icon_ids[ $box['id'] ] : 'frm-' . $box['id'];
1255 + $icon_id = array_key_exists( $box['id'], $icon_ids ) ? $icon_ids[ $box['id'] ] : 'frm-' . $box['id'];
1256 +
1380 1257 $open_class = '';
1381 -
1382 1258 if ( ! $first_open ) {
1383 1259 $first_open = true;
1384 1260 $open_class = 'open';
1385 1261 }
@@ -1385,16 +1261,18 @@
1385 1261 }
1386 1262
1387 1263 $accordion_content_id = 'frm_style_section_' . $box['id'];
1388 1264 ?>
1389 - <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'] ); ?>"><?php // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong ?>
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'] ); ?>">
1390 1266 <h3 class="accordion-section-title hndle">
1391 1267 <?php
1392 - FrmAppHelper::icon_by_class( 'frmfont ' . $icon_id . ' frm_svg24' );
1268 + FrmAppHelper::icon_by_class( 'frmfont ' . $icon_id );
1393 1269 echo esc_html( $box['title'] );
1394 1270 ?>
1395 - <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'] ); ?>"><?php // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong ?>
1396 - <?php FrmAppHelper::icon_by_class( 'frmfont frm_arrowdown8_icon' ); ?>
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
1273 + FrmAppHelper::icon_by_class( 'frmfont frm_arrowdown8_icon' );
1274 + ?>
1397 1275 </button>
1398 1276 </h3>
1399 1277 <div class="accordion-section-content <?php postbox_classes( $box['id'], $page ); ?>" id="<?php echo esc_attr( $accordion_content_id ); ?>">
1400 1278 <div class="inside">
@@ -1422,9 +1300,8 @@
1422 1300 * @return void
1423 1301 */
1424 1302 public static function rename_style() {
1425 1303 $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'nonce', 'frm_ajax' );
1426 -
1427 1304 if ( $permission_error !== false ) {
1428 1305 $data = array(
1429 1306 'message' => __( 'Unable to rename style', 'formidable' ),
1430 1307 );
@@ -1443,9 +1320,8 @@
1443 1320 die();
1444 1321 }
1445 1322
1446 1323 $post = get_post( $style_id );
1447 -
1448 1324 if ( ! $post || $post->post_type !== self::$post_type ) {
1449 1325 $data = array(
1450 1326 'message' => __( 'The style you are renaming either does not exist or it is not a style', 'formidable' ),
1451 1327 );
@@ -1466,9 +1342,8 @@
1466 1342 *
1467 1343 * @since 6.0
1468 1344 *
1469 1345 * @param WP_Styles $styles
1470 - *
1471 1346 * @return void
1472 1347 */
1473 1348 public static function disable_conflicting_wp_admin_css( $styles ) {
1474 1349 if ( ! FrmAppHelper::is_style_editor_page() ) {