modules
1 week ago
pages
1 week ago
routes
2 days ago
scripts
2 weeks ago
styles
6 months ago
build.php
2 months ago
constants.php
2 days ago
i18n-manifest.json
2 weeks ago
modules.php
2 months ago
pages.php
2 months ago
routes.php
3 months ago
scripts.php
3 months ago
styles.php
3 months ago
routes.php
114 lines
| 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_forms |
| 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_forms_' . $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_forms_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-forms/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-forms/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-forms-responses |
| 96 | /** |
| 97 | * Register routes for jetpack-forms-responses page (full-page mode). |
| 98 | */ |
| 99 | function jetpack_forms_register_jetpack_forms_responses_page_routes() { |
| 100 | global $jetpack_forms_jetpack_forms_responses_routes_data; |
| 101 | jetpack_forms_register_page_routes( $jetpack_forms_jetpack_forms_responses_routes_data, 'jetpack_forms_register_jetpack_forms_responses_route' ); |
| 102 | } |
| 103 | add_action( 'jetpack-forms-responses_init', 'jetpack_forms_register_jetpack_forms_responses_page_routes' ); |
| 104 | |
| 105 | /** |
| 106 | * Register routes for jetpack-forms-responses page (wp-admin mode). |
| 107 | */ |
| 108 | function jetpack_forms_register_jetpack_forms_responses_wp_admin_page_routes() { |
| 109 | global $jetpack_forms_jetpack_forms_responses_routes_data; |
| 110 | jetpack_forms_register_page_routes( $jetpack_forms_jetpack_forms_responses_routes_data, 'jetpack_forms_register_jetpack_forms_responses_wp_admin_route' ); |
| 111 | } |
| 112 | add_action( 'jetpack-forms-responses-wp-admin_init', 'jetpack_forms_register_jetpack_forms_responses_wp_admin_page_routes' ); |
| 113 | |
| 114 |