| @@ -121,9 +121,35 @@ | ||
| 121 | 121 | |
| 122 | 122 | // 3. Postprocess Form Conent - regarding settings - e.g.: $source_res['bfb_settings'] = [ options = [ booking_form_theme = "wpbc_theme_dark_1", .... ], ... |
| 123 | 123 | $wrapped = apply_filters( 'wpbc_booking_form__wrapped_html__before_inline_scripts', $wrapped, $source_res['bfb_settings'], $resource_id, $custom_booking_form ); |
| 124 | 124 | |
| 125 | - $wrapped .= WPBC_FE_Inline_Scripts::collect( $resource_id ); | |
| 125 | + /** | |
| 126 | + * Filters whether the current booking form render should collect legacy | |
| 127 | + * page-level inline scripts. | |
| 128 | + * | |
| 129 | + * Request-local administration previews initialize their returned markup | |
| 130 | + * through an explicit bootstrap payload. They must not queue callbacks on | |
| 131 | + * the parent administration page because the preview form can be replaced | |
| 132 | + * before those callbacks run. | |
| 133 | + * | |
| 134 | + * @since 11.9.0 | |
| 135 | + * | |
| 136 | + * @param bool $should_collect Whether legacy inline scripts should be collected. | |
| 137 | + * @param int $resource_id Booking resource ID used by the rendered form. | |
| 138 | + * @param string $custom_booking_form Booking form slug requested by the renderer. | |
| 139 | + * @param string $form_status Normalized renderer status such as published or preview. | |
| 140 | + */ | |
| 141 | + $should_collect_inline_scripts = (bool) apply_filters( | |
| 142 | + 'wpbc_booking_form__should_collect_inline_scripts', | |
| 143 | + true, | |
| 144 | + $resource_id, | |
| 145 | + $custom_booking_form, | |
| 146 | + $form_status | |
| 147 | + ); | |
| 148 | + | |
| 149 | + if ( $should_collect_inline_scripts ) { | |
| 150 | + $wrapped .= WPBC_FE_Inline_Scripts::collect( $resource_id ); | |
| 151 | + } | |
| 126 | 152 | |
| 127 | 153 | // Info: Hook for addons. Postprocess Form Conent - regarding settings - e.g.: $source_res['bfb_settings'] = [ options = [ booking_form_theme = "wpbc_theme_dark_1", .... ], ... |
| 128 | 154 | $wrapped = apply_filters( 'wpbc_booking_form__wrapped_html__after_inline_scripts', $wrapped, $source_res['bfb_settings'], $resource_id, $custom_booking_form ); |
| 129 | 155 | |