Skip to content

Commit a78b0c5

Browse files
committed
Correct merge.
1 parent aa487df commit a78b0c5

2 files changed

Lines changed: 62 additions & 51 deletions

File tree

.claude/settings.local.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(python3:*)",
5+
"Bash(node -e:*)",
6+
"Bash(node:*)",
7+
"Bash(/Users/jdesrosiers/Sites/GitHub/Organizations/WordPress/gutenberg/node_modules/.bin/npmPkgJsonLint --help)",
8+
"WebFetch(domain:raw.githubusercontent.com)",
9+
"Bash(node_modules/.bin/stylelint:*)",
10+
"WebFetch(domain:github.com)"
11+
]
12+
}
13+
}

packages/wp-build/templates/routes-registration.php.template

Lines changed: 49 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -32,63 +32,61 @@ foreach ( $routes_by_page as $page_slug => $page_routes ) {
3232
$GLOBALS[ $global_name ] = $page_routes;
3333
}
3434

35-
if ( ! function_exists( '{{PREFIX}}_register_page_routes' ) ) {
36-
/**
37-
* Generic helper function to register routes for a page.
38-
*
39-
* @param array $page_routes Array of route data for the page.
40-
* @param string $register_function_name Name of the function to call for registering each route.
41-
*/
42-
function {{PREFIX}}_register_page_routes( $page_routes, $register_function_name ) {
43-
// Load build constants
44-
$build_constants = require __DIR__ . '/constants.php';
35+
/**
36+
* Generic helper function to register routes for a page.
37+
*
38+
* @param array $page_routes Array of route data for the page.
39+
* @param string $register_function_name Name of the function to call for registering each route.
40+
*/
41+
function {{PREFIX}}_register_page_routes( $page_routes, $register_function_name ) {
42+
// Load build constants
43+
$build_constants = require __DIR__ . '/constants.php';
4544

46-
foreach ( $page_routes as $route ) {
47-
$content_handle = null;
48-
$route_handle = null;
45+
foreach ( $page_routes as $route ) {
46+
$content_handle = null;
47+
$route_handle = null;
4948

50-
// Register content module if exists
51-
if ( $route['has_content'] ) {
52-
$content_asset_path = __DIR__ . "/routes/{$route['name']}/content.min.asset.php";
53-
if ( file_exists( $content_asset_path ) ) {
54-
$content_asset = require $content_asset_path;
55-
$content_handle = '{{HANDLE_PREFIX}}/routes/' . $route['name'] . '/content';
56-
$extension = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.js' : '.min.js';
57-
// Deregister first to override any previously registered version
58-
// (e.g., Core's default modules when running as a plugin).
59-
wp_deregister_script_module( $content_handle );
60-
wp_register_script_module(
61-
$content_handle,
62-
$build_constants['build_url'] . 'routes/' . $route['name'] . '/content' . $extension,
63-
$content_asset['module_dependencies'] ?? array(),
64-
$content_asset['version'] ?? false
65-
);
66-
}
49+
// Register content module if exists
50+
if ( $route['has_content'] ) {
51+
$content_asset_path = __DIR__ . "/routes/{$route['name']}/content.min.asset.php";
52+
if ( file_exists( $content_asset_path ) ) {
53+
$content_asset = require $content_asset_path;
54+
$content_handle = '{{HANDLE_PREFIX}}/routes/' . $route['name'] . '/content';
55+
$extension = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.js' : '.min.js';
56+
// Deregister first to override any previously registered version
57+
// (e.g., Core's default modules when running as a plugin).
58+
wp_deregister_script_module( $content_handle );
59+
wp_register_script_module(
60+
$content_handle,
61+
$build_constants['build_url'] . 'routes/' . $route['name'] . '/content' . $extension,
62+
$content_asset['module_dependencies'] ?? array(),
63+
$content_asset['version'] ?? false
64+
);
6765
}
66+
}
6867

69-
// Register route module if exists
70-
if ( $route['has_route'] ) {
71-
$route_asset_path = __DIR__ . "/routes/{$route['name']}/route.min.asset.php";
72-
if ( file_exists( $route_asset_path ) ) {
73-
$route_asset = require $route_asset_path;
74-
$route_handle = '{{HANDLE_PREFIX}}/routes/' . $route['name'] . '/route';
75-
$extension = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.js' : '.min.js';
76-
// Deregister first to override any previously registered version
77-
// (e.g., Core's default modules when running as a plugin).
78-
wp_deregister_script_module( $route_handle );
79-
wp_register_script_module(
80-
$route_handle,
81-
$build_constants['build_url'] . 'routes/' . $route['name'] . '/route' . $extension,
82-
$route_asset['module_dependencies'] ?? array(),
83-
$route_asset['version'] ?? false
84-
);
85-
}
68+
// Register route module if exists
69+
if ( $route['has_route'] ) {
70+
$route_asset_path = __DIR__ . "/routes/{$route['name']}/route.min.asset.php";
71+
if ( file_exists( $route_asset_path ) ) {
72+
$route_asset = require $route_asset_path;
73+
$route_handle = '{{HANDLE_PREFIX}}/routes/' . $route['name'] . '/route';
74+
$extension = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.js' : '.min.js';
75+
// Deregister first to override any previously registered version
76+
// (e.g., Core's default modules when running as a plugin).
77+
wp_deregister_script_module( $route_handle );
78+
wp_register_script_module(
79+
$route_handle,
80+
$build_constants['build_url'] . 'routes/' . $route['name'] . '/route' . $extension,
81+
$route_asset['module_dependencies'] ?? array(),
82+
$route_asset['version'] ?? false
83+
);
8684
}
85+
}
8786

88-
// Register route with page
89-
if ( function_exists( $register_function_name ) ) {
90-
call_user_func( $register_function_name, $route['path'], $content_handle, $route_handle );
91-
}
87+
// Register route with page
88+
if ( function_exists( $register_function_name ) ) {
89+
call_user_func( $register_function_name, $route['path'], $content_handle, $route_handle );
9290
}
9391
}
9492
}

0 commit comments

Comments
 (0)