| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Connectors administration screen. 4 * 5 * @package WordPress 6 * @subpackage Administration 7 * @since 7.0.0 8 */ 9 10 /** WordPress Administration Bootstrap */ 11 require_once __DIR__ . '/admin.php'; 12 13 if ( ! current_user_can( 'manage_options' ) ) { 14 wp_die( 15 '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' . 16 '<p>' . __( 'Sorry, you are not allowed to manage connectors on this site.' ) . '</p>', 17 403 18 ); 19 } 20 21 if ( ! class_exists( '\WordPress\AiClient\AiClient' ) || ! function_exists( 'wp_options_connectors_wp_admin_render_page' ) ) { 22 wp_die( 23 '<h1>' . __( 'The Connectors are not available.' ) . '</h1>' . 24 '<p>' . __( 'The Connectors page requires build files. Please build WordPress and try again.' ) . '</p>', 25 503 26 ); 27 } 28 29 // Set the page title. 30 $title = __( 'Connectors' ); 31 32 // Set parent file for menu highlighting. 33 $parent_file = 'options-general.php'; 34 35 /** 36 * Preloads the REST API responses the Connectors UI fetches on mount. 37 * 38 * Without this, the page does a network round-trip for site settings, 39 * plugin capability discovery, and each connector's plugin record after 40 * the JS hydrates, which noticeably delays first paint. 41 * 42 * @since 7.2.0 43 * @access private 44 * 45 * @param array<string|string[]> $preload_paths Paths already queued for preloading. 46 * @return array<string|string[]> Paths with the Connectors-specific requests appended. 47 * 48 * @phpstan-param array<non-falsy-string|array{ non-falsy-string, 'GET'|'OPTIONS' }> $preload_paths 49 * @phpstan-return array<non-falsy-string|array{ non-falsy-string, 'GET'|'OPTIONS' }> 50 */ 51 function _wp_connectors_preload_paths( array $preload_paths ): array { 52 // getEntityRecord( 'root', 'site' ) in use-connector-plugin.ts / ai-plugin-callout.tsx. 53 $preload_paths[] = '/wp/v2/settings'; 54 55 // canUser( 'create', { kind: 'root', name: 'plugin' } ) in stage.tsx. 56 $preload_paths[] = array( '/wp/v2/plugins', 'OPTIONS' ); 57 58 // AiPluginCallout in routes/connectors-home/ai-plugin-callout.tsx queries this 59 // hardcoded ID to check whether the WP AI plugin is installed/active. 60 $preload_paths[] = '/wp/v2/plugins/ai/ai?context=edit'; 61 62 // getEntityRecord( 'root', 'plugin', <basename> ) per connector in use-connector-plugin.ts. 63 foreach ( wp_get_connectors() as $connector_data ) { 64 if ( empty( $connector_data['plugin']['file'] ) ) { 65 continue; 66 } 67 // core-data's plugin entity uses the basename with `.php` stripped 68 // as the record key (see routes/connectors-home/use-connector-plugin.ts). 69 $basename = preg_replace( '/\.php$/', '', plugin_basename( $connector_data['plugin']['file'] ) ); 70 $preload_paths[] = '/wp/v2/plugins/' . $basename . '?context=edit'; 71 } 72 73 return $preload_paths; 74 } 75 add_filter( 'wp_options_connectors_wp_admin_preload_paths', '_wp_connectors_preload_paths' ); 76 77 require_once ABSPATH . 'wp-admin/admin-header.php'; 78 79 // Render the Connectors page. 80 wp_options_connectors_wp_admin_render_page(); 81 82 require_once ABSPATH . 'wp-admin/admin-footer.php';
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Wed Nov 4 08:20:38 2026 | Cross-referenced by PHPXref |