| @@ -19,8 +19,9 @@ | ||
| 19 | 19 | const TRACKING_CODE = 'leadin-script-loader-js'; |
| 20 | 20 | const GUTENBERG = 'leadin-gutenberg'; |
| 21 | 21 | const MEETINGS_GUTENBERG = 'leadin-meetings-gutenberg'; |
| 22 | 22 | const FORMS_SCRIPT = 'leadin-forms-v2'; |
| 23 | + const FORMS_V4_SCRIPT = 'leadin-forms-v4'; | |
| 23 | 24 | const MEETINGS_SCRIPT = 'leadin-meeting'; |
| 24 | 25 | const LEADIN_CONFIG = 'leadinConfig'; |
| 25 | 26 | const LEADIN_I18N = 'leadinI18n'; |
| 26 | 27 | const REVIEW_BANNER = 'leadin-review-banner'; |
| @@ -115,8 +116,23 @@ | ||
| 115 | 116 | ); |
| 116 | 117 | } |
| 117 | 118 | |
| 118 | 119 | /** |
| 120 | + * Register and enqueue forms v4 script | |
| 121 | + * | |
| 122 | + * @param string $portal_id The portal ID. | |
| 123 | + */ | |
| 124 | + public static function enqueue_form_v4_script( $portal_id ) { | |
| 125 | + wp_enqueue_script( | |
| 126 | + self::FORMS_V4_SCRIPT, | |
| 127 | + Filters::apply_forms_v4_script_url_filters( $portal_id ), | |
| 128 | + array(), | |
| 129 | + LEADIN_PLUGIN_VERSION, | |
| 130 | + true | |
| 131 | + ); | |
| 132 | + } | |
| 133 | + | |
| 134 | + /** | |
| 119 | 135 | * Register and enqueue meetings script |
| 120 | 136 | */ |
| 121 | 137 | public static function enqueue_meetings_script() { |
| 122 | 138 | wp_enqueue_script( |
| @@ -133,11 +149,18 @@ | ||
| 133 | 149 | */ |
| 134 | 150 | public static function localize_gutenberg() { |
| 135 | 151 | $embed_domain = Filters::apply_js_base_url_filters(); |
| 136 | 152 | wp_enqueue_script( self::APP_EMBEDDER, "$embed_domain/integrated-app-embedder/v1.js", array(), LEADIN_PLUGIN_VERSION, true ); |
| 153 | + self::enqueue_forms_script(); | |
| 154 | + // The v4 forms embed script is intentionally not enqueued here: in the | |
| 155 | + // WP 6.3+ iframed editor the block renders `.hs-form-frame` inside the | |
| 156 | + // canvas iframe, so PreviewForm injects the embed script into that | |
| 157 | + // iframe instead. A top-frame copy would pre-empt the iframe copy's | |
| 158 | + // init guard and leave the preview blank. | |
| 159 | + self::enqueue_meetings_script(); | |
| 137 | 160 | wp_register_style( self::GUTENBERG, LEADIN_JS_BASE_PATH . '/gutenberg.css', array(), LEADIN_PLUGIN_VERSION ); |
| 138 | 161 | wp_enqueue_style( self::GUTENBERG ); |
| 139 | - wp_register_script( self::GUTENBERG, LEADIN_JS_BASE_PATH . '/gutenberg.js', array( 'wp-blocks', 'wp-element', 'wp-i18n', self::APP_EMBEDDER ), LEADIN_PLUGIN_VERSION, true ); | |
| 162 | + wp_register_script( self::GUTENBERG, LEADIN_JS_BASE_PATH . '/gutenberg.js', array( 'wp-blocks', 'wp-element', 'wp-i18n', self::APP_EMBEDDER, self::MEETINGS_SCRIPT, self::FORMS_SCRIPT ), LEADIN_PLUGIN_VERSION, true ); | |
| 140 | 163 | wp_localize_script( self::GUTENBERG, self::LEADIN_CONFIG, AdminConstants::get_background_leadin_config() ); |
| 141 | 164 | wp_set_script_translations( self::GUTENBERG, 'leadin', __DIR__ . '/../languages' ); |
| 142 | 165 | } |
| 143 | 166 | |