Skip to content

Commit 0cc68cf

Browse files
Connectors: Change URL to options-connectors.php
Changes the Connectors screen URL from a query parameter page to a direct file, following the Settings menu naming convention (options-general.php, options-writing.php, etc.). - Add src/wp-admin/options-connectors.php direct admin file - Add submenu entry in menu.php at position 1 - Update script_module_data filter to options-connectors-wp-admin Props jeremyfelt, flavor13. See #64730.
1 parent 21f3a54 commit 0cc68cf

4 files changed

Lines changed: 43 additions & 24 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"url": "https://develop.svn.wordpress.org/trunk"
88
},
99
"gutenberg": {
10-
"ref": "022d8dd3d461f91b15c1f0410649d3ebb027207f"
10+
"ref": "95ecd95bc36c3e794be28250c10f4247761905c8"
1111
},
1212
"engines": {
1313
"node": ">=20.10.0",

src/wp-admin/menu.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ function _add_plugin_file_editor_to_tools() {
404404

405405
$menu[80] = array( __( 'Settings' ), 'manage_options', 'options-general.php', '', 'menu-top menu-icon-settings', 'menu-settings', 'dashicons-admin-settings' );
406406
$submenu['options-general.php'][10] = array( _x( 'General', 'settings screen' ), 'manage_options', 'options-general.php' );
407+
$submenu['options-general.php'][12] = array( __( 'Connectors' ), 'manage_options', 'options-connectors.php' );
407408
$submenu['options-general.php'][15] = array( __( 'Writing' ), 'manage_options', 'options-writing.php' );
408409
$submenu['options-general.php'][20] = array( __( 'Reading' ), 'manage_options', 'options-reading.php' );
409410
$submenu['options-general.php'][25] = array( __( 'Discussion' ), 'manage_options', 'options-discussion.php' );
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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>' . __( 'Connectors is not available.' ) . '</h1>' .
24+
'<p>' . __( 'The Connectors page requires build files. Please run <code>npm install</code> to build the necessary files.' ) . '</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+
require_once ABSPATH . 'wp-admin/admin-header.php';
36+
37+
// Render the Connectors page.
38+
wp_options_connectors_wp_admin_render_page();
39+
40+
require_once ABSPATH . 'wp-admin/admin-footer.php';

src/wp-includes/connectors.php

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,6 @@
1010
use WordPress\AiClient\AiClient;
1111
use WordPress\AiClient\Providers\Http\DTO\ApiKeyRequestAuthentication;
1212

13-
/**
14-
* Registers the Connectors menu item under Settings.
15-
*
16-
* @since 7.0.0
17-
* @access private
18-
*/
19-
function _wp_connectors_add_settings_menu_item(): void {
20-
if ( ! class_exists( '\WordPress\AiClient\AiClient' ) || ! function_exists( 'wp_connectors_wp_admin_render_page' ) ) {
21-
return;
22-
}
23-
24-
add_submenu_page(
25-
'options-general.php',
26-
__( 'Connectors' ),
27-
__( 'Connectors' ),
28-
'manage_options',
29-
'connectors-wp-admin',
30-
'wp_connectors_wp_admin_render_page',
31-
1
32-
);
33-
}
34-
add_action( 'admin_menu', '_wp_connectors_add_settings_menu_item' );
3513

3614
/**
3715
* Masks an API key, showing only the last 4 characters.
@@ -415,4 +393,4 @@ function _wp_connectors_get_connector_script_module_data( array $data ): array {
415393
$data['connectors'] = $connectors;
416394
return $data;
417395
}
418-
add_filter( 'script_module_data_connectors-wp-admin', '_wp_connectors_get_connector_script_module_data' );
396+
add_filter( 'script_module_data_options-connectors-wp-admin', '_wp_connectors_get_connector_script_module_data' );

0 commit comments

Comments
 (0)