Skip to content

Commit 91d7eec

Browse files
committed
rearrange menu items under GraphQL
1 parent 7231933 commit 91d7eec

File tree

6 files changed

+20
-8
lines changed

6 files changed

+20
-8
lines changed

plugins/wpgraphql-logging/src/Admin/Settings/Menu/MenuPage.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace WPGraphQL\Logging\Admin\Settings\Menu;
66

7+
use WPGraphQL\Logging\Admin\ViewLogsPage;
8+
79
/**
810
* Menu class for WordPress admin settings page.
911
*
@@ -78,7 +80,7 @@ public function __construct(
7880
*/
7981
public function register_page(): void {
8082
add_submenu_page(
81-
'options-general.php',
83+
ViewLogsPage::ADMIN_PAGE_SLUG,
8284
$this->page_title,
8385
$this->menu_title,
8486
'manage_options',

plugins/wpgraphql-logging/src/Admin/Settings/Templates/admin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
<div class="wrap">
2424
<h1><?php esc_html_e( 'WPGraphQL Logging Settings', 'wpgraphql-logging' ); ?></h1>
25+
<?php settings_errors(); ?>
2526
<form method="post" action="options.php">
2627
<nav class="nav-tab-wrapper">
2728
<?php

plugins/wpgraphql-logging/src/Admin/SettingsPage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static function init(): ?SettingsPage {
6868
*/
6969
public function setup(): void {
7070
add_action( 'init', [ $this, 'init_field_collection' ], 10, 0 );
71-
add_action( 'admin_menu', [ $this, 'register_settings_page' ], 10, 0 );
71+
add_action( 'admin_menu', [ $this, 'register_settings_page' ], 11, 0 );
7272
add_action( 'admin_init', [ $this, 'register_settings_fields' ], 10, 0 );
7373
add_action( 'admin_enqueue_scripts', [ $this, 'load_scripts_styles' ], 10, 1 );
7474
}
@@ -109,7 +109,7 @@ public function register_settings_page(): void {
109109

110110
$page = new MenuPage(
111111
__( 'WPGraphQL Logging Settings', 'wpgraphql-logging' ),
112-
__( 'WPGraphQL Logging', 'wpgraphql-logging' ),
112+
__( 'Settings', 'wpgraphql-logging' ),
113113
self::PLUGIN_MENU_SLUG,
114114
$this->get_admin_template(),
115115
[

plugins/wpgraphql-logging/src/Admin/ViewLogsPage.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,24 @@ public function setup(): void {
8282
*/
8383
public function register_settings_page(): void {
8484

85-
// Add submenu under GraphQL menu using the correct parent slug.
85+
// Add top-level menu page.
8686
$this->page_hook = add_menu_page(
8787
esc_html__( 'GraphQL Logs', 'wpgraphql-logging' ),
8888
esc_html__( 'GraphQL Logs', 'wpgraphql-logging' ),
8989
'manage_options',
9090
self::ADMIN_PAGE_SLUG,
9191
[ $this, 'render_admin_page' ],
9292
'dashicons-chart-line',
93-
25
93+
);
94+
95+
// Add "View All Logs" as the first submenu item (replaces the duplicate top-level menu item).
96+
add_submenu_page(
97+
self::ADMIN_PAGE_SLUG,
98+
esc_html__( 'All Logs', 'wpgraphql-logging' ),
99+
esc_html__( 'All Logs', 'wpgraphql-logging' ),
100+
'manage_options',
101+
self::ADMIN_PAGE_SLUG,
102+
[ $this, 'render_admin_page' ]
94103
);
95104

96105
// Updates the list table when filters are applied.

plugins/wpgraphql-logging/tests/e2e/plugins/reset-wpgraphql-logging-settings/reset-wpgraphql-logging-settings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
add_action('init', function () {
8-
if ($_SERVER['REQUEST_URI'] === '/wp-admin/options-general.php?page=wpgraphql-logging&reset=true') {
8+
if ($_SERVER['REQUEST_URI'] === '/wp-admin/admin.php?page=wpgraphql-logging&reset=true') {
99
global $wpdb;
1010

1111
// Reset settings

plugins/wpgraphql-logging/tests/e2e/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
*/
44
export async function resetPluginSettings(admin) {
55
await admin.visitAdminPage(
6-
"/options-general.php?page=wpgraphql-logging&reset=true"
6+
"/admin.php?page=wpgraphql-logging&reset=true"
77
);
88
}
99

1010
/**
1111
* Navigate to WPGraphQL Logging settings page
1212
*/
1313
export async function goToLoggingSettingsPage(admin) {
14-
await admin.visitAdminPage("/options-general.php?page=wpgraphql-logging");
14+
await admin.visitAdminPage("/admin.php?page=wpgraphql-logging");
1515
}
1616

1717
/**

0 commit comments

Comments
 (0)