PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 2.12.8
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v2.12.8
2.12.8 2.12.7 2.12.6 2.12.5 2.12.4 2.12.3 2.12.2 2.12.1 2.12.0 2.11.1 2.11.0 2.10.1 2.10.0 2.9.1 2.9.0 2.8.2 2.8.1 2.7.0 2.7.1 2.8.0 trunk 0.0.10 0.0.11 0.0.12 0.0.13 All 98 releases
← All changes | inc/frontend-assets.php +46 -0 2.12.5 → 2.12.8 View file →
@@ -179,8 +179,14 @@
179 179 'is_rtl' => $is_rtl,
180 180 // Resolved RFC 5321 email limits so the client honors the
181 181 // srfm_email_field_char_limits filter instead of hardcoding 64/255.
182 182 'email_char_limits' => Field_Validation::get_email_char_limits(),
183 + // Hint only. This value is baked into cached HTML and can be a full
184 + // cache TTL out of date, so the server re-checks on every write --
185 + // see Form_Submit::client_error_log_permissions_check(). Its job is
186 + // to keep the browser from posting when logging is plainly off.
187 + 'logging_enabled' => Client_Logger::is_enabled(),
188 + 'log_error_url' => esc_url_raw( rest_url( 'sureforms/v1/log-client-error' ) ),
183 189 ]
184 190 );
185 191
186 192 $current_post = get_post();
@@ -541,8 +547,10 @@
541 547 // Bail if not SureForms post type.
542 548 return $template;
543 549 }
544 550
551 + self::reset_printed_assets();
552 +
545 553 $file_name = 'single-form.php';
546 554 $template = locate_template( $file_name );
547 555
548 556 /**
@@ -550,7 +558,45 @@
550 558 *
551 559 * @since 0.0.1
552 560 */
553 561 return apply_filters( 'srfm_form_template', $template ? $template : SRFM_DIR . '/templates/' . $file_name );
562 + }
563 +
564 + /**
565 + * Let the Instant Form template print assets a discarded render already claimed.
566 + *
567 + * `page_template()` runs on `template_include` at PHP_INT_MAX and returns the
568 + * Instant Form template regardless of what earlier filters returned. A page
569 + * builder that renders the whole page inside its own `template_include`
570 + * filter has therefore already run `wp_head()` and `wp_footer()` into an
571 + * output buffer that is about to be thrown away.
572 + *
573 + * The buffer goes, but `WP_Styles::$done` and `WP_Scripts::$done` still hold
574 + * every handle it claimed, so `do_items()` skips them when `single-form.php`
575 + * calls `wp_head()` and `wp_footer()` for real. The form arrives with no
576 + * stylesheets, and -- because `srfm-form-submit` is registered for the footer
577 + * -- no submit handler either.
578 + *
579 + * Clearing both `done` lists wholesale is the right scope rather than an
580 + * over-broad one: only the render that begins after this filter returns
581 + * reaches the browser, so nothing recorded before it was ever delivered. The
582 + * handles are re-enqueued by the second `wp_enqueue_scripts` pass, so they
583 + * print normally once `done` stops shadowing them.
584 + *
585 + * Guarded on `wp_head` having already fired, so this is inert on the ordinary
586 + * path where no builder rendered first and nothing has been printed yet.
587 + *
588 + * @since 2.12.7
589 + * @return void
590 + */
591 + private static function reset_printed_assets() {
592 + // No earlier wp_head() means no discarded render, so there is nothing to
593 + // forget. Deny is the fallthrough: act only on the state this repairs.
594 + if ( ! did_action( 'wp_head' ) ) {
595 + return;
596 + }
597 +
598 + wp_styles()->done = [];
599 + wp_scripts()->done = [];
554 600 }
555 601
556 602 }