PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 All 504 releases
jetpack / jetpack_vendor / automattic / jetpack-forms / build / modules.php

modules.php in Jetpack – WP Security, Backup, Speed, & Growth 16.3-a.1, at jetpack_vendor/automattic/jetpack-forms/build/modules.php

64 lines 1.8 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 jetpack_forms
7 */
8
9 /**
10 * Register all script modules.
11 */
12 function jetpack_forms_register_script_modules() {
13 // Ensure this only runs once. wp_default_scripts can fire multiple times,
14 // and each wp_deregister_script_module() call also dequeues the module.
15 // If a module was enqueued between calls, repeated deregister/register
16 // cycles would lose the enqueue state.
17 static $already_registered = false;
18 if ( $already_registered ) {
19 return;
20 }
21 $already_registered = true;
22
23 // Load build constants
24 $constants_file = __DIR__ . '/constants.php';
25 if ( ! file_exists( $constants_file ) ) {
26 return;
27 }
28 $build_constants = require $constants_file;
29 $modules_dir = __DIR__ . '/modules';
30 $modules_file = $modules_dir . '/registry.php';
31
32 if ( ! file_exists( $modules_file ) ) {
33 return;
34 }
35
36 $modules = require $modules_file;
37 $base_url = $build_constants['build_url'] . 'modules/';
38
39 foreach ( $modules as $module ) {
40 // WASM-only modules (e.g., vips worker) only have .min.js; use it even when SCRIPT_DEBUG is `true`.
41 $extension = '.min.js';
42
43 $asset_path = $modules_dir . '/' . $module['asset'];
44 $asset = file_exists( $asset_path ) ? require $asset_path : array();
45
46 // Deregister first to override any previously registered version
47 // (e.g., Core's default modules when running as a plugin).
48 wp_deregister_script_module( $module['id'] );
49
50 wp_register_script_module(
51 $module['id'],
52 $base_url . $module['path'] . $extension,
53 $asset['module_dependencies'] ?? array(),
54 $asset['version'] ?? false,
55 array(
56 'fetchpriority' => 'low',
57 'in_footer' => true,
58 )
59 );
60 }
61 }
62
63 add_action( 'wp_default_scripts', 'jetpack_forms_register_script_modules' );
64