Skip to content
Closed
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
907615f
Add preload paths filter introduced in https://github.com/WordPress/g…
westonruter May 10, 2026
3efbc09
Preload REST API requests used on the Connectors screen
westonruter May 10, 2026
7239697
Supply improved type for WP_HTTP_Response::$headers
westonruter May 10, 2026
1a851a2
Harden rest_preload_api_request() and address PHPStan errors
westonruter May 10, 2026
e782e09
Allow preloading REST API responses with non-OK statuses
westonruter May 10, 2026
f97da5d
Update phpdoc for _wp_connectors_preload_paths()
westonruter May 11, 2026
cd78f0f
Revert "Add preload paths filter introduced in https://github.com/Wor…
westonruter May 11, 2026
dc15523
Fix duplicated non-existing post ID
westonruter May 12, 2026
daff569
Fix variable reference in assertion message
westonruter May 12, 2026
3f31717
Update since tag
westonruter Jun 15, 2026
971ebe6
Fix PHPStan rule level 10 issues in tests
westonruter Jun 16, 2026
512f016
Fix typo
t-hamano Aug 2, 2026
e33c6da
Fix typo
t-hamano Aug 2, 2026
ecc8c66
Remove obsolete PHPStan baseline entry for rest_preload_api_request()
t-hamano Sep 29, 2026
e4bc841
Rename Connectors preload paths hook to match the Gutenberg wp-build …
t-hamano Sep 29, 2026
f5b3b30
Update PHPDoc for Connectors preloading and rest_preload_api_request()
t-hamano Oct 2, 2026
d5a2d7e
Fix: Don't preload 404 responses for missing Connectors plugins.
jorgefilipecosta Oct 16, 2026
82503d9
Fix: Revert the rest_preload_api_request() changes and keep only the …
jorgefilipecosta Oct 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/wp-admin/options-connectors.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,48 @@
// Set parent file for menu highlighting.
$parent_file = 'options-general.php';

/**
* Preloads the REST API responses the Connectors UI fetches on mount.
*
* Without this, the page does a network round-trip for site settings,
* plugin capability discovery, and each connector's plugin record after
* the JS hydrates, which noticeably delays first paint.
*
* @since 7.2.0
* @access private
*
* @param array<string|string[]> $preload_paths Paths already queued for preloading.
* @return array<string|string[]> Paths with the Connectors-specific requests appended.
*
* @phpstan-param array<non-falsy-string|array{ non-falsy-string, 'GET'|'OPTIONS' }> $preload_paths
* @phpstan-return array<non-falsy-string|array{ non-falsy-string, 'GET'|'OPTIONS' }>
*/
function _wp_connectors_preload_paths( array $preload_paths ): array {
// getEntityRecord( 'root', 'site' ) in use-connector-plugin.ts / ai-plugin-callout.tsx.
$preload_paths[] = '/wp/v2/settings';

// canUser( 'create', { kind: 'root', name: 'plugin' } ) in stage.tsx.
$preload_paths[] = array( '/wp/v2/plugins', 'OPTIONS' );

// AiPluginCallout in routes/connectors-home/ai-plugin-callout.tsx queries this
// hardcoded ID to check whether the WP AI plugin is installed/active.
$preload_paths[] = '/wp/v2/plugins/ai/ai?context=edit';

// getEntityRecord( 'root', 'plugin', <basename> ) per connector in use-connector-plugin.ts.
foreach ( wp_get_connectors() as $connector_data ) {
if ( empty( $connector_data['plugin']['file'] ) ) {
continue;
}
// core-data's plugin entity uses the basename with `.php` stripped
// as the record key (see routes/connectors-home/use-connector-plugin.ts).
$basename = preg_replace( '/\.php$/', '', plugin_basename( $connector_data['plugin']['file'] ) );
$preload_paths[] = '/wp/v2/plugins/' . $basename . '?context=edit';
}

return $preload_paths;
}
add_filter( 'wp_options_connectors_wp_admin_preload_paths', '_wp_connectors_preload_paths' );

Comment on lines +73 to +76
require_once ABSPATH . 'wp-admin/admin-header.php';

// Render the Connectors page.
Expand Down
Loading