| @@ -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( |
| @@ -101,9 +95,9 @@ | ||
| 101 | 95 | * |
| 102 | 96 | * @return void |
| 103 | 97 | */ |
| 104 | 98 | private static function disable_form_css() { |
| 105 | - add_filter( 'get_frm_stylesheet', '__return_empty_array' ); | |
| 99 | + add_filter( 'get_frm_stylesheet', '__return_false' ); | |
| 106 | 100 | } |
| 107 | 101 | |
| 108 | 102 | /** |
| 109 | 103 | * Removing this action prevents front end JavaScript from loading. |
| @@ -129,8 +123,9 @@ | ||
| 129 | 123 | FrmStyleComponent::register_assets(); |
| 130 | 124 | self::load_pro_hooks(); |
| 131 | 125 | |
| 132 | 126 | $version = FrmAppHelper::plugin_version(); |
| 127 | + wp_enqueue_script( 'jquery-ui-datepicker' ); | |
| 133 | 128 | |
| 134 | 129 | if ( FrmAppHelper::is_style_editor_page( 'edit' ) ) { |
| 135 | 130 | wp_enqueue_style( 'wp-color-picker' ); |
| 136 | 131 | } |
| @@ -137,9 +132,8 @@ | ||
| 137 | 132 | |
| 138 | 133 | wp_enqueue_style( 'frm-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_css' ), array(), $version ); |
| 139 | 134 | |
| 140 | 135 | $style = apply_filters( 'frm_style_head', false ); |
| 141 | - | |
| 142 | 136 | if ( $style ) { |
| 143 | 137 | 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 | 138 | } |
| 145 | 139 | } |
| @@ -168,9 +162,8 @@ | ||
| 168 | 162 | |
| 169 | 163 | /** |
| 170 | 164 | * @param string $register Either 'enqueue' or 'register'. |
| 171 | 165 | * @param bool $force True to enqueue/register the style if a form has not been loaded. |
| 172 | - * | |
| 173 | 166 | * @return void |
| 174 | 167 | */ |
| 175 | 168 | public static function enqueue_css( $register = 'enqueue', $force = false ) { |
| 176 | 169 | global $frm_vars; |
| @@ -182,9 +175,8 @@ | ||
| 182 | 175 | return; |
| 183 | 176 | } |
| 184 | 177 | |
| 185 | 178 | $frm_settings = FrmAppHelper::get_settings(); |
| 186 | - | |
| 187 | 179 | if ( $frm_settings->load_style === 'none' ) { |
| 188 | 180 | return; |
| 189 | 181 | } |
| 190 | 182 | |
| @@ -200,9 +192,8 @@ | ||
| 200 | 192 | wp_register_style( $css_key, $file, array(), $this_version ); |
| 201 | 193 | } |
| 202 | 194 | |
| 203 | 195 | $load_on_all = ! FrmAppHelper::is_admin() && 'all' === $frm_settings->load_style; |
| 204 | - | |
| 205 | 196 | if ( $load_on_all || $register !== 'register' ) { |
| 206 | 197 | wp_enqueue_style( $css_key ); |
| 207 | 198 | } |
| 208 | 199 | unset( $css_key, $file ); |
| @@ -233,14 +224,12 @@ | ||
| 233 | 224 | } |
| 234 | 225 | |
| 235 | 226 | /** |
| 236 | 227 | * @param array $stylesheet_urls |
| 237 | - * | |
| 238 | 228 | * @return void |
| 239 | 229 | */ |
| 240 | 230 | private static function get_url_to_custom_style( &$stylesheet_urls ) { |
| 241 | 231 | $file_name = '/css/' . self::get_file_name(); |
| 242 | - | |
| 243 | 232 | if ( is_readable( FrmAppHelper::plugin_path() . $file_name ) ) { |
| 244 | 233 | $url = FrmAppHelper::plugin_url() . $file_name; |
| 245 | 234 | } else { |
| 246 | 235 | $url = admin_url( 'admin-ajax.php?action=frmpro_css' ); |
| @@ -251,10 +240,8 @@ | ||
| 251 | 240 | /** |
| 252 | 241 | * Use a different stylesheet per site in a multisite install |
| 253 | 242 | * |
| 254 | 243 | * @since 3.0.03 |
| 255 | - * | |
| 256 | - * @return string | |
| 257 | 244 | */ |
| 258 | 245 | public static function get_file_name() { |
| 259 | 246 | if ( is_multisite() ) { |
| 260 | 247 | $blog_id = get_current_blog_id(); |
| @@ -265,18 +252,11 @@ | ||
| 265 | 252 | |
| 266 | 253 | return $name; |
| 267 | 254 | } |
| 268 | 255 | |
| 269 | - /** | |
| 270 | - * @param string $css_key | |
| 271 | - * @param string $version | |
| 272 | - * | |
| 273 | - * @return string | |
| 274 | - */ | |
| 275 | 256 | private static function get_css_version( $css_key, $version ) { |
| 276 | - if ( 'formidable' === $css_key ) { | |
| 257 | + if ( 'formidable' == $css_key ) { | |
| 277 | 258 | $this_version = get_option( 'frm_last_style_update' ); |
| 278 | - | |
| 279 | 259 | if ( ! $this_version ) { |
| 280 | 260 | $this_version = $version; |
| 281 | 261 | } |
| 282 | 262 | } else { |
| @@ -288,9 +268,8 @@ | ||
| 288 | 268 | |
| 289 | 269 | /** |
| 290 | 270 | * @param string $tag |
| 291 | 271 | * @param string $handle |
| 292 | - * | |
| 293 | 272 | * @return string |
| 294 | 273 | */ |
| 295 | 274 | public static function add_tags_to_css( $tag, $handle ) { |
| 296 | 275 | if ( ( 'formidable' === $handle || 'jquery-theme' === $handle ) && strpos( $tag, ' property=' ) === false ) { |
| @@ -344,9 +323,8 @@ | ||
| 344 | 323 | |
| 345 | 324 | self::setup_styles_and_scripts_for_styler(); |
| 346 | 325 | |
| 347 | 326 | $style_id = self::get_style_id_for_styler(); |
| 348 | - | |
| 349 | 327 | if ( ! $style_id ) { |
| 350 | 328 | $error_args = array( |
| 351 | 329 | 'title' => __( 'No styles', 'formidable' ), |
| 352 | 330 | 'body' => __( 'You must have a style to use the Visual Styler.', 'formidable' ), |
| @@ -356,9 +334,8 @@ | ||
| 356 | 334 | return; |
| 357 | 335 | } |
| 358 | 336 | |
| 359 | 337 | $form_id = FrmAppHelper::simple_get( 'form', 'absint', 0 ); |
| 360 | - | |
| 361 | 338 | if ( ! $form_id ) { |
| 362 | 339 | $form_id = self::get_form_id_for_style( $style_id ); |
| 363 | 340 | } |
| 364 | 341 | |
| @@ -396,9 +373,8 @@ | ||
| 396 | 373 | * @return int |
| 397 | 374 | */ |
| 398 | 375 | private static function get_style_id_for_styler() { |
| 399 | 376 | $action = FrmAppHelper::simple_get( 'frm_action' ); |
| 400 | - | |
| 401 | 377 | if ( 'duplicate' === $action ) { |
| 402 | 378 | // The duplicate action uses style_id instead of id for better backward compatibility. |
| 403 | 379 | return FrmAppHelper::simple_get( 'style_id', 'absint', 0 ); |
| 404 | 380 | } |
| @@ -403,9 +379,8 @@ | ||
| 403 | 379 | return FrmAppHelper::simple_get( 'style_id', 'absint', 0 ); |
| 404 | 380 | } |
| 405 | 381 | |
| 406 | 382 | $style_id = FrmAppHelper::simple_get( 'id', 'absint', 0 ); |
| 407 | - | |
| 408 | 383 | if ( $style_id ) { |
| 409 | 384 | // Always use the style ID from the URL if one is specified. |
| 410 | 385 | return $style_id; |
| 411 | 386 | } |
| @@ -410,9 +385,8 @@ | ||
| 410 | 385 | return $style_id; |
| 411 | 386 | } |
| 412 | 387 | |
| 413 | 388 | $request_form_id = FrmAppHelper::simple_get( 'form', 'absint', 0 ); |
| 414 | - | |
| 415 | 389 | if ( $request_form_id && is_callable( 'FrmProStylesController::get_active_style_for_form' ) ) { |
| 416 | 390 | return FrmProStylesController::get_active_style_for_form( $request_form_id )->ID; |
| 417 | 391 | } |
| 418 | 392 | |
| @@ -424,9 +398,8 @@ | ||
| 424 | 398 | * |
| 425 | 399 | * @since 6.0 |
| 426 | 400 | * |
| 427 | 401 | * @param int $style_id |
| 428 | - * | |
| 429 | 402 | * @return int |
| 430 | 403 | */ |
| 431 | 404 | private static function get_form_id_for_style( $style_id ) { |
| 432 | 405 | $check = serialize( array( 'custom_style' => (string) $style_id ) ); |
| @@ -487,15 +460,13 @@ | ||
| 487 | 460 | * @return void |
| 488 | 461 | */ |
| 489 | 462 | private static function save_form_style() { |
| 490 | 463 | $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form_style', 'frm_save_form_style_nonce' ); |
| 491 | - | |
| 492 | 464 | if ( $permission_error !== false ) { |
| 493 | 465 | wp_die( 'Unable to save form', '', 403 ); |
| 494 | 466 | } |
| 495 | 467 | |
| 496 | 468 | $style_id = FrmAppHelper::get_post_param( 'style_id', 0, 'absint' ); |
| 497 | - | |
| 498 | 469 | if ( $style_id && ! self::confirm_style_exists_before_setting( $style_id ) ) { |
| 499 | 470 | wp_die( esc_html__( 'Invalid target style', 'formidable' ), esc_html__( 'Invalid target style', 'formidable' ), 400 ); |
| 500 | 471 | return; |
| 501 | 472 | } |
| @@ -515,9 +486,8 @@ | ||
| 515 | 486 | return; |
| 516 | 487 | } |
| 517 | 488 | |
| 518 | 489 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 519 | - | |
| 520 | 490 | if ( ! $form_id ) { |
| 521 | 491 | wp_die( esc_html__( 'No form specified', 'formidable' ), esc_html__( 'No form specified', 'formidable' ), 400 ); |
| 522 | 492 | return; |
| 523 | 493 | } |
| @@ -522,21 +492,17 @@ | ||
| 522 | 492 | return; |
| 523 | 493 | } |
| 524 | 494 | |
| 525 | 495 | $form = FrmForm::getOne( $form_id ); |
| 526 | - | |
| 527 | 496 | if ( ! $form ) { |
| 528 | 497 | wp_die( esc_html__( 'Form does not exist', 'formidable' ), esc_html__( 'Form does not exist', 'formidable' ), 400 ); |
| 529 | 498 | return; |
| 530 | 499 | } |
| 531 | 500 | |
| 532 | - $previous_style_id = $form->options['custom_style']; | |
| 533 | - | |
| 534 | 501 | // If the default style is selected, use the "Always use default" legacy option instead of the default style. |
| 535 | 502 | // There's also a check here for conversational forms. |
| 536 | 503 | // Without the check it isn't possible to select "Default" because "Always use default" will convert to "Lines" dynamically. |
| 537 | 504 | $default_style = self::get_default_style(); |
| 538 | - | |
| 539 | 505 | if ( $style_id === $default_style->ID && empty( $form->options['chat'] ) ) { |
| 540 | 506 | $style_id = 1; |
| 541 | 507 | } |
| 542 | 508 | |
| @@ -542,27 +508,13 @@ | ||
| 542 | 508 | |
| 543 | 509 | // We want to save a string for consistency. FrmStylesHelper::get_form_count_for_style expects the custom style ID is a string. |
| 544 | 510 | $form->options['custom_style'] = (string) $style_id; |
| 545 | 511 | |
| 546 | - if ( $previous_style_id === $form->options['custom_style'] ) { | |
| 547 | - // Exit early before updating DB if nothing actually changed. | |
| 548 | - self::$message = __( 'Successfully updated style.', 'formidable' ); | |
| 549 | - return; | |
| 550 | - } | |
| 551 | - | |
| 552 | 512 | global $wpdb; |
| 553 | 513 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 554 | 514 | |
| 555 | 515 | FrmForm::clear_form_cache(); |
| 556 | 516 | |
| 557 | - /** | |
| 558 | - * @since 6.25.1 | |
| 559 | - * | |
| 560 | - * @param int $form_id | |
| 561 | - * @param int $style_id | |
| 562 | - */ | |
| 563 | - do_action( 'frm_after_changed_form_style', absint( $form_id ), absint( $style_id ) ); | |
| 564 | - | |
| 565 | 517 | self::$message = __( 'Successfully updated style.', 'formidable' ); |
| 566 | 518 | } |
| 567 | 519 | |
| 568 | 520 | /** |
| @@ -568,9 +520,8 @@ | ||
| 568 | 520 | /** |
| 569 | 521 | * Validate that we're assigning a form to a style that actually exists before assigning it to a form. |
| 570 | 522 | * |
| 571 | 523 | * @param int $style_id |
| 572 | - * | |
| 573 | 524 | * @return bool True if the style actually exists. |
| 574 | 525 | */ |
| 575 | 526 | private static function confirm_style_exists_before_setting( $style_id ) { |
| 576 | 527 | global $wpdb; |
| @@ -589,9 +540,9 @@ | ||
| 589 | 540 | $plugin_url = FrmAppHelper::plugin_url(); |
| 590 | 541 | $version = FrmAppHelper::plugin_version(); |
| 591 | 542 | $js_dependencies = array( 'wp-i18n', 'wp-hooks', 'formidable_dom' ); |
| 592 | 543 | |
| 593 | - if ( FrmAppHelper::pro_is_installed() && is_callable( 'FrmProAppHelper::use_jquery_datepicker' ) && FrmProAppHelper::use_jquery_datepicker() ) { | |
| 544 | + if ( FrmAppHelper::pro_is_installed() ) { | |
| 594 | 545 | $js_dependencies[] = 'jquery-ui-datepicker'; |
| 595 | 546 | } |
| 596 | 547 | |
| 597 | 548 | wp_register_script( 'formidable_style', $plugin_url . '/js/admin/style.js', $js_dependencies, $version ); |
| @@ -610,9 +561,8 @@ | ||
| 610 | 561 | * |
| 611 | 562 | * @param stdClass|WP_Post $active_style |
| 612 | 563 | * @param stdClass $form |
| 613 | 564 | * @param WP_Post $default_style |
| 614 | - * | |
| 615 | 565 | * @return void |
| 616 | 566 | */ |
| 617 | 567 | private static function render_style_page( $active_style, $form, $default_style ) { |
| 618 | 568 | $style_views_path = self::get_views_path(); |
| @@ -687,9 +637,8 @@ | ||
| 687 | 637 | * |
| 688 | 638 | * @since 6.0 |
| 689 | 639 | * |
| 690 | 640 | * @param stdClass|WP_Post $style A new style is not a WP_Post object. |
| 691 | - * | |
| 692 | 641 | * @return void |
| 693 | 642 | */ |
| 694 | 643 | private static function force_form_style( $style ) { |
| 695 | 644 | add_filter( |
| @@ -728,9 +677,8 @@ | ||
| 728 | 677 | return; |
| 729 | 678 | } |
| 730 | 679 | |
| 731 | 680 | $id = $frm_style->update( $post_id ); |
| 732 | - | |
| 733 | 681 | if ( ! $post_id && $id ) { |
| 734 | 682 | self::maybe_redirect_after_save( $id ); |
| 735 | 683 | // Set the post id to the new style so it will be loaded for editing. |
| 736 | 684 | $post_id = reset( $id ); |
| @@ -735,15 +683,8 @@ | ||
| 735 | 683 | // Set the post id to the new style so it will be loaded for editing. |
| 736 | 684 | $post_id = reset( $id ); |
| 737 | 685 | } |
| 738 | 686 | |
| 739 | - /** | |
| 740 | - * @since 6.25.1 | |
| 741 | - * | |
| 742 | - * @param int $post_id | |
| 743 | - */ | |
| 744 | - do_action( 'frm_after_saved_style', absint( $post_id ) ); | |
| 745 | - | |
| 746 | 687 | self::$message = __( 'Your styling settings have been saved.', 'formidable' ); |
| 747 | 688 | } |
| 748 | 689 | |
| 749 | 690 | /** |
| @@ -762,9 +703,8 @@ | ||
| 762 | 703 | * |
| 763 | 704 | * @since 6.0 |
| 764 | 705 | * |
| 765 | 706 | * @param array $ids |
| 766 | - * | |
| 767 | 707 | * @return void |
| 768 | 708 | */ |
| 769 | 709 | private static function maybe_redirect_after_save( $ids ) { |
| 770 | 710 | $referer = FrmAppHelper::get_server_value( 'HTTP_REFERER' ); |
| @@ -772,9 +712,8 @@ | ||
| 772 | 712 | $query = $parsed['query']; |
| 773 | 713 | |
| 774 | 714 | $current_action = false; |
| 775 | 715 | $actions_to_redirect = array( 'duplicate', 'new_style' ); |
| 776 | - | |
| 777 | 716 | foreach ( $actions_to_redirect as $action ) { |
| 778 | 717 | if ( false !== strpos( $query, 'frm_action=' . $action ) ) { |
| 779 | 718 | $current_action = $action; |
| 780 | 719 | break; |
| @@ -799,9 +738,8 @@ | ||
| 799 | 738 | * @since 6.0 |
| 800 | 739 | * |
| 801 | 740 | * @param string $message |
| 802 | 741 | * @param array|object $forms |
| 803 | - * | |
| 804 | 742 | * @return void |
| 805 | 743 | */ |
| 806 | 744 | public static function manage( $message = '', $forms = array() ) { |
| 807 | 745 | $frm_style = new FrmStyle(); |
| @@ -806,9 +744,8 @@ | ||
| 806 | 744 | public static function manage( $message = '', $forms = array() ) { |
| 807 | 745 | $frm_style = new FrmStyle(); |
| 808 | 746 | $styles = $frm_style->get_all(); |
| 809 | 747 | $default_style = $frm_style->get_default_style( $styles ); |
| 810 | - $frm_settings = FrmAppHelper::get_settings(); | |
| 811 | 748 | |
| 812 | 749 | if ( ! $forms ) { |
| 813 | 750 | $forms = FrmForm::get_published_forms(); |
| 814 | 751 | } |
| @@ -825,16 +762,15 @@ | ||
| 825 | 762 | private static function manage_styles() { |
| 826 | 763 | global $wpdb; |
| 827 | 764 | |
| 828 | 765 | $forms = FrmForm::get_published_forms(); |
| 829 | - | |
| 830 | 766 | foreach ( $forms as $form ) { |
| 831 | - if ( ! isset( $_POST['style'] ) || ! isset( $_POST['style'][ $form->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 767 | + $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 | |
| 768 | + $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 | |
| 769 | + if ( $new_style == $previous_style ) { | |
| 832 | 770 | continue; |
| 833 | 771 | } |
| 834 | 772 | |
| 835 | - $new_style = sanitize_text_field( wp_unslash( $_POST['style'][ $form->id ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 836 | - | |
| 837 | 773 | $form->options['custom_style'] = $new_style; |
| 838 | 774 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 839 | 775 | unset( $form ); |
| 840 | 776 | } |
| @@ -843,27 +779,15 @@ | ||
| 843 | 779 | /** |
| 844 | 780 | * Echo content for the Custom CSS page. |
| 845 | 781 | * |
| 846 | 782 | * @param string $message |
| 847 | - * @param array $extra_args An array of extra arguments. | |
| 848 | - * | |
| 849 | 783 | * @return void |
| 850 | 784 | */ |
| 851 | - public static function custom_css( $message = '', $extra_args = array() ) { | |
| 852 | - $id = $extra_args['id'] ?? 'frm_codemirror_box'; | |
| 853 | - $settings = self::enqueue_codemirror( $id, $extra_args['placeholder'] ?? '' ); | |
| 854 | - $id = $settings ? $id : 'frm_custom_css_box'; | |
| 855 | - $show_errors = $extra_args['show_errors'] ?? true; | |
| 856 | - $custom_css = $extra_args['custom_css'] ?? self::get_custom_css(); | |
| 857 | - $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' ); | |
| 858 | - $textarea_params = ! empty( $extra_args['textarea_params'] ) ? $extra_args['textarea_params'] : array( | |
| 859 | - 'name' => 'frm_custom_css', | |
| 860 | - 'id' => $id, | |
| 861 | - ); | |
| 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(); | |
| 862 | 789 | |
| 863 | - if ( ! empty( $settings ) ) { | |
| 864 | - $textarea_params['class'] = 'hide-if-js'; | |
| 865 | - } | |
| 866 | 790 | include FrmAppHelper::plugin_path() . '/classes/views/styles/custom_css.php'; |
| 867 | 791 | } |
| 868 | 792 | |
| 869 | 793 | /** |
| @@ -870,20 +794,12 @@ | ||
| 870 | 794 | * Get custom CSS code entered in the Custom CSS page. |
| 871 | 795 | * |
| 872 | 796 | * @since 6.0 |
| 873 | 797 | * |
| 874 | - * @param array|null $single_style_settings The single style settings. | |
| 875 | - * | |
| 876 | 798 | * @return string |
| 877 | 799 | */ |
| 878 | - public static function get_custom_css( $single_style_settings = null ) { | |
| 879 | - // If the single style settings are passed, return the custom CSS from the single style settings. | |
| 880 | - if ( ! empty( $single_style_settings['single_style_custom_css'] ) && ! empty( $single_style_settings['enable_style_custom_css'] ) ) { | |
| 881 | - return $single_style_settings['single_style_custom_css']; | |
| 882 | - } | |
| 883 | - | |
| 800 | + public static function get_custom_css() { | |
| 884 | 801 | $settings = FrmAppHelper::get_settings(); |
| 885 | - | |
| 886 | 802 | if ( is_string( $settings->custom_css ) ) { |
| 887 | 803 | return $settings->custom_css; |
| 888 | 804 | } |
| 889 | 805 | |
| @@ -900,14 +816,11 @@ | ||
| 900 | 816 | * The Custom CSS page uses codemirror. |
| 901 | 817 | * |
| 902 | 818 | * @since 6.0 Previously this code was embedded in self::custom_css. |
| 903 | 819 | * |
| 904 | - * @param string $id The ID of the codemirror box. | |
| 905 | - * @param string $placeholder The placeholder text for the codemirror box. | |
| 906 | - * | |
| 907 | 820 | * @return array|false |
| 908 | 821 | */ |
| 909 | - private static function enqueue_codemirror( $id = 'frm_codemirror_box', $placeholder = '' ) { | |
| 822 | + private static function enqueue_codemirror() { | |
| 910 | 823 | if ( ! function_exists( 'wp_enqueue_code_editor' ) ) { |
| 911 | 824 | // The WordPress version is likely older than 4.9. |
| 912 | 825 | return false; |
| 913 | 826 | } |
| @@ -920,9 +833,8 @@ | ||
| 920 | 833 | 'tabSize' => 2, |
| 921 | 834 | // As the codemirror box only appears once you click into the Custom CSS tab, we need to auto-refresh. |
| 922 | 835 | // Otherwise the line numbers all end up with a 1px width causing overlap issues with the text in the content. |
| 923 | 836 | 'autoRefresh' => true, |
| 924 | - 'placeholder' => $placeholder, | |
| 925 | 837 | ), |
| 926 | 838 | ) |
| 927 | 839 | ); |
| 928 | 840 | |
| @@ -929,11 +841,9 @@ | ||
| 929 | 841 | if ( $settings ) { |
| 930 | 842 | wp_add_inline_script( |
| 931 | 843 | 'code-editor', |
| 932 | 844 | sprintf( |
| 933 | - 'jQuery( function() { window.%s_wp_editor = wp.codeEditor.initialize( \'%s\', %s ); } );', | |
| 934 | - $id, | |
| 935 | - $id, | |
| 845 | + 'jQuery( function() { wp.codeEditor.initialize( \'frm_codemirror_box\', %s ); } );', | |
| 936 | 846 | wp_json_encode( $settings ) |
| 937 | 847 | ) |
| 938 | 848 | ); |
| 939 | 849 | } |
| @@ -985,9 +895,8 @@ | ||
| 985 | 895 | FrmAppHelper::permission_check( 'frm_change_settings' ); |
| 986 | 896 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 987 | 897 | |
| 988 | 898 | $style_id = FrmAppHelper::get_post_param( 'style_id', '', 'absint' ); |
| 989 | - | |
| 990 | 899 | if ( ! $style_id ) { |
| 991 | 900 | // A style ID is not sent when resetting on the edit page. |
| 992 | 901 | // Instead of resetting the style, send the defaults back so the inputs can be updated with JavaScript. |
| 993 | 902 | $frm_style = new FrmStyle(); |
| @@ -1078,9 +987,8 @@ | ||
| 1078 | 987 | |
| 1079 | 988 | /** |
| 1080 | 989 | * @param array $atts |
| 1081 | 990 | * @param array $sec |
| 1082 | - * | |
| 1083 | 991 | * @return void |
| 1084 | 992 | */ |
| 1085 | 993 | public static function include_style_section( $atts, $sec ) { |
| 1086 | 994 | extract( $atts ); // phpcs:ignore WordPress.PHP.DontExtract |
| @@ -1151,9 +1059,8 @@ | ||
| 1151 | 1059 | * @return void |
| 1152 | 1060 | */ |
| 1153 | 1061 | public static function maybe_hide_sample_form_error_message() { |
| 1154 | 1062 | $referer = FrmAppHelper::get_server_value( 'HTTP_REFERER' ); |
| 1155 | - | |
| 1156 | 1063 | if ( false !== strpos( $referer, 'admin.php?page=formidable-styles' ) ) { |
| 1157 | 1064 | echo '#frm_broken_styles_warning { display: none; }'; |
| 1158 | 1065 | } |
| 1159 | 1066 | } |
| @@ -1163,9 +1070,8 @@ | ||
| 1163 | 1070 | * |
| 1164 | 1071 | * @since 4.11.03 |
| 1165 | 1072 | * |
| 1166 | 1073 | * @param string $css CSS content. |
| 1167 | - * | |
| 1168 | 1074 | * @return string |
| 1169 | 1075 | */ |
| 1170 | 1076 | public static function replace_relative_url( $css ) { |
| 1171 | 1077 | $plugin_url = trailingslashit( FrmAppHelper::plugin_url() ); |
| @@ -1188,10 +1094,8 @@ | ||
| 1188 | 1094 | * Check if the Formidable styling should be loaded, |
| 1189 | 1095 | * then enqueue it for the footer |
| 1190 | 1096 | * |
| 1191 | 1097 | * @since 2.0 |
| 1192 | - * | |
| 1193 | - * @return void | |
| 1194 | 1098 | */ |
| 1195 | 1099 | public static function enqueue_style() { |
| 1196 | 1100 | global $frm_vars; |
| 1197 | 1101 | |
| @@ -1200,9 +1104,8 @@ | ||
| 1200 | 1104 | return; |
| 1201 | 1105 | } |
| 1202 | 1106 | |
| 1203 | 1107 | $frm_settings = FrmAppHelper::get_settings(); |
| 1204 | - | |
| 1205 | 1108 | if ( $frm_settings->load_style !== 'none' ) { |
| 1206 | 1109 | wp_enqueue_style( 'formidable' ); |
| 1207 | 1110 | $frm_vars['css_loaded'] = true; |
| 1208 | 1111 | } |
| @@ -1223,9 +1126,8 @@ | ||
| 1223 | 1126 | /** |
| 1224 | 1127 | * Get the style post object for a target form. |
| 1225 | 1128 | * |
| 1226 | 1129 | * @param bool|object|string $form |
| 1227 | - * | |
| 1228 | 1130 | * @return WP_Post|null |
| 1229 | 1131 | */ |
| 1230 | 1132 | public static function get_form_style( $form = 'default' ) { |
| 1231 | 1133 | $style = FrmFormsHelper::get_form_style( $form ); |
| @@ -1240,10 +1142,8 @@ | ||
| 1240 | 1142 | |
| 1241 | 1143 | /** |
| 1242 | 1144 | * @param string $class |
| 1243 | 1145 | * @param string $style |
| 1244 | - * | |
| 1245 | - * @return string | |
| 1246 | 1146 | */ |
| 1247 | 1147 | public static function get_form_style_class( $class, $style ) { |
| 1248 | 1148 | if ( 1 == $style ) { |
| 1249 | 1149 | $style = 'default'; |
| @@ -1261,17 +1161,13 @@ | ||
| 1261 | 1161 | } |
| 1262 | 1162 | |
| 1263 | 1163 | /** |
| 1264 | 1164 | * @since 3.0 |
| 1265 | - * | |
| 1266 | 1165 | * @param object $style |
| 1267 | 1166 | * @param string $class |
| 1268 | - * | |
| 1269 | - * @return void | |
| 1270 | 1167 | */ |
| 1271 | 1168 | private static function maybe_add_rtl_class( $style, &$class ) { |
| 1272 | 1169 | $is_rtl = isset( $style->post_content['direction'] ) && 'rtl' === $style->post_content['direction']; |
| 1273 | - | |
| 1274 | 1170 | if ( $is_rtl ) { |
| 1275 | 1171 | $class .= ' frm_rtl'; |
| 1276 | 1172 | } |
| 1277 | 1173 | } |
| @@ -1276,26 +1172,17 @@ | ||
| 1276 | 1172 | } |
| 1277 | 1173 | } |
| 1278 | 1174 | |
| 1279 | 1175 | /** |
| 1280 | - * @param string $val Style setting key. | |
| 1281 | - * @param int|string $form Form ID or 'default'. | |
| 1282 | - * | |
| 1283 | - * @return mixed | |
| 1176 | + * @param string $val | |
| 1284 | 1177 | */ |
| 1285 | 1178 | public static function get_style_val( $val, $form = 'default' ) { |
| 1286 | 1179 | $style = self::get_form_style( $form ); |
| 1287 | - | |
| 1288 | 1180 | if ( $style && isset( $style->post_content[ $val ] ) ) { |
| 1289 | 1181 | return $style->post_content[ $val ]; |
| 1290 | 1182 | } |
| 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,9 +1191,8 @@ | ||
| 1304 | 1191 | } |
| 1305 | 1192 | |
| 1306 | 1193 | foreach ( $default_styles as $name => $val ) { |
| 1307 | 1194 | $setting = $name; |
| 1308 | - | |
| 1309 | 1195 | if ( 'border_width' == $name ) { |
| 1310 | 1196 | $setting = 'field_border_width'; |
| 1311 | 1197 | } elseif ( 'alt_bg_color' == $name ) { |
| 1312 | 1198 | $setting = 'bg_color_active'; |
| @@ -1317,14 +1203,8 @@ | ||
| 1317 | 1203 | |
| 1318 | 1204 | return $default_styles; |
| 1319 | 1205 | } |
| 1320 | 1206 | |
| 1321 | - /** | |
| 1322 | - * @param string $important | |
| 1323 | - * @param array $field | |
| 1324 | - * | |
| 1325 | - * @return string | |
| 1326 | - */ | |
| 1327 | 1207 | public static function &important_style( $important, $field ) { |
| 1328 | 1208 | $important = self::get_style_val( 'important_style', $field['form_id'] ); |
| 1329 | 1209 | |
| 1330 | 1210 | return $important; |
| @@ -1334,12 +1214,8 @@ | ||
| 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 | 1220 | public static function do_accordion_sections( $screen, $context, $data_object ) { |
| 1345 | 1221 | global $wp_meta_boxes; |
| @@ -1378,27 +1254,22 @@ | ||
| 1378 | 1254 | ++$i; |
| 1379 | 1255 | $icon_id = array_key_exists( $box['id'], $icon_ids ) ? $icon_ids[ $box['id'] ] : 'frm-' . $box['id']; |
| 1380 | 1256 | |
| 1381 | 1257 | $open_class = ''; |
| 1382 | - | |
| 1383 | 1258 | if ( ! $first_open ) { |
| 1384 | 1259 | $first_open = true; |
| 1385 | 1260 | $open_class = 'open'; |
| 1386 | 1261 | } |
| 1387 | - | |
| 1388 | - $accordion_content_id = 'frm_style_section_' . $box['id']; | |
| 1389 | 1262 | ?> |
| 1390 | 1263 | <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'] ); ?>"> |
| 1391 | - <h3 class="accordion-section-title hndle"> | |
| 1264 | + <h3 class="accordion-section-title hndle" tabindex="0"> | |
| 1392 | 1265 | <?php |
| 1393 | - FrmAppHelper::icon_by_class( 'frmfont ' . $icon_id . ' frm_svg24' ); | |
| 1266 | + FrmAppHelper::icon_by_class( 'frmfont ' . $icon_id ); | |
| 1394 | 1267 | echo esc_html( $box['title'] ); |
| 1268 | + FrmAppHelper::icon_by_class( 'frmfont frm_arrowdown8_icon' ); | |
| 1395 | 1269 | ?> |
| 1396 | - <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'] ); ?>"> | |
| 1397 | - <?php FrmAppHelper::icon_by_class( 'frmfont frm_arrowdown8_icon' ); ?> | |
| 1398 | - </button> | |
| 1399 | 1270 | </h3> |
| 1400 | - <div class="accordion-section-content <?php postbox_classes( $box['id'], $page ); ?>" id="<?php echo esc_attr( $accordion_content_id ); ?>"> | |
| 1271 | + <div class="accordion-section-content <?php postbox_classes( $box['id'], $page ); ?>"> | |
| 1401 | 1272 | <div class="inside"> |
| 1402 | 1273 | <?php call_user_func( $box['callback'], $data_object, $box ); ?> |
| 1403 | 1274 | </div><!-- .inside --> |
| 1404 | 1275 | </div><!-- .accordion-section-content --> |
| @@ -1423,9 +1294,8 @@ | ||
| 1423 | 1294 | * @return void |
| 1424 | 1295 | */ |
| 1425 | 1296 | public static function rename_style() { |
| 1426 | 1297 | $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'nonce', 'frm_ajax' ); |
| 1427 | - | |
| 1428 | 1298 | if ( $permission_error !== false ) { |
| 1429 | 1299 | $data = array( |
| 1430 | 1300 | 'message' => __( 'Unable to rename style', 'formidable' ), |
| 1431 | 1301 | ); |
| @@ -1444,9 +1314,8 @@ | ||
| 1444 | 1314 | die(); |
| 1445 | 1315 | } |
| 1446 | 1316 | |
| 1447 | 1317 | $post = get_post( $style_id ); |
| 1448 | - | |
| 1449 | 1318 | if ( ! $post || $post->post_type !== self::$post_type ) { |
| 1450 | 1319 | $data = array( |
| 1451 | 1320 | 'message' => __( 'The style you are renaming either does not exist or it is not a style', 'formidable' ), |
| 1452 | 1321 | ); |
| @@ -1467,9 +1336,8 @@ | ||
| 1467 | 1336 | * |
| 1468 | 1337 | * @since 6.0 |
| 1469 | 1338 | * |
| 1470 | 1339 | * @param WP_Styles $styles |
| 1471 | - * | |
| 1472 | 1340 | * @return void |
| 1473 | 1341 | */ |
| 1474 | 1342 | public static function disable_conflicting_wp_admin_css( $styles ) { |
| 1475 | 1343 | if ( ! FrmAppHelper::is_style_editor_page() ) { |