Fix multi-directory save flow and Directory Builder access - #2958
Open
RabbiIslamRony wants to merge 1 commit into
Open
Fix multi-directory save flow and Directory Builder access#2958RabbiIslamRony wants to merge 1 commit into
RabbiIslamRony wants to merge 1 commit into
Conversation
Make the multi-directory toggle use the standard settings workflow so changes remain local until the footer Save changes action is used, without a confirmation modal or forced reload. Register the inactive Directory Builder slug as a hidden compatibility page and redirect it to the active mode-specific route. This keeps stale AJAX-era menu links and saved bookmarks working while retaining a single visible submenu item and the existing manage_options capability. Document the manual-save contract and compatibility routing behavior in the settings-panel references.
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.
PR Type
What kind of change does this PR introduce?
Description
Problem
The
Enable multi-directorysetting behaved differently from the other settings switches: it opened a confirmation modal, saved immediately, and forced a page reload.After moving the switch to the standard footer
Save changesflow, another existing routing problem became visible. The settings request is saved through AJAX, so the WordPress admin menu on the current page still contains the route from the previous multi-directory state:page=atbdp-layout-builder.page=atbdp-directory-types.Previously, only the route for the newly saved state was registered on the next request. Clicking the stale menu link or opening a bookmark for the inactive route therefore produced WordPress's
Sorry, you are not allowed to access this page.response, even for an administrator.Solution
enable_multi_directory.manage_optionscapability.wp_safe_redirect().How to reproduce the original issue
Save changesbutton.atbdp-layout-builderDirectory Builder menu link.atbdp-directory-types.How to test the changes
Save changesbutton becomes enabled, save the setting, and verify the button reportsSavedwhile the page remains in place.atbdp-layout-buildermenu link and verify it redirects toatbdp-directory-types, loads the directory archive, and shows only one Directory Builder submenu item.page=atbdp-directory-types&listing_type_id=3&action=editand verify the Business directory editor loads normally.atbdp-directory-typesmenu link and verify it redirects toatbdp-layout-builderand loads the default Business directory editor.Verification performed
builder-archive.jsand the editor loadsmulti-directory-builder.js.php -l.git diff --check.vendor/bin/phpcsis not installed.PHPCS Checkworkflow currently stops at its checkout step for fork PRs: itspull_request_targetjob attempts to check out the fork SHA, which GitHub rejects as unsafe before PHP setup or PHPCS execution. The reported failure is therefore an upstream workflow-policy failure, not a PHPCS result for this code. View the failed checkout job.Any linked issues
None.
Checklist