['wp-blocks', 'wp-i18n', 'wp-block-editor'], 'version' => FQBPRO_PLUGIN_VERSION, ]; if (file_exists($assets_file_path) && is_readable($assets_file_path)) { $loaded_dependencies = require $assets_file_path; if (is_array($loaded_dependencies)) { $script_dependencies = array_merge($script_dependencies, $loaded_dependencies); } } $handle = 'fqbpro-block-hooks'; wp_enqueue_script( $handle, $folder_url . '/index.js', $script_dependencies['dependencies'] ?? [], $script_dependencies['version'] ?? FQBPRO_PLUGIN_VERSION, ['in_footer' => true] ); // Modals are portaled into the parent editor document. Block editorStyle // assets target the canvas iframe, so load the extension's extracted styles // here alongside its JavaScript instead. All selectors are plugin-scoped. $style_path = $folder_path . '/style-index.css'; if (is_readable($style_path)) { wp_enqueue_style( $handle . '-editor', $folder_url . '/style-index.css', ['wp-components'], (string) filemtime($style_path) ); wp_style_add_data($handle . '-editor', 'rtl', 'replace'); } // Add translation support for JavaScript wp_set_script_translations($handle, FQBPRO_TEXT_DOMAIN, untrailingslashit(FQBPRO_PLUGIN_DIR) . '/languages'); // Localize script with block hooks data wp_localize_script($handle, 'fqbproBlockHooks', [ 'pluginUrl' => untrailingslashit(FQBPRO_PLUGIN_URL), 'version' => FQBPRO_PLUGIN_VERSION, 'textDomain' => FQBPRO_TEXT_DOMAIN, 'catalogLanguage' => \Fqbpro\Plugin\Compatibility\Languages\editor_language(), 'catalogExclusions' => \Fqbpro\Plugin\Catalog\Exclusions\get_exclusions_settings(), 'reservedUrlParameters' => \Fqbpro\Plugin\Query\Request\reserved_url_parameters(), ...fqbp_edition_info(), ]); }