Repository navigation
Connect: get the key back automatically when MonoRanks can't reach the site - #23
Merged
Merged
Conversation
…t reach the site The connect link now carries a per-user state (30 minutes). When MonoRanks cannot reach the site, it sends the person back to Settings with a one-time code and that state; the plugin checks the state and trades the code for the key directly.
Connection card: the status sentence moves to the Connected chip, the key's origin, the full sync date, the app password and SEO plugin notes and the Disconnect note move behind (i) tooltips. What is sent is a collapsed section. The page subtitle is gone. Overview: long step, note and status lines become tooltips.
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.
What
The Connect button did nothing useful for sites MonoRanks cannot reach (local
.testsites, firewalled sites). MonoRanks showed a key to copy, and the plugin stayed "Not connected".Now the plugin gets the key back by itself:
Settings::connect_url()adds&state=<40 hex chars>. The state is stored per user in a transient (monoranks_connect_<user id>, 30 minutes) together with the MonoRanks address the link points at. It is reused while it lives, so two tabs show the same link.Handoffclass, run onadmin_init. When MonoRanks → Settings opens withmonoranks_codeandmonoranks_state:manage_options.hash_equalsagainst the user's stored state, then deletes it.wp_remote_post {base}/api/wordpress/claimwith{code, site: untrailingslashit(home_url('/'))}.Connection::valid_key.Actions::use_key(..., 'pairing', site_id), the same steps as a pasted key withviaset to pairing: send status, start the first sync, refresh insights.Actions::connect_keynow goes through the shareduse_key. Its behaviour is unchanged.uninstall.phpalso clears the connect-state transients.bin/i18n.sh.No version bump, no readme.txt change.
App side: monoranks/monoranks#256.
Tests
vendor/bin/phpunit: 101 tests, all passing. NewHandoffTest: good state, bad state, another user's state, failed claim, bad key in the answer, bad code, nomanage_options, other admin page.SettingsTestgains a test that the link carries and reuses the state.Also: a simpler Settings page
Rows are short now, and the details sit behind an (i) tooltip. The tooltip is a new small component (
resources/admin/src/components/ui/tip.tsx) that opens on hover and on keyboard focus, and Escape closes it.Settings, Connection card
last_sent_shortandlast_sent_datefields, fromAdmin::ago_short()andAdmin::date_of().Rest of the Settings page
Overview
The .pot, fa_IR .po/.mo and the admin JSON are rebuilt, and the admin bundle is rebuilt. PHPUnit: 102 tests pass. The Playwright spec needs wp-env (Docker), which was not available.