PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.5
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.5
16.3-a.5 16.3-a.7 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 All 506 releases
jetpack / build / routes.php

routes.php in Jetpack – WP Security, Backup, Speed, & Growth 16.3-a.5, at build/routes.php

133 lines 5.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Routes registration - Auto-generated by build process.
4 * Registers all routes on their respective page init hooks.
5 * Do not edit this file manually.
6 *
7 * @package jetpack_plugin
8 */
9
10 // Load routes registry
11 $routes_file = __DIR__ . '/routes/registry.php';
12 if ( ! file_exists( $routes_file ) ) {
13 return;
14 }
15
16 $routes = require $routes_file;
17
18 // Group routes by page and store in globals for page-specific functions
19 $routes_by_page = array();
20 foreach ( $routes as $route ) {
21 $page_slug = $route['page'];
22 if ( ! isset( $routes_by_page[ $page_slug ] ) ) {
23 $routes_by_page[ $page_slug ] = array();
24 }
25 $routes_by_page[ $page_slug ][] = $route;
26 }
27
28 // Store routes data in globals for each page
29 foreach ( $routes_by_page as $page_slug => $page_routes ) {
30 $page_slug_underscore = str_replace( '-', '_', $page_slug );
31 $global_name = 'jetpack_plugin_' . $page_slug_underscore . '_routes_data';
32 $GLOBALS[ $global_name ] = $page_routes;
33 }
34
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 jetpack_plugin_register_page_routes( $page_routes, $register_function_name ) {
42 // Load build constants
43 $build_constants = require __DIR__ . '/constants.php';
44
45 foreach ( $page_routes as $route ) {
46 $content_handle = null;
47 $route_handle = null;
48
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 = 'jetpack-plugin/routes/' . $route['name'] . '/content';
55 $extension = '.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 );
65 }
66 }
67
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 = 'jetpack-plugin/routes/' . $route['name'] . '/route';
74 $extension = '.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 );
84 }
85 }
86
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 );
90 }
91 }
92 }
93
94 // Page-specific route registration functions
95 // Page-specific route registration functions for jetpack-ai-hub
96 /**
97 * Register routes for jetpack-ai-hub page (full-page mode).
98 */
99 function jetpack_plugin_register_jetpack_ai_hub_page_routes() {
100 global $jetpack_plugin_jetpack_ai_hub_routes_data;
101 jetpack_plugin_register_page_routes( $jetpack_plugin_jetpack_ai_hub_routes_data, 'jetpack_plugin_register_jetpack_ai_hub_route' );
102 }
103 add_action( 'jetpack-ai-hub_init', 'jetpack_plugin_register_jetpack_ai_hub_page_routes' );
104
105 /**
106 * Register routes for jetpack-ai-hub page (wp-admin mode).
107 */
108 function jetpack_plugin_register_jetpack_ai_hub_wp_admin_page_routes() {
109 global $jetpack_plugin_jetpack_ai_hub_routes_data;
110 jetpack_plugin_register_page_routes( $jetpack_plugin_jetpack_ai_hub_routes_data, 'jetpack_plugin_register_jetpack_ai_hub_wp_admin_route' );
111 }
112 add_action( 'jetpack-ai-hub-wp-admin_init', 'jetpack_plugin_register_jetpack_ai_hub_wp_admin_page_routes' );
113
114 // Page-specific route registration functions for jetpack-settings-dashboard
115 /**
116 * Register routes for jetpack-settings-dashboard page (full-page mode).
117 */
118 function jetpack_plugin_register_jetpack_settings_dashboard_page_routes() {
119 global $jetpack_plugin_jetpack_settings_dashboard_routes_data;
120 jetpack_plugin_register_page_routes( $jetpack_plugin_jetpack_settings_dashboard_routes_data, 'jetpack_plugin_register_jetpack_settings_dashboard_route' );
121 }
122 add_action( 'jetpack-settings-dashboard_init', 'jetpack_plugin_register_jetpack_settings_dashboard_page_routes' );
123
124 /**
125 * Register routes for jetpack-settings-dashboard page (wp-admin mode).
126 */
127 function jetpack_plugin_register_jetpack_settings_dashboard_wp_admin_page_routes() {
128 global $jetpack_plugin_jetpack_settings_dashboard_routes_data;
129 jetpack_plugin_register_page_routes( $jetpack_plugin_jetpack_settings_dashboard_routes_data, 'jetpack_plugin_register_jetpack_settings_dashboard_wp_admin_route' );
130 }
131 add_action( 'jetpack-settings-dashboard-wp-admin_init', 'jetpack_plugin_register_jetpack_settings_dashboard_wp_admin_page_routes' );
132
133