PluginProbe
Gutenberg / 22.7.1
Gutenberg v22.7.1
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / build / modules.php

modules.php in Gutenberg 22.7.1, at build/modules.php

60 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Script module registration - Auto-generated by build process.
4 * Do not edit this file manually.
5 *
6 * @package gutenberg
7 */
8
9 if ( ! function_exists( 'gutenberg_register_script_modules' ) ) {
10 /**
11 * Register all script modules.
12 */
13 function gutenberg_register_script_modules() {
14 // Ensure this only runs once. wp_default_scripts can fire multiple times,
15 // and each wp_deregister_script_module() call also dequeues the module.
16 // If a module was enqueued between calls, repeated deregister/register
17 // cycles would lose the enqueue state.
18 static $already_registered = false;
19 if ( $already_registered ) {
20 return;
21 }
22 $already_registered = true;
23
24 // Load build constants
25 $build_constants = require __DIR__ . '/constants.php';
26 $modules_dir = __DIR__ . '/modules';
27 $modules_file = $modules_dir . '/registry.php';
28
29 if ( ! file_exists( $modules_file ) ) {
30 return;
31 }
32
33 $modules = require $modules_file;
34 $base_url = $build_constants['build_url'] . 'modules/';
35 $extension = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.js' : '.min.js';
36
37 foreach ( $modules as $module ) {
38 $asset_path = $modules_dir . '/' . $module['asset'];
39 $asset = file_exists( $asset_path ) ? require $asset_path : array();
40
41 // Deregister first to override any previously registered version
42 // (e.g., Core's default modules when running as a plugin).
43 wp_deregister_script_module( $module['id'] );
44
45 wp_register_script_module(
46 $module['id'],
47 $base_url . $module['path'] . $extension,
48 $asset['module_dependencies'] ?? array(),
49 $asset['version'] ?? false,
50 array(
51 'fetchpriority' => 'low',
52 'in_footer' => true,
53 )
54 );
55 }
56 }
57
58 add_action( 'wp_default_scripts', 'gutenberg_register_script_modules' );
59 }
60