| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Page: options-connectors 4 * Auto-generated by build process. 5 * Do not edit this file manually. 6 * 7 * @package wp 8 */ 9 10 // Global storage for options-connectors routes and menu items 11 global $wp_options_connectors_routes, $wp_options_connectors_menu_items; 12 $wp_options_connectors_routes = array(); 13 $wp_options_connectors_menu_items = array(); 14 15 /** 16 * Register a route for the options-connectors page. 17 * 18 * @param string $path Route path (e.g., '/types/$type/edit/$id'). 19 * @param string|null $content_module Script module ID for content (stage/inspector). 20 * @param string|null $route_module Script module ID for route lifecycle hooks. 21 */ 22 function wp_register_options_connectors_route( $path, $content_module = null, $route_module = null ) { 23 global $wp_options_connectors_routes; 24 25 $route = array( 'path' => $path ); 26 if ( ! empty( $content_module ) ) { 27 $route['content_module'] = $content_module; 28 } 29 if ( ! empty( $route_module ) ) { 30 $route['route_module'] = $route_module; 31 } 32 33 $wp_options_connectors_routes[] = $route; 34 } 35 36 /** 37 * Register a menu item for the options-connectors page. 38 * 39 * @param string $id Menu item ID. 40 * @param string $label Display label. 41 * @param string $to Route path to navigate to. 42 * @param string $parent_id Optional. Parent menu item ID. 43 * @param string $parent_type Optional. Parent type: 'drilldown' or 'dropdown'. 44 */ 45 function wp_register_options_connectors_menu_item( $id, $label, $to, $parent_id = '', $parent_type = '' ) { 46 global $wp_options_connectors_menu_items; 47 48 $menu_item = array( 49 'id' => $id, 50 'label' => $label, 51 'to' => $to, 52 ); 53 54 if ( ! empty( $parent_id ) ) { 55 $menu_item['parent'] = $parent_id; 56 } 57 58 if ( ! empty( $parent_type ) && in_array( $parent_type, array( 'drilldown', 'dropdown' ), true ) ) { 59 $menu_item['parent_type'] = $parent_type; 60 } 61 62 $wp_options_connectors_menu_items[] = $menu_item; 63 } 64 65 /** 66 * Get all registered routes for the options-connectors page. 67 * 68 * @return array Array of route objects. 69 */ 70 function wp_get_options_connectors_routes() { 71 global $wp_options_connectors_routes; 72 return $wp_options_connectors_routes ?? array(); 73 } 74 75 /** 76 * Get all registered menu items for the options-connectors page. 77 * 78 * @return array Array of menu item objects. 79 */ 80 function wp_get_options_connectors_menu_items() { 81 global $wp_options_connectors_menu_items; 82 return $wp_options_connectors_menu_items ?? array(); 83 } 84 85 /** 86 * Preload REST API data for the options-connectors page. 87 * Automatically called during page rendering. 88 */ 89 function wp_options_connectors_preload_data() { 90 // Define paths to preload - same for all pages 91 // Please also change packages/core-data/src/entities.js when changing this. 92 $preload_paths = array( 93 '/?_fields=description,gmt_offset,home,image_sizes,image_size_threshold,image_output_formats,jpeg_interlaced,png_interlaced,gif_interlaced,name,site_icon,site_icon_url,site_logo,timezone_string,url,page_for_posts,page_on_front,show_on_front', 94 array( '/wp/v2/settings', 'OPTIONS' ), 95 ); 96 97 // Use rest_preload_api_request to gather the preloaded data 98 $preload_data = array_reduce( 99 $preload_paths, 100 'rest_preload_api_request', 101 array() 102 ); 103 104 // Register the preloading middleware with wp-api-fetch 105 wp_add_inline_script( 106 'wp-api-fetch', 107 sprintf( 108 'wp.apiFetch.use( wp.apiFetch.createPreloadingMiddleware( %s ) );', 109 wp_json_encode( $preload_data ) 110 ), 111 'after' 112 ); 113 } 114 115 /** 116 * Render the options-connectors page. 117 * Call this function from add_menu_page or add_submenu_page. 118 */ 119 function wp_options_connectors_render_page() { 120 // Load build constants 121 $build_constants = require __DIR__ . '/../../constants.php'; 122 123 // Set current screen 124 set_current_screen(); 125 126 // Remove unwanted deprecated handler 127 remove_action( 'admin_head', 'wp_admin_bar_header' ); 128 129 // Remove unwanted scripts and styles that were enqueued during `admin_init` 130 foreach ( wp_scripts()->queue as $script ) { 131 wp_dequeue_script( $script ); 132 } 133 foreach ( wp_styles()->queue as $style ) { 134 wp_dequeue_style( $style ); 135 } 136 137 // Fire init action for extensions to register routes and menu items 138 do_action( 'options-connectors_init' ); 139 140 // Enqueue command palette assets for boot-based pages 141 if ( function_exists( 'wp_enqueue_command_palette_assets' ) ) { 142 wp_enqueue_command_palette_assets(); 143 } 144 145 // Preload REST API data 146 wp_options_connectors_preload_data(); 147 148 // Get all registered routes and menu items 149 $menu_items = wp_get_options_connectors_menu_items(); 150 $routes = wp_get_options_connectors_routes(); 151 152 // Get boot module asset file for dependencies 153 $asset_file = ABSPATH . WPINC . '/js/dist/script-modules/boot/index.min.asset.php'; 154 if ( file_exists( $asset_file ) ) { 155 $asset = require $asset_file; 156 157 // This script serves two purposes: 158 // 1. It ensures all the globals that are made available to the modules are loaded. 159 // 2. It initializes the boot module as an inline script. 160 wp_register_script( 'options-connectors-prerequisites', '', $asset['dependencies'], $asset['version'], true ); 161 162 // Add inline script to initialize the app 163 $init_modules = []; 164 wp_add_inline_script( 165 'options-connectors-prerequisites', 166 sprintf( 167 'import("@wordpress/boot").then(mod => mod.init({mountId: "%s", menuItems: %s, routes: %s, initModules: %s, dashboardLink: "%s"}));', 168 'options-connectors-app', 169 wp_json_encode( $menu_items, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), 170 wp_json_encode( $routes, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), 171 wp_json_encode( $init_modules, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), 172 esc_url( admin_url( '/' ) ) 173 ) 174 ); 175 176 // Register prerequisites style by filtering script dependencies to find registered styles 177 $style_dependencies = array_filter( 178 $asset['dependencies'], 179 function ( $handle ) { 180 return wp_style_is( $handle, 'registered' ); 181 } 182 ); 183 wp_register_style( 'options-connectors-prerequisites', false, $style_dependencies, $asset['version'] ); 184 185 // Build dependencies for options-connectors module 186 $boot_dependencies = array( 187 array( 188 'import' => 'static', 189 'id' => '@wordpress/boot', 190 ), 191 ); 192 193 // Add init modules as static dependencies 194 // No init modules configured 195 196 // Add all registered routes as dependencies 197 foreach ( $routes as $route ) { 198 if ( isset( $route['route_module'] ) ) { 199 $boot_dependencies[] = array( 200 'import' => 'static', 201 'id' => $route['route_module'], 202 ); 203 } 204 if ( isset( $route['content_module'] ) ) { 205 $boot_dependencies[] = array( 206 'import' => 'dynamic', 207 'id' => $route['content_module'], 208 ); 209 } 210 } 211 212 // Dummy script module to ensure dependencies are loaded 213 wp_register_script_module( 214 'options-connectors', 215 $build_constants['build_url'] . 'pages/options-connectors/loader.js', 216 $boot_dependencies 217 ); 218 219 // Enqueue the boot scripts and styles 220 wp_enqueue_script( 'options-connectors-prerequisites' ); 221 wp_enqueue_script_module( 'options-connectors' ); 222 wp_enqueue_style( 'options-connectors-prerequisites' ); 223 } 224 225 // Output the HTML 226 ?> 227 <!DOCTYPE html> 228 <html <?php language_attributes(); ?>> 229 <head> 230 <meta charset="<?php bloginfo( 'charset' ); ?>"> 231 <meta name="viewport" content="width=device-width, initial-scale=1"> 232 <title><?php echo esc_html( get_admin_page_title() ); ?></title> 233 <style> 234 html { 235 background: #f1f1f1; 236 color: #444; 237 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; 238 font-size: 13px; 239 line-height: 1.4em; 240 } 241 body { 242 margin: 0; 243 } 244 #wpadminbar { display: none; } 245 </style> 246 <?php 247 global $hook_suffix; 248 // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited 249 $hook_suffix = 'options-connectors'; 250 251 // BEGIN see wp-admin/admin-header.php 252 print_admin_styles(); 253 print_head_scripts(); 254 255 /** 256 * Fires in head section for a specific admin page. 257 * 258 * @since 2.1.0 259 */ 260 do_action( "admin_head-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 261 262 /** 263 * Fires in head section for all admin pages. 264 * 265 * @since 2.1.0 266 */ 267 do_action( 'admin_head' ); 268 // END see wp-admin/admin-header.php 269 ?> 270 </head> 271 <body class="options-connectors"> 272 <div id="options-connectors-app" style="height: 100vh; box-sizing: border-box;"></div> 273 <?php 274 // BEGIN see wp-admin/admin-footer.php 275 276 /** 277 * Prints scripts or data before the default footer scripts. 278 * 279 * @since 1.2.0 280 */ 281 do_action( 'admin_footer', '' ); 282 283 // Print import map first so it's available for inline scripts 284 wp_script_modules()->print_import_map(); 285 print_footer_scripts(); 286 wp_script_modules()->print_enqueued_script_modules(); 287 wp_script_modules()->print_script_module_preloads(); 288 wp_script_modules()->print_script_module_data(); 289 290 /** 291 * Prints scripts or data after the default footer scripts. 292 * 293 * @since 2.8.0 294 */ 295 do_action( "admin_footer-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 296 // END see wp-admin/admin-footer.php 297 ?> 298 </body> 299 </html> 300 <?php 301 exit; 302 } 303 304 /** 305 * Intercept admin_init to render the page early. 306 * This bypasses the default WordPress admin template. 307 */ 308 function wp_options_connectors_intercept_render() { 309 // phpcs:ignore WordPress.Security.NonceVerification.Recommended 310 if ( isset( $_GET['page'] ) && 'options-connectors' === $_GET['page'] ) { 311 wp_options_connectors_render_page(); 312 exit; 313 } 314 } 315 316 // Hook the interceptor to admin_init 317 add_action( 'admin_init', 'wp_options_connectors_intercept_render' );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Sat Jun 13 09:38:55 2026 | Cross-referenced by PHPXref |