PUM_Admin_BlockEditor::register_editor_assets()
Registers all block assets so that they can be enqueued through Gutenberg in the corresponding context.
Description Description
Passes translations to JavaScript.
Source Source
File: classes/Admin/BlockEditor.php
public static function register_editor_assets() { $build_path = 'dist/block-editor/'; $script_path = $build_path . 'block-editor.js'; $script_asset_path = $build_path . 'block-editor.asset.php'; $script_asset = file_exists( Popup_Maker::$DIR . $script_asset_path ) ? require Popup_Maker::$DIR . $script_asset_path : [ 'dependencies' => [], 'version' => Popup_Maker::$VER, ]; $script_url = plugins_url( $script_path, Popup_Maker::$FILE ); wp_enqueue_script( 'popup-maker-block-editor', $script_url, array_merge( $script_asset['dependencies'], [ 'wp-edit-post' ] ), $script_asset['version'] ); wp_localize_script( 'popup-maker-block-editor', 'pum_block_editor_vars', [ 'popups' => pum_get_all_popups(), 'popup_trigger_excluded_blocks' => apply_filters( 'pum_block_editor_popup_trigger_excluded_blocks', [ 'core/nextpage', ] ), ] ); $editor_styles_path = $build_path . 'block-editor-styles.css'; $editor_styles_asset_path = $build_path . 'block-editor-styles.asset.php'; $editor_styles_asset = file_exists( Popup_Maker::$DIR . $editor_styles_asset_path ) ? require Popup_Maker::$DIR . $editor_styles_asset_path : [ 'dependencies' => [], 'version' => Popup_Maker::$VER, ]; wp_enqueue_style( 'popup-maker-block-editor', plugins_url( $editor_styles_path, Popup_Maker::$FILE ), [], $editor_styles_asset['version'] ); if ( function_exists( 'wp_set_script_translations' ) ) { /** * May be extended to wp_set_script_translations( 'my-handle', 'my-domain', * plugin_dir_path( MY_PLUGIN ) . 'languages' ) ). For details see * https://make.wordpress.org/core/2018/11/09/new-javascript-i18n-support-in-wordpress/ */ wp_set_script_translations( 'popup-maker-block-editor', 'popup-maker' ); } }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
1.10.0 | Introduced. |