Skip to content

Commit 740b17c

Browse files
committed
[FIX] Skip an empty keyphrase sync so Arc is unchanged
[UPD] Bump plugin version to 0.6.1 [DOC] Add the v0.6.1 release notes [TST] Cover a vacant keyphrase replace
1 parent 4751ebd commit 740b17c

9 files changed

Lines changed: 79 additions & 8 deletions

File tree

‎ROADMAP.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ has none, and to connect this install when it is not paired with Arc.
6666
Those notices do not change the menu count. **Sync with Arc** is shown after the first scan,
6767
and only when the local list hash differs from `GET /v1/sites/{siteId}/seo-targets`.
6868
The click sends dirty rows when Arc still matches the last accepted hash,
69-
or the whole list when Arc has moved. Commit uses `auto_run: true`, which
69+
or the whole list when Arc has moved. A replace with no page phrases and no
70+
focus is not sent, so an empty site does not clear the Arc list. Commit uses `auto_run: true`, which
7071
queues the SEO report. Turning the checkbox off clears the WordPress list
7172
and leaves the Arc target in place.
7273

‎docs/releases/v0.6.1.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
WordPress plugin that connects a site to Pendulum Arc. An empty keyphrase list no longer replaces Arc for v0.6.1.
2+
3+
**Min version support:**
4+
- WordPress **6.7**
5+
- PHP **8.1** with the sodium extension
6+
7+
**Requires:**
8+
- A Pendulum Arc account, and an API key or Arc sign-in
9+
10+
**Runtime support:**
11+
- WordPress 6.7 or newer
12+
13+
**Changes since v0.6.0:**
14+
- Sync keyphrases does not send a replace when this site has no focus phrase and no page phrases. Arc keeps the list it already has
15+
- A list that does have page phrases still replaces the Arc target
16+
17+
**Support us:**
18+
19+
If you find this useful, visit Pendulum:
20+
21+
[![Pendulum][Pendulum-shield]][Pendulum-url]
22+
23+
[Pendulum-shield]: https://img.shields.io/badge/pendulum-000000?style=for-the-badge&logo=data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmlld0JveD0iMCAwIDE2NSAxNjUiPjxkZWZzPjxsaW5lYXJHcmFkaWVudCBpZD0ibGluZWFyLWdyYWRpZW50IiB4MT0iMCIgeTE9IjgzLjUiIHgyPSIxNjEuMzkiIHkyPSI4My41IiBncmFkaWVudFRyYW5zZm9ybT0idHJhbnNsYXRlKDAgMTY2KSBzY2FsZSgxIC0xKSIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPjxzdG9wIG9mZnNldD0iMCIgc3RvcC1jb2xvcj0iIzMyYjdkNiIvPjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iI2Y0OTYzYyIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHdpZHRoPSIxNjUiIGhlaWdodD0iMTY1IiBzdHlsZT0iZmlsbDp1cmwoI2xpbmVhci1ncmFkaWVudCk7Ii8+PHBhdGggZD0iTTU0LjA4LDEzM2gtMjUuOThWMzMuMDNoNDEuMzZjMTEuMjIsMCwxOS44MiwyLjkyLDI1Ljc4LDguNzVzOC45NSwxNC4wNSw4Ljk1LDI0LjY2LTIuOTgsMTguODMtOC45NSwyNC42NmMtNS45Niw1LjgzLTE0LjU2LDguNzUtMjUuNzgsOC43NWgtMTUuMzhzMCwzMy4xNSwwLDMzLjE1Wk01NC4wOCw3OC45aDguNjJjOS41NCwwLDE0LjMyLTQuMTUsMTQuMzItMTIuNDZzLTQuNzctMTIuNDYtMTQuMzItMTIuNDZoLTguNjJ2MjQuOTNoMFpNMTQzLjEsMzNsLTI2LjExLDEwMGgtMjVsMjYuMTEtMTAwaDI1WiIgc3R5bGU9ImZpbGw6I2ZmZjsiLz48L3N2Zz4=
24+
[Pendulum-url]: https://pendulumdev.co.uk/

‎package-lock.json‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "arc-wordpress",
3-
"version": "0.6.0",
3+
"version": "0.6.1",
44
"private": true,
55
"description": "Connect a WordPress site to a Pendulum Arc account.",
66
"author": "Pendulum Development Ltd",

‎pendulum-arc/includes/class-keyphrase-push.php‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,17 @@ public static function plan( ?string $acked_hash, string $arc_hash, string $focu
6767
);
6868
}
6969

70+
/**
71+
* A replace with no pages and no focus must not be sent. Arc keeps its list.
72+
*
73+
* @param array{mode: string, upserts: array<int, mixed>, focus: string|null} $plan Push plan.
74+
*/
75+
public static function vacant( array $plan ): bool {
76+
return 'replace' === $plan['mode']
77+
&& array() === $plan['upserts']
78+
&& null === $plan['focus'];
79+
}
80+
7081
/**
7182
* @param array<int, array{path: string, focusKeyphrase: string}> $upserts Upserts.
7283
* @param array<int, string> $deletes Paths to delete.

‎pendulum-arc/includes/class-keyphrase-sync.php‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,12 @@ function ( string $env, string $token, string $site_id ) {
260260
);
261261
$arc_hash = (string) ( $remote['hash'] ?? '' );
262262
$plan = Keyphrase_Push::plan( $state['acked_hash'], $arc_hash, $state['focus'], $state['focus_synced'], $this->list->rows() );
263+
if ( Keyphrase_Push::vacant( $plan ) ) {
264+
return array(
265+
'ok' => true,
266+
'message' => __( 'This site has no keyphrases to send. Arc was left unchanged.', 'pendulum-arc' ),
267+
);
268+
}
263269
if ( '' !== $state['sync_id'] ) {
264270
$this->abandon( $state['sync_id'] );
265271
}

‎pendulum-arc/pendulum-arc.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Arc Analytics
44
* Plugin URI: https://github.com/pendulumdev/arc-wordpress
55
* Description: Connect this site to a Pendulum Arc account.
6-
* Version: 0.6.0
6+
* Version: 0.6.1
77
* Requires at least: 6.7
88
* Requires PHP: 8.1
99
* Author: Pendulum
@@ -21,7 +21,7 @@
2121
exit;
2222
}
2323

24-
define( 'ARC_WORDPRESS_VERSION', '0.6.0' );
24+
define( 'ARC_WORDPRESS_VERSION', '0.6.1' );
2525
define( 'ARC_WORDPRESS_FILE', __FILE__ );
2626
define( 'ARC_WORDPRESS_DIR', plugin_dir_path( __FILE__ ) );
2727

‎pendulum-arc/readme.txt‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: seo, analytics
44
Requires at least: 6.7
55
Tested up to: 7.1
66
Requires PHP: 8.1
7-
Stable tag: 0.6.0
7+
Stable tag: 0.6.1
88
License: GPLv2 or later
99
License URI: https://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -20,7 +20,7 @@ An API key pairs the site when Arc already has this address. When it does not, y
2020

2121
On Settings, Invite sends project invites to WordPress administrators who are not already on the Arc project.
2222

23-
Sync keyphrases, on the Settings page, reads focus keyphrases already stored by Yoast, Rank Math, SEOPress, and All in One SEO. When that list differs from Arc, a notice appears at the top of Arc screens and the Arc menu shows a count of 1. Sync with Arc sends that list to Arc and queues the SEO report. Turning the checkbox off clears the list in WordPress and leaves the Arc target as it is.
23+
Sync keyphrases, on the Settings page, reads focus keyphrases already stored by Yoast, Rank Math, SEOPress, and All in One SEO. When that list differs from Arc, a notice appears at the top of Arc screens and the Arc menu shows a count of 1. Sync with Arc sends that list to Arc and queues the SEO report. An empty list is not sent, so Arc keeps the phrases it already has. Turning the checkbox off clears the list in WordPress and leaves the Arc target as it is.
2424

2525
GDPR Consent, under the Arc menu, is a cookie banner for this site. It does not call Arc, and it is available before the site is paired. Optional cookies, and scripts listed on them, stay off until a visitor accepts them. Decline refuses every optional cookie. Consent logging is off until you turn it on. A static banner is printed at the end of the theme header or footer. A fixed banner is positioned on the screen. Disable, on the Behaviour tab, turns the banner off and leaves script tags unchanged.
2626

@@ -69,6 +69,10 @@ When the GitHub repository is public and a release is newer than this install, W
6969

7070
== Changelog ==
7171

72+
= 0.6.1 =
73+
* Sync keyphrases does not send a replace when this site has no focus phrase and no page phrases. Arc keeps the list it already has.
74+
* A list that does have page phrases still replaces the Arc target.
75+
7276
= 0.6.0 =
7377
* The Arc Analytics screen shows the paired site's latest Analytics, SEO, A11Y, AI, Security, and Brand report.
7478
* SEO, accessibility, and AI page rows open that page's issues. The list scrolls down.

‎tests/unit/KeyphraseTest.php‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,31 @@ public function test_a_different_arc_hash_replaces_the_whole_list(): void {
227227
self::assertCount( 1, $plan['upserts'] );
228228
}
229229

230+
public function test_an_empty_replace_is_vacant(): void {
231+
$plan = Keyphrase_Push::plan( 'old', 'moved', '', '', array() );
232+
self::assertSame( 'replace', $plan['mode'] );
233+
self::assertSame( array(), $plan['upserts'] );
234+
self::assertNull( $plan['focus'] );
235+
self::assertTrue( Keyphrase_Push::vacant( $plan ) );
236+
237+
$pages = Keyphrase_Push::plan(
238+
'old',
239+
'moved',
240+
'',
241+
'',
242+
array(
243+
array(
244+
'path' => '/about',
245+
'phrase' => 'about',
246+
'synced_phrase' => '',
247+
'deleted' => false,
248+
),
249+
)
250+
);
251+
self::assertFalse( Keyphrase_Push::vacant( $pages ) );
252+
self::assertCount( 1, $pages['upserts'] );
253+
}
254+
230255
public function test_only_the_keyphrase_alert_counts(): void {
231256
self::assertFalse( Page_Alerts::keyphrase_pending( true, false, true, 'home', '', true, false ) );
232257
self::assertFalse( Page_Alerts::keyphrase_pending( true, true, false, 'home', '', true, false ) );

0 commit comments

Comments
 (0)