wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
_wp_connectors_preload_paths is private and should not be used in themes or plugins directly.
_wp_connectors_preload_paths › WordPress Function
Seit7.2.0
Veraltetn/v
› _wp_connectors_preload_paths ( $preload_paths )
| Zugriff: |
|
| Parameter: |
|
| Gibt zurück: |
|
| Definiert in: |
|
| Codex: |
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.Quellcode
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;
}