Pewarta Proxy

📋 Server Request & Proxy Logs

Loading active proxy settings...
Developed by Khairul Adha (adhexa.id)
Mengambil log server...

⚙️ Pengaturan Proxy Target

Skip to content

Commit f0d0909

Browse files
desrosjyouknowriad
authored andcommitted
Remove ! function_exists() checks from PHP templates (#76062)
Co-authored-by: desrosj <desrosj@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
1 parent 024f173 commit f0d0909

7 files changed

Lines changed: 696 additions & 740 deletions

‎packages/wp-build/templates/module-registration.php.template‎

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,42 @@
66
* @package {{PREFIX}}
77
*/
88

9-
if ( ! function_exists( '{{PREFIX}}_register_script_modules' ) ) {
10-
/**
11-
* Register all script modules.
12-
*/
13-
function {{PREFIX}}_register_script_modules() {
14-
// Load build constants
15-
$build_constants = require __DIR__ . '/constants.php';
16-
$modules_dir = __DIR__ . '/modules';
17-
$modules_file = $modules_dir . '/registry.php';
9+
/**
10+
* Register all script modules.
11+
*/
12+
function {{PREFIX}}_register_script_modules() {
13+
// Load build constants
14+
$build_constants = require __DIR__ . '/constants.php';
15+
$modules_dir = __DIR__ . '/modules';
16+
$modules_file = $modules_dir . '/registry.php';
1817

19-
if ( ! file_exists( $modules_file ) ) {
20-
return;
21-
}
18+
if ( ! file_exists( $modules_file ) ) {
19+
return;
20+
}
2221

23-
$modules = require $modules_file;
24-
$base_url = $build_constants['build_url'] . 'modules/';
25-
$extension = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.js' : '.min.js';
22+
$modules = require $modules_file;
23+
$base_url = $build_constants['build_url'] . 'modules/';
24+
$extension = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.js' : '.min.js';
2625

27-
foreach ( $modules as $module ) {
28-
$asset_path = $modules_dir . '/' . $module['asset'];
29-
$asset = file_exists( $asset_path ) ? require $asset_path : array();
26+
foreach ( $modules as $module ) {
27+
$asset_path = $modules_dir . '/' . $module['asset'];
28+
$asset = file_exists( $asset_path ) ? require $asset_path : array();
3029

31-
// Deregister first to override any previously registered version
32-
// (e.g., Core's default modules when running as a plugin).
33-
wp_deregister_script_module( $module['id'] );
30+
// Deregister first to override any previously registered version
31+
// (e.g., Core's default modules when running as a plugin).
32+
wp_deregister_script_module( $module['id'] );
3433

35-
wp_register_script_module(
36-
$module['id'],
37-
$base_url . $module['path'] . $extension,
38-
$asset['module_dependencies'] ?? array(),
39-
$asset['version'] ?? false,
40-
array(
41-
'fetchpriority' => 'low',
42-
'in_footer' => true,
43-
)
44-
);
45-
}
34+
wp_register_script_module(
35+
$module['id'],
36+
$base_url . $module['path'] . $extension,
37+
$asset['module_dependencies'] ?? array(),
38+
$asset['version'] ?? false,
39+
array(
40+
'fetchpriority' => 'low',
41+
'in_footer' => true,
42+
)
43+
);
4644
}
47-
48-
add_action( 'wp_default_scripts', '{{PREFIX}}_register_script_modules' );
4945
}
46+
47+
add_action( 'wp_default_scripts', '{{PREFIX}}_register_script_modules' );

0 commit comments

Comments
 (0)