Repository navigation
Give FrontBlocks a menu of its own with a submenu for each settings tab - #357
Merged
Merged
Conversation
Move the settings out of Appearance into a top-level menu below it. Each tab is an entry of the submenu and a page of its own, so a tab has a URL that can be linked, bookmarked and opened from the admin sidebar. - The first tab uses the page slug of the menu and every other adds its id, for example frontblocks-settings-image-management. The tab of the page that was opened is shown first, a #hash still overrides it, and a link with a hash followed while the screen is open now switches tab. - Clicking a tab in the screen updates the address bar to the page of that tab and highlights its entry in the sidebar, so reloading or copying the link opens the same tab. - Tabs come from one place, get_tabs(), which the menu and the screen share, so a tab added with frontblocks_settings_tabs also gets a menu entry. A tab can stay out of the menu with 'menu' => false. - The old themes.php?page=frontblocks-settings URL redirects to the new menu and keeps its query arguments and its #tab. It only redirects users who can open the settings, and forwards only sanitized string arguments. - Settings::get_settings_url(), get_page_slug(), get_tab_from_page() and is_settings_screen() replace the hard-coded URLs and the appearance_page_frontblocks-settings screen ID, in the settings assets, the notices, the activation redirect, the admin bar maintenance link, Google Sign-In and the redundant plugins notice.
Cover the top-level menu and its submenu entries, tabs added or hidden by companion plugins, the URL helpers and screen detection, the tab that opens, the script that keeps the sidebar and the address bar in step, the redirect of the old URL and every link that used to point at Appearance. Update the tests that used the old screen ID.
Say FrontBlocks menu instead of Appearance in the docs, explain how a companion plugin gets its tab in the submenu and links to it, and add the changelog entry.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Resolve the changelog conflict and move the code that came with Staging Mode to the new menu: the admin bar node and the redundant plugins link open the Maintenance tab, and the staging notice also shows on every FrontBlocks settings screen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FrontBlocks leaves the Appearance menu and gets a menu of its own, right below it, with a submenu entry for each settings tab. Each entry is a page of its own, so a tab can be linked, bookmarked and opened from the admin sidebar. The screen, its tabs and its save bar stay the same.
(See
menu-screenshot.png, attach it to the pull request.)How it works
Settings::register_menu()adds the top-level menu with the existingicon-menu.svgat position 60.5, below Appearance, and a submenu entry for each tab. The page callback is on the first entry, so the page is not rendered twice.admin.php?page=frontblocks-settings) and every other adds its id (frontblocks-settings-image-management). All of them render the same screen, which opens on the tab of the page that was requested. A#hashstill wins over it, so links with a hash keep working.hashchange).get_tabs()is shared by the menu and the screen, so a tab added withfrontblocks_settings_tabsgets a menu entry automatically. A tab can stay out of the menu with'menu' => false. The toggle counts shown next to a tab are passed in by the screen, because the fields they come from do not exist yet when the menu is registered.themes.php?page=frontblocks-settingsredirects to the new menu onadmin_menu, before WordPress checks the page. It keeps the query arguments and the#tab(the browser carries the fragment across the redirect), forwards only sanitized string arguments, stays on the site (wp_safe_redirect) and only redirects users who can open the settings. Everyone else gets the usual "not allowed".One set of helpers instead of hard-coded locations
Settings::get_settings_url( $tab ),get_page_slug(),get_tab_from_page()andis_settings_screen()replace thethemes.php?page=...URLs and theappearance_page_frontblocks-settingsscreen ID, in:is_settings_screen()matches by slug, because the screen ID is different on each tab, and it still recognizes the Appearance one for plugins that have not changed yet.Release order and FrontBlocks PRO
PRO compares the screen ID in two places (the styles of Advanced Cookie Management and the Leads notice). The companion pull request,
feature/accept-top-level-menuinfrontblocks-pro, makes them work with both locations and does not depend on this one, so it should be released first. If this goes out first, the only thing that stops working with an older PRO is the admin stylesheet of Advanced Cookie Management; the Leads tab keeps working.Testing
tests/Unit/SettingsMenuTest.php): the top-level menu and its position, the submenu entries and their order, tabs added, hidden and invalid, the helpers and screen detection, the tab that opens, the script that keeps the sidebar in step, the redirect of the old URL (arguments, sanitizing, same-site, capability, other pages) and every link that used to point at Appearance. The two tests that used the old screen ID were updated.'menu' => falserule, the slug of the first tab, the position, or any of the links makes tests fail.composer lintandcomposer phpstanare clean. Together with the Backup tab pull request (Add settings export and import in a new Backup tab #350) the merged result passes 561 tests.#google-signinandgsi-updatedlands on the new page with the Social Login tab and its notice; saving the Optional tab returns to it with the change saved; the activation redirect and the admin bar link land on the new pages; an editor sees no menu and gets a 403 on the new and the old URLs; a logged-out visitor goes to the login. No JavaScript errors.Notes for reviewers
themes.php?page=...#backup. It works through the redirect, but whichever of the two is merged second should switch it toSettings::get_settings_url( 'backup' ). The two only conflict in the changelog ofreadme.txt.feature/e2e-playwrightusethemes.php?page=frontblocks-settings. They keep working because they follow the redirect, but their expectations about the URL should be updated.@since 1.6.0. Adjust it if this ships in another version.trunk:Settings.phpcallsclosest('.tw:flex'), which is not a valid selector and needs the colon escaped. It is outside this change.