| @@ -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. |
| @@ -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,19 +123,19 @@ | ||
| 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 | 132 | |
| 138 | - wp_enqueue_style( 'frm-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_css&frm_scope_custom_css=1' ), array(), $version ); | |
| 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 | - 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 | |
| 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 | } |
| 146 | 140 | |
| 147 | 141 | /** |
| @@ -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,20 +224,17 @@ | ||
| 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' ); |
| 247 | 236 | } |
| 248 | - | |
| 249 | 237 | $stylesheet_urls['formidable'] = $url; |
| 250 | 238 | } |
| 251 | 239 | |
| 252 | 240 | /** |
| @@ -252,44 +240,42 @@ | ||
| 252 | 240 | /** |
| 253 | 241 | * Use a different stylesheet per site in a multisite install |
| 254 | 242 | * |
| 255 | 243 | * @since 3.0.03 |
| 256 | - * | |
| 257 | - * @return string | |
| 258 | 244 | */ |
| 259 | 245 | public static function get_file_name() { |
| 260 | 246 | if ( is_multisite() ) { |
| 261 | - return 'formidableforms' . absint( get_current_blog_id() ) . '.css'; | |
| 247 | + $blog_id = get_current_blog_id(); | |
| 248 | + $name = 'formidableforms' . absint( $blog_id ) . '.css'; | |
| 249 | + } else { | |
| 250 | + $name = 'formidableforms.css'; | |
| 262 | 251 | } |
| 263 | 252 | |
| 264 | - return 'formidableforms.css'; | |
| 253 | + return $name; | |
| 265 | 254 | } |
| 266 | 255 | |
| 267 | - /** | |
| 268 | - * @param string $css_key | |
| 269 | - * @param string $version | |
| 270 | - * | |
| 271 | - * @return string | |
| 272 | - */ | |
| 273 | 256 | private static function get_css_version( $css_key, $version ) { |
| 274 | - if ( 'formidable' !== $css_key ) { | |
| 275 | - return $version; | |
| 257 | + if ( 'formidable' == $css_key ) { | |
| 258 | + $this_version = get_option( 'frm_last_style_update' ); | |
| 259 | + if ( ! $this_version ) { | |
| 260 | + $this_version = $version; | |
| 261 | + } | |
| 262 | + } else { | |
| 263 | + $this_version = $version; | |
| 276 | 264 | } |
| 277 | 265 | |
| 278 | - $this_version = get_option( 'frm_last_style_update' ); | |
| 279 | - | |
| 280 | - return $this_version ? $this_version : $version; | |
| 266 | + return $this_version; | |
| 281 | 267 | } |
| 282 | 268 | |
| 283 | 269 | /** |
| 284 | 270 | * @param string $tag |
| 285 | 271 | * @param string $handle |
| 286 | - * | |
| 287 | 272 | * @return string |
| 288 | 273 | */ |
| 289 | 274 | public static function add_tags_to_css( $tag, $handle ) { |
| 290 | - if ( ( 'formidable' === $handle || 'jquery-theme' === $handle ) && ! str_contains( $tag, ' property=' ) ) { | |
| 291 | - return str_replace( ' type="', ' property="stylesheet" type="', $tag ); | |
| 275 | + if ( ( 'formidable' === $handle || 'jquery-theme' === $handle ) && strpos( $tag, ' property=' ) === false ) { | |
| 276 | + $frm_settings = FrmAppHelper::get_settings(); | |
| 277 | + $tag = str_replace( ' type="', ' property="stylesheet" type="', $tag ); | |
| 292 | 278 | } |
| 293 | 279 | |
| 294 | 280 | return $tag; |
| 295 | 281 | } |
| @@ -337,11 +323,10 @@ | ||
| 337 | 323 | |
| 338 | 324 | self::setup_styles_and_scripts_for_styler(); |
| 339 | 325 | |
| 340 | 326 | $style_id = self::get_style_id_for_styler(); |
| 341 | - | |
| 342 | 327 | if ( ! $style_id ) { |
| 343 | - $error_args = array( | |
| 328 | + $error_args = array( | |
| 344 | 329 | 'title' => __( 'No styles', 'formidable' ), |
| 345 | 330 | 'body' => __( 'You must have a style to use the Visual Styler.', 'formidable' ), |
| 346 | 331 | 'cancel_url' => admin_url( 'admin.php?page=formidable' ), |
| 347 | 332 | ); |
| @@ -349,9 +334,8 @@ | ||
| 349 | 334 | return; |
| 350 | 335 | } |
| 351 | 336 | |
| 352 | 337 | $form_id = FrmAppHelper::simple_get( 'form', 'absint', 0 ); |
| 353 | - | |
| 354 | 338 | if ( ! $form_id ) { |
| 355 | 339 | $form_id = self::get_form_id_for_style( $style_id ); |
| 356 | 340 | } |
| 357 | 341 | |
| @@ -357,9 +341,9 @@ | ||
| 357 | 341 | |
| 358 | 342 | $form = FrmForm::getOne( $form_id ); |
| 359 | 343 | |
| 360 | 344 | if ( ! is_object( $form ) ) { |
| 361 | - $error_args = array( | |
| 345 | + $error_args = array( | |
| 362 | 346 | 'title' => __( 'No forms', 'formidable' ), |
| 363 | 347 | 'body' => __( 'You must have a form to use the Visual Styler.', 'formidable' ), |
| 364 | 348 | 'cancel_url' => admin_url( 'admin.php?page=formidable' ), |
| 365 | 349 | ); |
| @@ -366,10 +350,11 @@ | ||
| 366 | 350 | FrmAppController::show_error_modal( $error_args ); |
| 367 | 351 | return; |
| 368 | 352 | } |
| 369 | 353 | |
| 370 | - $frm_style = new FrmStyle( $style_id ); | |
| 371 | - $active_style = $frm_style->get_one(); | |
| 354 | + $frm_style = new FrmStyle( $style_id ); | |
| 355 | + $active_style = $frm_style->get_one(); | |
| 356 | + $default_style = self::get_default_style(); | |
| 372 | 357 | |
| 373 | 358 | self::disable_admin_page_styling_on_submit_buttons(); |
| 374 | 359 | |
| 375 | 360 | /** |
| @@ -378,9 +363,9 @@ | ||
| 378 | 363 | * @param array{form:\stdClass} $data |
| 379 | 364 | */ |
| 380 | 365 | do_action( 'frm_before_render_style_page', compact( 'form' ) ); |
| 381 | 366 | |
| 382 | - self::render_style_page( $active_style, $form, self::get_default_style() ); | |
| 367 | + self::render_style_page( $active_style, $form, $default_style ); | |
| 383 | 368 | } |
| 384 | 369 | |
| 385 | 370 | /** |
| 386 | 371 | * @since 6.0 |
| @@ -388,9 +373,8 @@ | ||
| 388 | 373 | * @return int |
| 389 | 374 | */ |
| 390 | 375 | private static function get_style_id_for_styler() { |
| 391 | 376 | $action = FrmAppHelper::simple_get( 'frm_action' ); |
| 392 | - | |
| 393 | 377 | if ( 'duplicate' === $action ) { |
| 394 | 378 | // The duplicate action uses style_id instead of id for better backward compatibility. |
| 395 | 379 | return FrmAppHelper::simple_get( 'style_id', 'absint', 0 ); |
| 396 | 380 | } |
| @@ -395,9 +379,8 @@ | ||
| 395 | 379 | return FrmAppHelper::simple_get( 'style_id', 'absint', 0 ); |
| 396 | 380 | } |
| 397 | 381 | |
| 398 | 382 | $style_id = FrmAppHelper::simple_get( 'id', 'absint', 0 ); |
| 399 | - | |
| 400 | 383 | if ( $style_id ) { |
| 401 | 384 | // Always use the style ID from the URL if one is specified. |
| 402 | 385 | return $style_id; |
| 403 | 386 | } |
| @@ -402,9 +385,8 @@ | ||
| 402 | 385 | return $style_id; |
| 403 | 386 | } |
| 404 | 387 | |
| 405 | 388 | $request_form_id = FrmAppHelper::simple_get( 'form', 'absint', 0 ); |
| 406 | - | |
| 407 | 389 | if ( $request_form_id && is_callable( 'FrmProStylesController::get_active_style_for_form' ) ) { |
| 408 | 390 | return FrmProStylesController::get_active_style_for_form( $request_form_id )->ID; |
| 409 | 391 | } |
| 410 | 392 | |
| @@ -416,9 +398,8 @@ | ||
| 416 | 398 | * |
| 417 | 399 | * @since 6.0 |
| 418 | 400 | * |
| 419 | 401 | * @param int $style_id |
| 420 | - * | |
| 421 | 402 | * @return int |
| 422 | 403 | */ |
| 423 | 404 | private static function get_form_id_for_style( $style_id ) { |
| 424 | 405 | $check = serialize( array( 'custom_style' => (string) $style_id ) ); |
| @@ -431,8 +412,9 @@ | ||
| 431 | 412 | ) |
| 432 | 413 | ); |
| 433 | 414 | |
| 434 | 415 | if ( ! $form_id ) { |
| 416 | + // TODO: Show a message why a random form is being shown (because no form is assigned to the style). | |
| 435 | 417 | // Fallback to any form. |
| 436 | 418 | $where = array( |
| 437 | 419 | 'status' => 'published', |
| 438 | 420 | // Make sure it's not a repeater. |
| @@ -464,10 +446,11 @@ | ||
| 464 | 446 | * |
| 465 | 447 | * @return WP_Post |
| 466 | 448 | */ |
| 467 | 449 | private static function get_default_style() { |
| 468 | - $frm_style = new FrmStyle( 'default' ); | |
| 469 | - return $frm_style->get_one(); | |
| 450 | + $frm_style = new FrmStyle( 'default' ); | |
| 451 | + $default_style = $frm_style->get_one(); | |
| 452 | + return $default_style; | |
| 470 | 453 | } |
| 471 | 454 | |
| 472 | 455 | /** |
| 473 | 456 | * Save style for form (from Styler list page) via a POST action. |
| @@ -477,15 +460,13 @@ | ||
| 477 | 460 | * @return void |
| 478 | 461 | */ |
| 479 | 462 | private static function save_form_style() { |
| 480 | 463 | $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form_style', 'frm_save_form_style_nonce' ); |
| 481 | - | |
| 482 | 464 | if ( $permission_error !== false ) { |
| 483 | 465 | wp_die( 'Unable to save form', '', 403 ); |
| 484 | 466 | } |
| 485 | 467 | |
| 486 | 468 | $style_id = FrmAppHelper::get_post_param( 'style_id', 0, 'absint' ); |
| 487 | - | |
| 488 | 469 | if ( $style_id && ! self::confirm_style_exists_before_setting( $style_id ) ) { |
| 489 | 470 | wp_die( esc_html__( 'Invalid target style', 'formidable' ), esc_html__( 'Invalid target style', 'formidable' ), 400 ); |
| 490 | 471 | return; |
| 491 | 472 | } |
| @@ -505,9 +486,8 @@ | ||
| 505 | 486 | return; |
| 506 | 487 | } |
| 507 | 488 | |
| 508 | 489 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 509 | - | |
| 510 | 490 | if ( ! $form_id ) { |
| 511 | 491 | wp_die( esc_html__( 'No form specified', 'formidable' ), esc_html__( 'No form specified', 'formidable' ), 400 ); |
| 512 | 492 | return; |
| 513 | 493 | } |
| @@ -512,21 +492,18 @@ | ||
| 512 | 492 | return; |
| 513 | 493 | } |
| 514 | 494 | |
| 515 | 495 | $form = FrmForm::getOne( $form_id ); |
| 516 | - | |
| 517 | 496 | if ( ! $form ) { |
| 518 | 497 | wp_die( esc_html__( 'Form does not exist', 'formidable' ), esc_html__( 'Form does not exist', 'formidable' ), 400 ); |
| 519 | 498 | return; |
| 520 | 499 | } |
| 521 | 500 | |
| 522 | - $previous_style_id = $form->options['custom_style']; | |
| 523 | - | |
| 524 | 501 | // If the default style is selected, use the "Always use default" legacy option instead of the default style. |
| 525 | 502 | // There's also a check here for conversational forms. |
| 526 | 503 | // Without the check it isn't possible to select "Default" because "Always use default" will convert to "Lines" dynamically. |
| 527 | - | |
| 528 | - if ( $style_id === self::get_default_style()->ID && empty( $form->options['chat'] ) ) { | |
| 504 | + $default_style = self::get_default_style(); | |
| 505 | + if ( $style_id === $default_style->ID && empty( $form->options['chat'] ) ) { | |
| 529 | 506 | $style_id = 1; |
| 530 | 507 | } |
| 531 | 508 | |
| 532 | 509 | // We want to save a string for consistency. FrmStylesHelper::get_form_count_for_style expects the custom style ID is a string. |
| @@ -531,27 +508,13 @@ | ||
| 531 | 508 | |
| 532 | 509 | // We want to save a string for consistency. FrmStylesHelper::get_form_count_for_style expects the custom style ID is a string. |
| 533 | 510 | $form->options['custom_style'] = (string) $style_id; |
| 534 | 511 | |
| 535 | - if ( $previous_style_id === $form->options['custom_style'] ) { | |
| 536 | - // Exit early before updating DB if nothing actually changed. | |
| 537 | - self::$message = __( 'Successfully updated style.', 'formidable' ); | |
| 538 | - return; | |
| 539 | - } | |
| 540 | - | |
| 541 | 512 | global $wpdb; |
| 542 | 513 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 543 | 514 | |
| 544 | 515 | FrmForm::clear_form_cache(); |
| 545 | 516 | |
| 546 | - /** | |
| 547 | - * @since 6.25.1 | |
| 548 | - * | |
| 549 | - * @param int $form_id | |
| 550 | - * @param int $style_id | |
| 551 | - */ | |
| 552 | - do_action( 'frm_after_changed_form_style', absint( $form_id ), absint( $style_id ) ); | |
| 553 | - | |
| 554 | 517 | self::$message = __( 'Successfully updated style.', 'formidable' ); |
| 555 | 518 | } |
| 556 | 519 | |
| 557 | 520 | /** |
| @@ -557,9 +520,8 @@ | ||
| 557 | 520 | /** |
| 558 | 521 | * Validate that we're assigning a form to a style that actually exists before assigning it to a form. |
| 559 | 522 | * |
| 560 | 523 | * @param int $style_id |
| 561 | - * | |
| 562 | 524 | * @return bool True if the style actually exists. |
| 563 | 525 | */ |
| 564 | 526 | private static function confirm_style_exists_before_setting( $style_id ) { |
| 565 | 527 | global $wpdb; |
| @@ -578,9 +540,9 @@ | ||
| 578 | 540 | $plugin_url = FrmAppHelper::plugin_url(); |
| 579 | 541 | $version = FrmAppHelper::plugin_version(); |
| 580 | 542 | $js_dependencies = array( 'wp-i18n', 'wp-hooks', 'formidable_dom' ); |
| 581 | 543 | |
| 582 | - if ( FrmAppHelper::pro_is_installed() && is_callable( 'FrmProAppHelper::use_jquery_datepicker' ) && FrmProAppHelper::use_jquery_datepicker() ) { | |
| 544 | + if ( FrmAppHelper::pro_is_installed() ) { | |
| 583 | 545 | $js_dependencies[] = 'jquery-ui-datepicker'; |
| 584 | 546 | } |
| 585 | 547 | |
| 586 | 548 | wp_register_script( 'formidable_style', $plugin_url . '/js/admin/style.js', $js_dependencies, $version ); |
| @@ -599,9 +561,8 @@ | ||
| 599 | 561 | * |
| 600 | 562 | * @param stdClass|WP_Post $active_style |
| 601 | 563 | * @param stdClass $form |
| 602 | 564 | * @param WP_Post $default_style |
| 603 | - * | |
| 604 | 565 | * @return void |
| 605 | 566 | */ |
| 606 | 567 | private static function render_style_page( $active_style, $form, $default_style ) { |
| 607 | 568 | $style_views_path = self::get_views_path(); |
| @@ -676,9 +637,8 @@ | ||
| 676 | 637 | * |
| 677 | 638 | * @since 6.0 |
| 678 | 639 | * |
| 679 | 640 | * @param stdClass|WP_Post $style A new style is not a WP_Post object. |
| 680 | - * | |
| 681 | 641 | * @return void |
| 682 | 642 | */ |
| 683 | 643 | private static function force_form_style( $style ) { |
| 684 | 644 | add_filter( |
| @@ -689,9 +649,9 @@ | ||
| 689 | 649 | /** |
| 690 | 650 | * @param string $class |
| 691 | 651 | */ |
| 692 | 652 | function ( $class ) { |
| 693 | - return $class && ! str_starts_with( $class, 'frm_style_' ); | |
| 653 | + return $class && 0 !== strpos( $class, 'frm_style_' ); | |
| 694 | 654 | } |
| 695 | 655 | ); |
| 696 | 656 | $split[] = 'frm_style_' . $style->post_name; |
| 697 | 657 | return implode( ' ', $split ); |
| @@ -706,10 +666,8 @@ | ||
| 706 | 666 | * |
| 707 | 667 | * @return void |
| 708 | 668 | */ |
| 709 | 669 | public static function save_style() { |
| 710 | - FrmAppHelper::permission_check( 'frm_change_settings' ); | |
| 711 | - | |
| 712 | 670 | $frm_style = new FrmStyle(); |
| 713 | 671 | $post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_title' ); |
| 714 | 672 | $style_nonce = FrmAppHelper::get_post_param( 'frm_style', '', 'sanitize_text_field' ); |
| 715 | 673 | |
| @@ -719,9 +677,8 @@ | ||
| 719 | 677 | return; |
| 720 | 678 | } |
| 721 | 679 | |
| 722 | 680 | $id = $frm_style->update( $post_id ); |
| 723 | - | |
| 724 | 681 | if ( ! $post_id && $id ) { |
| 725 | 682 | self::maybe_redirect_after_save( $id ); |
| 726 | 683 | // Set the post id to the new style so it will be loaded for editing. |
| 727 | 684 | $post_id = reset( $id ); |
| @@ -726,15 +683,8 @@ | ||
| 726 | 683 | // Set the post id to the new style so it will be loaded for editing. |
| 727 | 684 | $post_id = reset( $id ); |
| 728 | 685 | } |
| 729 | 686 | |
| 730 | - /** | |
| 731 | - * @since 6.25.1 | |
| 732 | - * | |
| 733 | - * @param int $post_id | |
| 734 | - */ | |
| 735 | - do_action( 'frm_after_saved_style', absint( $post_id ) ); | |
| 736 | - | |
| 737 | 687 | self::$message = __( 'Your styling settings have been saved.', 'formidable' ); |
| 738 | 688 | } |
| 739 | 689 | |
| 740 | 690 | /** |
| @@ -753,20 +703,19 @@ | ||
| 753 | 703 | * |
| 754 | 704 | * @since 6.0 |
| 755 | 705 | * |
| 756 | 706 | * @param array $ids |
| 757 | - * | |
| 758 | 707 | * @return void |
| 759 | 708 | */ |
| 760 | 709 | private static function maybe_redirect_after_save( $ids ) { |
| 761 | - $referer = FrmAppHelper::get_server_value( 'HTTP_REFERER' ); | |
| 762 | - $parsed = parse_url( $referer ); | |
| 763 | - $query = $parsed['query']; | |
| 710 | + $referer = FrmAppHelper::get_server_value( 'HTTP_REFERER' ); | |
| 711 | + $parsed = parse_url( $referer ); | |
| 712 | + $query = $parsed['query']; | |
| 713 | + | |
| 764 | 714 | $current_action = false; |
| 765 | 715 | $actions_to_redirect = array( 'duplicate', 'new_style' ); |
| 766 | - | |
| 767 | 716 | foreach ( $actions_to_redirect as $action ) { |
| 768 | - if ( str_contains( $query, 'frm_action=' . $action ) ) { | |
| 717 | + if ( false !== strpos( $query, 'frm_action=' . $action ) ) { | |
| 769 | 718 | $current_action = $action; |
| 770 | 719 | break; |
| 771 | 720 | } |
| 772 | 721 | } |
| @@ -776,9 +725,10 @@ | ||
| 776 | 725 | return; |
| 777 | 726 | } |
| 778 | 727 | |
| 779 | 728 | parse_str( $query, $parsed_query ); |
| 780 | - $form_id = ! empty( $parsed_query['form'] ) ? absint( $parsed_query['form'] ) : 0; | |
| 729 | + $form_id = ! empty( $parsed_query['form'] ) ? absint( $parsed_query['form'] ) : 0; | |
| 730 | + | |
| 781 | 731 | $style = new stdClass(); |
| 782 | 732 | $style->ID = end( $ids ); |
| 783 | 733 | wp_safe_redirect( esc_url_raw( FrmStylesHelper::get_edit_url( $style, $form_id ) ) ); |
| 784 | 734 | die(); |
| @@ -788,9 +738,8 @@ | ||
| 788 | 738 | * @since 6.0 |
| 789 | 739 | * |
| 790 | 740 | * @param string $message |
| 791 | 741 | * @param array|object $forms |
| 792 | - * | |
| 793 | 742 | * @return void |
| 794 | 743 | */ |
| 795 | 744 | public static function manage( $message = '', $forms = array() ) { |
| 796 | 745 | $frm_style = new FrmStyle(); |
| @@ -795,9 +744,8 @@ | ||
| 795 | 744 | public static function manage( $message = '', $forms = array() ) { |
| 796 | 745 | $frm_style = new FrmStyle(); |
| 797 | 746 | $styles = $frm_style->get_all(); |
| 798 | 747 | $default_style = $frm_style->get_default_style( $styles ); |
| 799 | - $frm_settings = FrmAppHelper::get_settings(); | |
| 800 | 748 | |
| 801 | 749 | if ( ! $forms ) { |
| 802 | 750 | $forms = FrmForm::get_published_forms(); |
| 803 | 751 | } |
| @@ -814,16 +762,15 @@ | ||
| 814 | 762 | private static function manage_styles() { |
| 815 | 763 | global $wpdb; |
| 816 | 764 | |
| 817 | 765 | $forms = FrmForm::get_published_forms(); |
| 818 | - | |
| 819 | 766 | foreach ( $forms as $form ) { |
| 820 | - 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 ) { | |
| 821 | 770 | continue; |
| 822 | 771 | } |
| 823 | 772 | |
| 824 | - $new_style = sanitize_text_field( wp_unslash( $_POST['style'][ $form->id ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 825 | - | |
| 826 | 773 | $form->options['custom_style'] = $new_style; |
| 827 | 774 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 828 | 775 | unset( $form ); |
| 829 | 776 | } |
| @@ -832,28 +779,15 @@ | ||
| 832 | 779 | /** |
| 833 | 780 | * Echo content for the Custom CSS page. |
| 834 | 781 | * |
| 835 | 782 | * @param string $message |
| 836 | - * @param array $extra_args An array of extra arguments. | |
| 837 | - * | |
| 838 | 783 | * @return void |
| 839 | 784 | */ |
| 840 | - public static function custom_css( $message = '', $extra_args = array() ) { | |
| 841 | - $id = $extra_args['id'] ?? 'frm_codemirror_box'; | |
| 842 | - $settings = self::enqueue_codemirror( $id, $extra_args['placeholder'] ?? '' ); | |
| 843 | - $id = $settings ? $id : 'frm_custom_css_box'; | |
| 844 | - $show_errors = $extra_args['show_errors'] ?? true; | |
| 845 | - $custom_css = $extra_args['custom_css'] ?? self::get_custom_css(); | |
| 846 | - $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 | |
| 847 | - $textarea_params = ! empty( $extra_args['textarea_params'] ) ? $extra_args['textarea_params'] : array( | |
| 848 | - 'name' => 'frm_custom_css', | |
| 849 | - 'id' => $id, | |
| 850 | - ); | |
| 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(); | |
| 851 | 789 | |
| 852 | - if ( $settings ) { | |
| 853 | - $textarea_params['class'] = 'hide-if-js'; | |
| 854 | - } | |
| 855 | - | |
| 856 | 790 | include FrmAppHelper::plugin_path() . '/classes/views/styles/custom_css.php'; |
| 857 | 791 | } |
| 858 | 792 | |
| 859 | 793 | /** |
| @@ -860,33 +794,22 @@ | ||
| 860 | 794 | * Get custom CSS code entered in the Custom CSS page. |
| 861 | 795 | * |
| 862 | 796 | * @since 6.0 |
| 863 | 797 | * |
| 864 | - * @param array|null $single_style_settings The single style settings. | |
| 865 | - * | |
| 866 | 798 | * @return string |
| 867 | 799 | */ |
| 868 | - public static function get_custom_css( $single_style_settings = null ) { | |
| 869 | - if ( $single_style_settings ) { | |
| 870 | - // If the single style settings are passed, return the custom CSS from the single style settings. | |
| 871 | - if ( ! empty( $single_style_settings['single_style_custom_css'] ) && ! empty( $single_style_settings['enable_style_custom_css'] ) ) { | |
| 872 | - return $single_style_settings['single_style_custom_css']; | |
| 873 | - } | |
| 874 | - | |
| 875 | - return ''; | |
| 876 | - } | |
| 877 | - | |
| 800 | + public static function get_custom_css() { | |
| 878 | 801 | $settings = FrmAppHelper::get_settings(); |
| 879 | - | |
| 880 | 802 | if ( is_string( $settings->custom_css ) ) { |
| 881 | 803 | return $settings->custom_css; |
| 882 | 804 | } |
| 883 | 805 | |
| 884 | 806 | // If it does not exist, check the default style as a fallback. |
| 885 | - $frm_style = new FrmStyle(); | |
| 886 | - $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']; | |
| 887 | 810 | |
| 888 | - return $style->post_content['custom_css']; | |
| 811 | + return $custom_css; | |
| 889 | 812 | } |
| 890 | 813 | |
| 891 | 814 | /** |
| 892 | 815 | * Enqueue assets for codemirror, built into WordPress since 4.9. |
| @@ -893,14 +816,11 @@ | ||
| 893 | 816 | * The Custom CSS page uses codemirror. |
| 894 | 817 | * |
| 895 | 818 | * @since 6.0 Previously this code was embedded in self::custom_css. |
| 896 | 819 | * |
| 897 | - * @param string $id The ID of the codemirror box. | |
| 898 | - * @param string $placeholder The placeholder text for the codemirror box. | |
| 899 | - * | |
| 900 | 820 | * @return array|false |
| 901 | 821 | */ |
| 902 | - private static function enqueue_codemirror( $id = 'frm_codemirror_box', $placeholder = '' ) { | |
| 822 | + private static function enqueue_codemirror() { | |
| 903 | 823 | if ( ! function_exists( 'wp_enqueue_code_editor' ) ) { |
| 904 | 824 | // The WordPress version is likely older than 4.9. |
| 905 | 825 | return false; |
| 906 | 826 | } |
| @@ -913,9 +833,8 @@ | ||
| 913 | 833 | 'tabSize' => 2, |
| 914 | 834 | // As the codemirror box only appears once you click into the Custom CSS tab, we need to auto-refresh. |
| 915 | 835 | // Otherwise the line numbers all end up with a 1px width causing overlap issues with the text in the content. |
| 916 | 836 | 'autoRefresh' => true, |
| 917 | - 'placeholder' => $placeholder, | |
| 918 | 837 | ), |
| 919 | 838 | ) |
| 920 | 839 | ); |
| 921 | 840 | |
| @@ -922,11 +841,9 @@ | ||
| 922 | 841 | if ( $settings ) { |
| 923 | 842 | wp_add_inline_script( |
| 924 | 843 | 'code-editor', |
| 925 | 844 | sprintf( |
| 926 | - 'jQuery( function() { window.%s_wp_editor = wp.codeEditor.initialize( \'%s\', %s ); } );', | |
| 927 | - $id, | |
| 928 | - $id, | |
| 845 | + 'jQuery( function() { wp.codeEditor.initialize( \'frm_codemirror_box\', %s ); } );', | |
| 929 | 846 | wp_json_encode( $settings ) |
| 930 | 847 | ) |
| 931 | 848 | ); |
| 932 | 849 | } |
| @@ -978,14 +895,14 @@ | ||
| 978 | 895 | FrmAppHelper::permission_check( 'frm_change_settings' ); |
| 979 | 896 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 980 | 897 | |
| 981 | 898 | $style_id = FrmAppHelper::get_post_param( 'style_id', '', 'absint' ); |
| 982 | - | |
| 983 | 899 | if ( ! $style_id ) { |
| 984 | 900 | // A style ID is not sent when resetting on the edit page. |
| 985 | 901 | // Instead of resetting the style, send the defaults back so the inputs can be updated with JavaScript. |
| 986 | 902 | $frm_style = new FrmStyle(); |
| 987 | - echo json_encode( $frm_style->get_defaults() ); | |
| 903 | + $defaults = $frm_style->get_defaults(); | |
| 904 | + echo json_encode( $defaults ); | |
| 988 | 905 | wp_die(); |
| 989 | 906 | } |
| 990 | 907 | |
| 991 | 908 | $frm_style = new FrmStyle(); |
| @@ -1038,9 +955,9 @@ | ||
| 1038 | 955 | /** |
| 1039 | 956 | * @return void |
| 1040 | 957 | */ |
| 1041 | 958 | public static function add_meta_boxes() { |
| 1042 | - // Setup meta boxes | |
| 959 | + // setup meta boxes | |
| 1043 | 960 | $meta_boxes = array( |
| 1044 | 961 | 'general' => __( 'General', 'formidable' ), |
| 1045 | 962 | 'form-title' => __( 'Form Title', 'formidable' ), |
| 1046 | 963 | 'form-description' => __( 'Form Description', 'formidable' ), |
| @@ -1070,9 +987,8 @@ | ||
| 1070 | 987 | |
| 1071 | 988 | /** |
| 1072 | 989 | * @param array $atts |
| 1073 | 990 | * @param array $sec |
| 1074 | - * | |
| 1075 | 991 | * @return void |
| 1076 | 992 | */ |
| 1077 | 993 | public static function include_style_section( $atts, $sec ) { |
| 1078 | 994 | extract( $atts ); // phpcs:ignore WordPress.PHP.DontExtract |
| @@ -1143,10 +1059,9 @@ | ||
| 1143 | 1059 | * @return void |
| 1144 | 1060 | */ |
| 1145 | 1061 | public static function maybe_hide_sample_form_error_message() { |
| 1146 | 1062 | $referer = FrmAppHelper::get_server_value( 'HTTP_REFERER' ); |
| 1147 | - | |
| 1148 | - if ( str_contains( $referer, 'admin.php?page=formidable-styles' ) ) { | |
| 1063 | + if ( false !== strpos( $referer, 'admin.php?page=formidable-styles' ) ) { | |
| 1149 | 1064 | echo '#frm_broken_styles_warning { display: none; }'; |
| 1150 | 1065 | } |
| 1151 | 1066 | } |
| 1152 | 1067 | |
| @@ -1155,9 +1070,8 @@ | ||
| 1155 | 1070 | * |
| 1156 | 1071 | * @since 4.11.03 |
| 1157 | 1072 | * |
| 1158 | 1073 | * @param string $css CSS content. |
| 1159 | - * | |
| 1160 | 1074 | * @return string |
| 1161 | 1075 | */ |
| 1162 | 1076 | public static function replace_relative_url( $css ) { |
| 1163 | 1077 | $plugin_url = trailingslashit( FrmAppHelper::plugin_url() ); |
| @@ -1180,27 +1094,22 @@ | ||
| 1180 | 1094 | * Check if the Formidable styling should be loaded, |
| 1181 | 1095 | * then enqueue it for the footer |
| 1182 | 1096 | * |
| 1183 | 1097 | * @since 2.0 |
| 1184 | - * | |
| 1185 | - * @return void | |
| 1186 | 1098 | */ |
| 1187 | 1099 | public static function enqueue_style() { |
| 1188 | 1100 | global $frm_vars; |
| 1189 | 1101 | |
| 1190 | - if ( ! empty( $frm_vars['css_loaded'] ) ) { | |
| 1102 | + if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) { | |
| 1191 | 1103 | // The CSS has already been loaded. |
| 1192 | 1104 | return; |
| 1193 | 1105 | } |
| 1194 | 1106 | |
| 1195 | 1107 | $frm_settings = FrmAppHelper::get_settings(); |
| 1196 | - | |
| 1197 | - if ( $frm_settings->load_style === 'none' ) { | |
| 1198 | - return; | |
| 1108 | + if ( $frm_settings->load_style !== 'none' ) { | |
| 1109 | + wp_enqueue_style( 'formidable' ); | |
| 1110 | + $frm_vars['css_loaded'] = true; | |
| 1199 | 1111 | } |
| 1200 | - | |
| 1201 | - wp_enqueue_style( 'formidable' ); | |
| 1202 | - $frm_vars['css_loaded'] = true; | |
| 1203 | 1112 | } |
| 1204 | 1113 | |
| 1205 | 1114 | /** |
| 1206 | 1115 | * Get the stylesheets for the form settings page |
| @@ -1208,9 +1117,11 @@ | ||
| 1208 | 1117 | * @return array<WP_Post> |
| 1209 | 1118 | */ |
| 1210 | 1119 | public static function get_style_opts() { |
| 1211 | 1120 | $frm_style = new FrmStyle(); |
| 1212 | - return $frm_style->get_all(); | |
| 1121 | + $styles = $frm_style->get_all(); | |
| 1122 | + | |
| 1123 | + return $styles; | |
| 1213 | 1124 | } |
| 1214 | 1125 | |
| 1215 | 1126 | /** |
| 1216 | 1127 | * Get the style post object for a target form. |
| @@ -1215,16 +1126,14 @@ | ||
| 1215 | 1126 | /** |
| 1216 | 1127 | * Get the style post object for a target form. |
| 1217 | 1128 | * |
| 1218 | 1129 | * @param bool|object|string $form |
| 1219 | - * | |
| 1220 | 1130 | * @return WP_Post|null |
| 1221 | 1131 | */ |
| 1222 | 1132 | public static function get_form_style( $form = 'default' ) { |
| 1223 | 1133 | $style = FrmFormsHelper::get_form_style( $form ); |
| 1224 | 1134 | |
| 1225 | - // phpcs:ignore Universal.Operators.StrictComparisons | |
| 1226 | - if ( ! $style || 1 == $style ) { | |
| 1135 | + if ( empty( $style ) || 1 == $style ) { | |
| 1227 | 1136 | $style = 'default'; |
| 1228 | 1137 | } |
| 1229 | 1138 | |
| 1230 | 1139 | $frm_style = new FrmStyle( $style ); |
| @@ -1233,13 +1142,10 @@ | ||
| 1233 | 1142 | |
| 1234 | 1143 | /** |
| 1235 | 1144 | * @param string $class |
| 1236 | 1145 | * @param string $style |
| 1237 | - * | |
| 1238 | - * @return string | |
| 1239 | 1146 | */ |
| 1240 | 1147 | public static function get_form_style_class( $class, $style ) { |
| 1241 | - // phpcs:ignore Universal.Operators.StrictComparisons | |
| 1242 | 1148 | if ( 1 == $style ) { |
| 1243 | 1149 | $style = 'default'; |
| 1244 | 1150 | } |
| 1245 | 1151 | |
| @@ -1255,17 +1161,13 @@ | ||
| 1255 | 1161 | } |
| 1256 | 1162 | |
| 1257 | 1163 | /** |
| 1258 | 1164 | * @since 3.0 |
| 1259 | - * | |
| 1260 | 1165 | * @param object $style |
| 1261 | 1166 | * @param string $class |
| 1262 | - * | |
| 1263 | - * @return void | |
| 1264 | 1167 | */ |
| 1265 | 1168 | private static function maybe_add_rtl_class( $style, &$class ) { |
| 1266 | 1169 | $is_rtl = isset( $style->post_content['direction'] ) && 'rtl' === $style->post_content['direction']; |
| 1267 | - | |
| 1268 | 1170 | if ( $is_rtl ) { |
| 1269 | 1171 | $class .= ' frm_rtl'; |
| 1270 | 1172 | } |
| 1271 | 1173 | } |
| @@ -1270,28 +1172,17 @@ | ||
| 1270 | 1172 | } |
| 1271 | 1173 | } |
| 1272 | 1174 | |
| 1273 | 1175 | /** |
| 1274 | - * @param string $val Style setting key. | |
| 1275 | - * @param int|string $form Form ID or 'default'. | |
| 1276 | - * | |
| 1277 | - * @return mixed | |
| 1176 | + * @param string $val | |
| 1278 | 1177 | */ |
| 1279 | 1178 | public static function get_style_val( $val, $form = 'default' ) { |
| 1280 | 1179 | $style = self::get_form_style( $form ); |
| 1281 | - | |
| 1282 | 1180 | if ( $style && isset( $style->post_content[ $val ] ) ) { |
| 1283 | 1181 | return $style->post_content[ $val ]; |
| 1284 | 1182 | } |
| 1285 | - | |
| 1286 | - return null; | |
| 1287 | 1183 | } |
| 1288 | 1184 | |
| 1289 | - /** | |
| 1290 | - * @param array $default_styles | |
| 1291 | - * | |
| 1292 | - * @return array | |
| 1293 | - */ | |
| 1294 | 1185 | public static function show_entry_styles( $default_styles ) { |
| 1295 | 1186 | $frm_style = new FrmStyle( 'default' ); |
| 1296 | 1187 | $style = $frm_style->get_one(); |
| 1297 | 1188 | |
| @@ -1300,15 +1191,13 @@ | ||
| 1300 | 1191 | } |
| 1301 | 1192 | |
| 1302 | 1193 | foreach ( $default_styles as $name => $val ) { |
| 1303 | 1194 | $setting = $name; |
| 1304 | - | |
| 1305 | - if ( 'border_width' === $name ) { | |
| 1195 | + if ( 'border_width' == $name ) { | |
| 1306 | 1196 | $setting = 'field_border_width'; |
| 1307 | - } elseif ( 'alt_bg_color' === $name ) { | |
| 1197 | + } elseif ( 'alt_bg_color' == $name ) { | |
| 1308 | 1198 | $setting = 'bg_color_active'; |
| 1309 | 1199 | } |
| 1310 | - | |
| 1311 | 1200 | $default_styles[ $name ] = $style->post_content[ $setting ]; |
| 1312 | 1201 | unset( $name, $val ); |
| 1313 | 1202 | } |
| 1314 | 1203 | |
| @@ -1314,16 +1203,12 @@ | ||
| 1314 | 1203 | |
| 1315 | 1204 | return $default_styles; |
| 1316 | 1205 | } |
| 1317 | 1206 | |
| 1318 | - /** | |
| 1319 | - * @param string $important | |
| 1320 | - * @param array $field | |
| 1321 | - * | |
| 1322 | - * @return string | |
| 1323 | - */ | |
| 1324 | - public static function important_style( $important, $field ) { | |
| 1325 | - return self::get_style_val( 'important_style', $field['form_id'] ); | |
| 1207 | + public static function &important_style( $important, $field ) { | |
| 1208 | + $important = self::get_style_val( 'important_style', $field['form_id'] ); | |
| 1209 | + | |
| 1210 | + return $important; | |
| 1326 | 1211 | } |
| 1327 | 1212 | |
| 1328 | 1213 | /** |
| 1329 | 1214 | * Duplicate of WordPress do_accordion_section function, it adds an additional svg icon support. |
| @@ -1329,18 +1214,14 @@ | ||
| 1329 | 1214 | * Duplicate of WordPress do_accordion_section function, it adds an additional svg icon support. |
| 1330 | 1215 | * |
| 1331 | 1216 | * @since 6.8.3 |
| 1332 | 1217 | * |
| 1333 | - * @param string|WP_Screen $screen Screen ID or screen object. | |
| 1334 | - * @param string $context Meta box context. | |
| 1335 | - * @param mixed $data_object Data object passed to callbacks. | |
| 1336 | - * | |
| 1337 | 1218 | * @return int |
| 1338 | 1219 | */ |
| 1339 | - 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 ) { | |
| 1340 | 1221 | global $wp_meta_boxes; |
| 1341 | 1222 | |
| 1342 | - // The symbol id from icons.svg | |
| 1223 | + // the symbol id from icons.svg | |
| 1343 | 1224 | $icon_ids = array( |
| 1344 | 1225 | 'ranking-fields-style' => 'frm_chart_bar_icon', |
| 1345 | 1226 | 'section-fields-style' => 'frm-form-title-style', |
| 1346 | 1227 | ); |
| @@ -1346,9 +1227,9 @@ | ||
| 1346 | 1227 | ); |
| 1347 | 1228 | |
| 1348 | 1229 | wp_enqueue_script( 'accordion' ); |
| 1349 | 1230 | |
| 1350 | - if ( ! $screen ) { | |
| 1231 | + if ( empty( $screen ) ) { | |
| 1351 | 1232 | $screen = get_current_screen(); |
| 1352 | 1233 | } elseif ( is_string( $screen ) ) { |
| 1353 | 1234 | $screen = convert_to_screen( $screen ); |
| 1354 | 1235 | } |
| @@ -1354,9 +1235,8 @@ | ||
| 1354 | 1235 | } |
| 1355 | 1236 | |
| 1356 | 1237 | $page = $screen->id; |
| 1357 | 1238 | |
| 1358 | - // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 1359 | 1239 | ?> |
| 1360 | 1240 | <div id="side-sortables" class="accordion-container"> |
| 1361 | 1241 | <ul class="outer-border"> |
| 1362 | 1242 | <?php |
| @@ -1364,46 +1244,40 @@ | ||
| 1364 | 1244 | $first_open = false; |
| 1365 | 1245 | |
| 1366 | 1246 | if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) { |
| 1367 | 1247 | foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
| 1368 | - if ( ! isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { | |
| 1369 | - continue; | |
| 1370 | - } | |
| 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 | + } | |
| 1371 | 1253 | |
| 1372 | - foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { | |
| 1373 | - if ( false === $box || ! $box['title'] ) { | |
| 1374 | - continue; | |
| 1375 | - } | |
| 1254 | + ++$i; | |
| 1255 | + $icon_id = array_key_exists( $box['id'], $icon_ids ) ? $icon_ids[ $box['id'] ] : 'frm-' . $box['id']; | |
| 1376 | 1256 | |
| 1377 | - ++$i; | |
| 1378 | - $icon_id = array_key_exists( $box['id'], $icon_ids ) ? $icon_ids[ $box['id'] ] : 'frm-' . $box['id']; | |
| 1379 | - $open_class = ''; | |
| 1380 | - | |
| 1381 | - if ( ! $first_open ) { | |
| 1382 | - $first_open = true; | |
| 1383 | - $open_class = 'open'; | |
| 1384 | - } | |
| 1385 | - | |
| 1386 | - $accordion_content_id = 'frm_style_section_' . $box['id']; | |
| 1387 | - ?> | |
| 1388 | - <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 ?> | |
| 1389 | - <h3 class="accordion-section-title hndle"> | |
| 1390 | - <?php | |
| 1391 | - FrmAppHelper::icon_by_class( 'frmfont ' . $icon_id . ' frm_svg24' ); | |
| 1392 | - echo esc_html( $box['title'] ); | |
| 1393 | - ?> | |
| 1394 | - <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 ?> | |
| 1395 | - <?php FrmAppHelper::icon_by_class( 'frmfont frm_arrowdown8_icon' ); ?> | |
| 1396 | - </button> | |
| 1397 | - </h3> | |
| 1398 | - <div class="accordion-section-content <?php postbox_classes( $box['id'], $page ); ?>" id="<?php echo esc_attr( $accordion_content_id ); ?>"> | |
| 1399 | - <div class="inside"> | |
| 1400 | - <?php call_user_func( $box['callback'], $data_object, $box ); ?> | |
| 1401 | - </div><!-- .inside --> | |
| 1402 | - </div><!-- .accordion-section-content --> | |
| 1403 | - </li><!-- .accordion-section --> | |
| 1404 | - <?php | |
| 1405 | - }//end foreach | |
| 1257 | + $open_class = ''; | |
| 1258 | + if ( ! $first_open ) { | |
| 1259 | + $first_open = true; | |
| 1260 | + $open_class = 'open'; | |
| 1261 | + } | |
| 1262 | + ?> | |
| 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'] ); ?>"> | |
| 1264 | + <h3 class="accordion-section-title hndle" tabindex="0"> | |
| 1265 | + <?php | |
| 1266 | + FrmAppHelper::icon_by_class( 'frmfont ' . $icon_id ); | |
| 1267 | + echo esc_html( $box['title'] ); | |
| 1268 | + FrmAppHelper::icon_by_class( 'frmfont frm_arrowdown8_icon' ); | |
| 1269 | + ?> | |
| 1270 | + </h3> | |
| 1271 | + <div class="accordion-section-content <?php postbox_classes( $box['id'], $page ); ?>"> | |
| 1272 | + <div class="inside"> | |
| 1273 | + <?php call_user_func( $box['callback'], $data_object, $box ); ?> | |
| 1274 | + </div><!-- .inside --> | |
| 1275 | + </div><!-- .accordion-section-content --> | |
| 1276 | + </li><!-- .accordion-section --> | |
| 1277 | + <?php | |
| 1278 | + }//end foreach | |
| 1279 | + }//end if | |
| 1406 | 1280 | }//end foreach |
| 1407 | 1281 | }//end if |
| 1408 | 1282 | ?> |
| 1409 | 1283 | </ul><!-- .outer-border --> |
| @@ -1408,9 +1282,8 @@ | ||
| 1408 | 1282 | ?> |
| 1409 | 1283 | </ul><!-- .outer-border --> |
| 1410 | 1284 | </div><!-- .accordion-container --> |
| 1411 | 1285 | <?php |
| 1412 | - // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 1413 | 1286 | return $i; |
| 1414 | 1287 | } |
| 1415 | 1288 | |
| 1416 | 1289 | /** |
| @@ -1421,9 +1294,8 @@ | ||
| 1421 | 1294 | * @return void |
| 1422 | 1295 | */ |
| 1423 | 1296 | public static function rename_style() { |
| 1424 | 1297 | $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'nonce', 'frm_ajax' ); |
| 1425 | - | |
| 1426 | 1298 | if ( $permission_error !== false ) { |
| 1427 | 1299 | $data = array( |
| 1428 | 1300 | 'message' => __( 'Unable to rename style', 'formidable' ), |
| 1429 | 1301 | ); |
| @@ -1442,9 +1314,8 @@ | ||
| 1442 | 1314 | die(); |
| 1443 | 1315 | } |
| 1444 | 1316 | |
| 1445 | 1317 | $post = get_post( $style_id ); |
| 1446 | - | |
| 1447 | 1318 | if ( ! $post || $post->post_type !== self::$post_type ) { |
| 1448 | 1319 | $data = array( |
| 1449 | 1320 | 'message' => __( 'The style you are renaming either does not exist or it is not a style', 'formidable' ), |
| 1450 | 1321 | ); |
| @@ -1465,9 +1336,8 @@ | ||
| 1465 | 1336 | * |
| 1466 | 1337 | * @since 6.0 |
| 1467 | 1338 | * |
| 1468 | 1339 | * @param WP_Styles $styles |
| 1469 | - * | |
| 1470 | 1340 | * @return void |
| 1471 | 1341 | */ |
| 1472 | 1342 | public static function disable_conflicting_wp_admin_css( $styles ) { |
| 1473 | 1343 | if ( ! FrmAppHelper::is_style_editor_page() ) { |