Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.
TypeScript aeoai-agentai-searchanswer-engine-optimizationbrand-monitoringchatgptclaudecopilotdockergeminigeogoogle-ai-overviewsgrokmcpnextjsopen-sourceperplexityseosupabasetypescript
feat(cms): send pages to WordPress from Send to CMS (#1331) (#1572)
Cihan33fba088aab1
diff --git a/web/messages/en.json b/web/messages/en.jsonindex 67dff79a0..f77f5b035 100644--- a/web/messages/en.json+++ b/web/messages/en.json@@ -3978,6 +3978,12 @@"sent": "In Webflow as a draft item since {when}","failed": "The last send to Webflow failed, {when}","published": "Published {when}"+ },+ "wordpress": {+ "queued": "Sending to WordPress since {when}",+ "sent": "In WordPress as a draft post since {when}",+ "failed": "The last send to WordPress failed, {when}",+ "published": "Published {when}"}},"bulk": {@@ -3990,6 +3996,7 @@"title": "{count, plural, one {Send # page to your CMS} other {Send # pages to your CMS}}","description": "Each page goes to the brand's webhook as it is ready to publish, with the slug and meta of its last send, else the page's. Open a page in the editor to change them.","descriptionWebflow": "Each page goes to {collection} in Webflow as a draft item, as it is ready to publish, with the slug and meta of its last send, else the page's. Open a page in the editor to change them.",+ "descriptionWordPress": "Each page goes to {site} in WordPress as a draft post, as it is ready to publish, with the slug and meta description (as its excerpt) of its last send, else the page's. Open a page in the editor to change them. A page whose post is already published or scheduled goes as a new draft post. The meta title and JSON-LD aren't sent: set them in your SEO plugin.","readFailed": "Couldn't read the pages. Try again.","retry": "Try again","notFound": "A page was archived or deleted since you picked it. Close this, pick the pages again and send.",@@ -4020,6 +4027,7 @@"closedUnsent": "{count, plural, one {# page wasn't sent} other {# pages weren't sent}}: the dialog closed while the pages before {count, plural, one {it} other {them}} were still going. Send {count, plural, one {it} other {them}} again from the Library.","skipped": "{count, plural, one {# page wasn't sent} other {# pages weren't sent}}: the workspace has sent 200 pages in the last 24 hours. Try again later.","inProgress": "A page is already on its way to Webflow. Wait for it, then send again.",+ "inProgressWordPress": "A page is already on its way to WordPress. Wait for it, then send again.","close": "Close","cancel": "Cancel","send": "{count, plural, one {Send # page} other {Send # pages}}",@@ -5112,10 +5120,11 @@},"send": {"button": "Send to CMS",- "hint": "Send the page to your CMS: Webflow, or your workflow through the brand's webhook",+ "hint": "Send the page to your CMS: Webflow, WordPress, or your workflow through the brand's webhook","title": "Send to CMS","description": "The page goes to the brand's webhook, for your workflow tool (Zapier, Make, n8n) to publish it in your CMS.","descriptionWebflow": "The page goes to {collection} in Webflow as a draft item, with its slug and meta. You publish it in Webflow.",+ "descriptionWordPress": "The page goes to {site} in WordPress as a draft post, with its slug, and its meta description as the excerpt. The meta title isn't sent: set it in your SEO plugin. You publish it in WordPress.","descriptionReading": "The page goes to your CMS with its slug and meta, kept on the page.","target": {"label": "Send to",@@ -5125,11 +5134,17 @@"collection": "your collection","notReady": "Not ready: connect it again or pick its collection in Settings › Integrations"},+ "wordpress": {+ "title": "WordPress",+ "hint": "A draft post on {site}",+ "notReady": "Sign-in refused: connect WordPress again in Settings › Integrations"+ },"webhook": {"title": "Your workflow","hint": "The brand's webhook (Zapier, Make, n8n)"},"unchecked": "Couldn't check Webflow just now, so this send goes to your workflow.",+ "uncheckedWordPress": "Couldn't check WordPress just now, so this send goes to your workflow.","retry": "Try again"},"placeholders": "{count, plural, one {# placeholder is} other {# placeholders are}} still open. Fill {count, plural, one {it} other {them}} first: none goes to your CMS.",@@ -5165,6 +5180,12 @@"failed": "The last send to Webflow failed, {when}.","published": "Published {when}."},+ "lastWordPress": {+ "queued": "Last sent to WordPress {when}, still on its way.",+ "sent": "In WordPress as a draft post since {when}.",+ "failed": "The last send to WordPress failed, {when}.",+ "published": "Published {when}."+ },"errors": {"no_webhook": "This brand has no webhook yet. Set one up in Webhook Settings on Content Opportunities.","webhook_not_subscribed": "The brand's webhook doesn't receive \"Content page sent\". Turn it on in Webhook Settings on Content Opportunities.",@@ -5183,7 +5204,13 @@"webflow_refused": "Webflow refused the brand's site token. Connect it again in Settings › Integrations.","webflow_not_ready": "Pick the Webflow collection pages go to in Settings › Integrations.","in_progress": "This page is already on its way to Webflow. Wait for it, then send again.",- "no_webhookWebflow": "This brand's Webflow isn't ready, and it has no webhook. Connect Webflow again or pick its collection in Settings › Integrations."+ "no_webhookWebflow": "This brand's Webflow isn't ready, and it has no webhook. Connect Webflow again or pick its collection in Settings › Integrations.",+ "wordpressFailed": "WordPress didn't take the page: {reason}",+ "wordpress_not_configured": "WordPress isn't set up on this server. Send to your workflow instead.",+ "no_wordpress": "Connect WordPress in Settings › Integrations first.",+ "wordpress_refused": "WordPress refused the sign-in. Connect it again in Settings › Integrations.",+ "in_progressWordPress": "This page is already on its way to WordPress. Wait for it, then send again.",+ "no_webhookWordPress": "This brand's WordPress refused the sign-in, and it has no webhook. Connect WordPress again in Settings › Integrations."},"cancel": "Cancel","send": "Send",@@ -5191,7 +5218,11 @@"sent": "Sent to your CMS","sentWebflow": "Sent to Webflow as a draft item","sentWebflowUpdated": "Updated in Webflow",- "webflowChanged": "{tables, plural, =0 {} one {# table went as a list. } other {# tables went as lists. }}{images, plural, =0 {} one {# image wasn't sent: add it in Webflow.} other {# images weren't sent: add them in Webflow.}}"+ "webflowChanged": "{tables, plural, =0 {} one {# table went as a list. } other {# tables went as lists. }}{images, plural, =0 {} one {# image wasn't sent: add it in Webflow.} other {# images weren't sent: add them in Webflow.}}",+ "sentWordPress": "Sent to WordPress as a draft post",+ "sentWordPressUpdated": "Draft post updated in WordPress",+ "wordpressLive": "Its post was already published or scheduled, so the page went as a new draft. Move the text over in WordPress; published as it is, its slug gets \"-2\".",+ "wordpressJsonLd": "JSON-LD left out: add schema with your SEO plugin."},"rulesChip": "Rules {met}/{total}","rulesChipReading": "Rules · reading",diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsxindex 73b7f621c..d661c348f 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx@@ -203,6 +203,10 @@ vi.mock('@/lib/content/cms-send-client', () => ({ readDraftCms, sendPagesToCms }vi.mock('@/lib/webflow-client', () => ({readWebflow: async () => ({ ok: true, configured: false, connection: null }),}));+// Nor its WordPress site (00294).+vi.mock('@/lib/wordpress-client', () => ({+ readWordPress: async () => ({ ok: true, configured: false, connection: null }),+}));(globalThis as typeof globalThis & {diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/library/_bulk-send-dialog.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/library/_bulk-send-dialog.test.tsxindex 5d83569fe..4b3fe20e0 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/library/_bulk-send-dialog.test.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/library/_bulk-send-dialog.test.tsx@@ -40,6 +40,26 @@ vi.mock('@/lib/webflow-client', () => ({: null,}),}));+// And its WordPress site (00294): none unless a test gives one.+const wordpress = vi.hoisted(() => ({ ready: false, refused: false, failed: false }));+vi.mock('@/lib/wordpress-client', () => ({+ readWordPress: async () => ({+ ok: !wordpress.failed,+ code: 'failed',+ configured: true,+ connection:+ wordpress.ready || wordpress.refused+ ? {+ status: wordpress.refused ? 'auth_failed' : 'connected',+ siteUrl: 'https://blog.acme.example',+ siteName: 'Acme Blog',+ account: 'ansvisor',+ connectedAt: '2026-10-26T10:00:00Z',+ updatedAt: '2026-10-26T10:00:00Z',+ }+ : null,+ }),+}));// One request a page, so a test can refuse the second.const oneByOne = vi.hoisted(() => ({ on: false }));vi.mock('@/lib/content/cms-send', async (importOriginal) => {@@ -111,6 +131,7 @@ const lines = () => [...dialog().querySelectorAll('li')].map((li) => li.textContbeforeEach(() => {oneByOne.on = false;Object.assign(webflow, { ready: false, refused: false, failed: false });+ Object.assign(wordpress, { ready: false, refused: false, failed: false });// The send target remembered per brand, in this browser.const kept = new Map<string, string>();vi.stubGlobal('localStorage', {@@ -268,6 +289,108 @@ describe('BulkSendDialog', () => {);});+ it('sends the pages to the brand’s WordPress site as draft posts', async () => {+ vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout', 'Date'] });+ wordpress.ready = true;+ sendPagesToCms.mockResolvedValue({+ ok: true,+ skipped: 0,+ deliveries: [+ { id: 'x1', draftId: 'd1', status: 'queued' },+ { id: 'x3', draftId: 'd3', status: 'queued' },+ ],+ });+ readDeliveries.mockResolvedValue([+ { id: 'x1', draftId: 'd1', status: 'sent', http_status: null, error: null },+ { id: 'x3', draftId: 'd3', status: 'sent', http_status: null, error: null },+ ]);+ await render();+ expect(dialog().textContent).toContain(+ 'Each page goes to Acme Blog in WordPress as a draft post, as it is ready to publish',+ );+ expect(dialog().textContent).toContain(+ "A page whose post is already published or scheduled goes as a new draft post. The meta title and JSON-LD aren't sent: set them in your SEO plugin.",+ );+ const radios = [...dialog().querySelectorAll('[role="radio"]')];+ expect(radios.map((r) => r.textContent)).toEqual([+ 'WordPressA draft post on Acme Blog',+ "Your workflowThe brand's webhook (Zapier, Make, n8n)",+ ]);+ expect(radios[0].getAttribute('aria-checked')).toBe('true');+ await act(async () => button('Send 2 pages').click());+ expect(sendPagesToCms.mock.calls[0]?.[2]).toBe('wordpress');+ expect(localStorage.getItem('aeo:cms-target:brand-1')).toBe('wordpress');+ await act(async () => void (await vi.advanceTimersByTimeAsync(2_000)));+ expect(dialog().querySelector('[role="status"]')!.textContent).toBe('2 pages sent.');+ });++ it('offers all three with Webflow and WordPress, starting from the remembered WordPress', async () => {+ webflow.ready = true;+ wordpress.ready = true;+ localStorage.setItem('aeo:cms-target:brand-1', 'wordpress');+ sendPagesToCms.mockResolvedValue({ ok: false, code: 'in_progress', field: null });+ await render();+ const radios = [...dialog().querySelectorAll('[role="radio"]')];+ expect(radios.map((r) => r.querySelector('span')?.textContent)).toEqual([+ 'Webflow',+ 'WordPress',+ 'Your workflow',+ ]);+ expect(radios.map((r) => r.getAttribute('aria-checked'))).toEqual(['false', 'true', 'false']);+ await act(async () => button('Send 2 pages').click());+ expect(sendPagesToCms.mock.calls[0]?.[2]).toBe('wordpress');+ expect(dialog().querySelector('[role="alert"]')!.textContent).toBe(+ 'A page is already on its way to WordPress. Wait for it, then send again.',+ );+ });++ it('says WordPress refused the sign-in when the brand has no webhook either', async () => {+ wordpress.refused = true;+ sendPagesToCms.mockResolvedValue({ ok: false, code: 'no_webhook', field: null });+ await render();+ const choice = [...dialog().querySelectorAll<HTMLButtonElement>('[role="radio"]')][0];+ expect(choice.disabled).toBe(true);+ expect(choice.textContent).toContain('Sign-in refused');+ await act(async () => button('Send 2 pages').click());+ expect(sendPagesToCms.mock.calls[0]?.[2]).toBe('webhook');+ expect(dialog().querySelector('[role="alert"]')!.textContent).toBe(+ "This brand's WordPress refused the sign-in, and it has no webhook. Connect WordPress again in Settings › Integrations.",+ );+ });++ it('says only that the webhook is missing when a CMS is ready to pick instead', async () => {+ webflow.refused = true;+ wordpress.ready = true;+ localStorage.setItem('aeo:cms-target:brand-1', 'webhook');+ sendPagesToCms.mockResolvedValue({ ok: false, code: 'no_webhook', field: null });+ await render();+ await act(async () => button('Send 2 pages').click());+ expect(sendPagesToCms.mock.calls[0]?.[2]).toBe('webhook');+ expect(dialog().querySelector('[role="alert"]')!.textContent).toBe(+ 'This brand has no webhook yet. Set one up in Webhook Settings on Content Opportunities.',+ );+ });++ it('sends to the webhook when WordPress can’t be read, saying so to a person who sent there', async () => {+ wordpress.failed = true;+ localStorage.setItem('aeo:cms-target:brand-1', 'wordpress');+ sendPagesToCms.mockResolvedValue({+ ok: true,+ skipped: 0,+ deliveries: [+ { id: 'x1', draftId: 'd1', status: 'sent' },+ { id: 'x3', draftId: 'd3', status: 'sent' },+ ],+ });+ await render();+ expect(dialog().querySelector('[role="radio"]')).toBeNull();+ expect(dialog().querySelector('[role="status"]')!.textContent).toContain(+ "Couldn't check WordPress just now, so this send goes to your workflow.",+ );+ await act(async () => button('Send 2 pages').click());+ expect(sendPagesToCms.mock.calls[0]?.[2]).toBe('webhook');+ });+it('says why nothing went, and keeps the pages to send again', async () => {sendPagesToCms.mockResolvedValue({ ok: false, code: 'webhook_not_subscribed', field: null });await render();diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/library/_bulk-send-dialog.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/library/_bulk-send-dialog.tsxindex 129b781e8..fdbe54b5c 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/library/_bulk-send-dialog.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/library/_bulk-send-dialog.tsx@@ -21,6 +21,7 @@ import {sendPagesToCms,type CmsDelivery,type CmsSendError,+ type CmsTarget,} from '@/lib/content/cms-send-client';import type { ContentDraftListItem } from '@/lib/content/drafts';import { CmsTargetPicker, CmsTargetUnchecked, useCmsTarget } from '@/components/content/cms-target';@@ -66,6 +67,8 @@ interface Refusal {code: CmsSendError;field: string | null;title: string | null;+ /** Where the pages were going. */+ target: CmsTarget;}type Phase =@@ -114,6 +117,7 @@ export function BulkSendDialog({const [attempt, setAttempt] = useState(0);const {webflow,+ wordpress,target,pick,sent: keepTarget,@@ -124,6 +128,7 @@ export function BulkSendDialog({const collection = webflow?.ready? webflow.collection || tEditor('send.target.webflow.collection'): '';+ const site = wordpress?.ready ? wordpress.site : '';useEffect(() => {let cancelled = false;@@ -233,6 +238,7 @@ export function BulkSendDialog({code: result.code,field: result.field,title: Number.isInteger(index) ? (group[index]?.title ?? null) : null,+ target,};notSent += group.length;continue;@@ -293,7 +299,7 @@ export function BulkSendDialog({);};- const failureText = ({ code, field, title }: Refusal) => {+ const failureText = ({ code, field, title, target: to }: Refusal) => {if (code === 'session' || code === 'workspace' || code === 'busy' || code === 'subscription') {return tFailure(code);}@@ -306,10 +312,11 @@ export function BulkSendDialog({: tEditor('send.errors.invalidField', { field: named });}// No page named: any of them may be the one on its way.- if (code === 'in_progress') return t('inProgress');- // Webflow not ready sent the pages to the webhook: what to fix is Webflow.- if (code === 'no_webhook' && webflow && !webflow.ready) {- return tEditor('send.errors.no_webhookWebflow');+ if (code === 'in_progress') return t(to === 'wordpress' ? 'inProgressWordPress' : 'inProgress');+ // No CMS ready sent the pages to the webhook: what to fix is the one connected.+ if (code === 'no_webhook' && !webflow?.ready && !wordpress?.ready) {+ if (webflow) return tEditor('send.errors.no_webhookWebflow');+ if (wordpress) return tEditor('send.errors.no_webhookWordPress');}return tEditor(`send.errors.${code}`);};@@ -335,15 +342,18 @@ export function BulkSendDialog({? tEditor('send.descriptionReading'): target === 'webflow'? t('descriptionWebflow', { collection })- : t('description')}+ : target === 'wordpress'+ ? t('descriptionWordPress', { site })+ : t('description')}</DialogDescription></DialogHeader>- {/* Where the pages go, before they go: Webflow once Settings has it ready. */}- {webflow && target && !after && (+ {/* Where the pages go, before they go: Webflow or WordPress once Settings has it ready. */}+ {(webflow || wordpress) && target && !after && (<CmsTargetPickervalue={target}webflow={webflow}+ wordpress={wordpress}disabled={phase.kind === 'sending'}onChange={(next) => {pick(next);@@ -353,6 +363,7 @@ export function BulkSendDialog({)}{targetUnchecked && !after && (<CmsTargetUnchecked+ target={targetUnchecked}reading={targetReading}onRetry={retryTarget}disabled={phase.kind === 'sending'}diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/library/_library-table.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/library/_library-table.tsxindex 6bff35415..897cd4f26 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/library/_library-table.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/library/_library-table.tsx@@ -387,10 +387,13 @@ function CmsStatusMark({ status }: { status: CmsStatus }) {const format = useFormatter();const when = format.dateTime(new Date(status.at), { dateStyle: 'medium', timeStyle: 'short' });const live = status.status === 'published' ? status.publishedUrl : null;- // A Webflow send (#1331, phase 2) says so: sent, it's a draft item there.- const label = t(status.target === 'webflow' ? `webflow.${status.status}` : status.status, {- when,- });+ // A Webflow or WordPress send (#1331, phase 2) says so: sent, it's a draft item or post there.+ const label = t(+ status.target === 'webflow' || status.target === 'wordpress'+ ? `${status.target}.${status.status}`+ : status.status,+ { when },+ );const icon = {queued: <Clock className="h-3.5 w-3.5" />,sent: <Send className="h-3.5 w-3.5" />,diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.test.tsxindex 70ac597ad..16d22e8cd 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.test.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.test.tsx@@ -49,6 +49,7 @@ const readCmsStatuses = vi.hoisted(() => vi.fn());const readDraftCms = vi.hoisted(() => vi.fn());const sendPagesToCms = vi.hoisted(() => vi.fn());const refreshWebflowPublished = vi.hoisted(() => vi.fn());+const refreshWordPressPublished = vi.hoisted(() => vi.fn());// Mark published (CE-013).const publishPage = vi.hoisted(() => vi.fn());const readPublishAddress = vi.hoisted(() => vi.fn());@@ -56,6 +57,7 @@ vi.mock('@/lib/content/publish-client', () => ({ publishPage, readPublishAddressvi.mock('@/lib/content/cms-send-client', () => ({readCmsStatuses,refreshWebflowPublished,+ refreshWordPressPublished,readDraftCms,sendPagesToCms,readKeptFields: vi.fn(async () => new Map()),@@ -65,6 +67,10 @@ vi.mock('@/lib/content/cms-send-client', () => ({vi.mock('@/lib/webflow-client', () => ({readWebflow: async () => ({ ok: true, configured: false, connection: null }),}));+// Nor its WordPress site (00294).+vi.mock('@/lib/wordpress-client', () => ({+ readWordPress: async () => ({ ok: true, configured: false, connection: null }),+}));vi.mock('@/lib/actions/content-authors', () => ({ getContentAuthors: vi.fn(async () => null) }));// The workspace's plan: active unless a test says it's read-only.const gate = vi.hoisted(() => ({ isLocked: false, openUpgrade: vi.fn() }));@@ -163,6 +169,7 @@ beforeEach(() => {root = createRoot(container);getContentDrafts.mockReset();refreshWebflowPublished.mockReset().mockResolvedValue([]);+ refreshWordPressPublished.mockReset().mockResolvedValue([]);readPublishAddress.mockReset().mockResolvedValue('https://acme.example/pipeline-forecasting');publishPage.mockReset().mockResolvedValue({ok: true,@@ -576,34 +583,90 @@ describe('Send to CMS from a Library row (#1331)', () => {expect(refreshWebflowPublished).toHaveBeenCalledTimes(1);});- it('doesn’t ask Webflow by itself while the workspace is read-only', async () => {+ it('doesn’t ask Webflow or WordPress by itself while the workspace is read-only', async () => {gate.isLocked = true;- getContentDrafts.mockResolvedValue([row({})]);+ getContentDrafts.mockResolvedValue([row({}), row({ id: 'd2', title: 'Churn' })]);+ const sent = (target: string) => ({+ status: 'sent',+ target,+ at: '2026-10-24T10:00:00Z',+ httpStatus: null,+ error: null,+ publishedUrl: null,+ });readCmsStatuses.mockResolvedValue(new Map([- [- 'd1',- {- status: 'sent',- target: 'webflow',- at: '2026-10-24T10:00:00Z',- httpStatus: null,- error: null,- publishedUrl: null,- },- ],+ ['d1', sent('webflow')],+ ['d2', sent('wordpress')],]),);await renderPage();// What is stored is listed; nothing is asked of the API.expect(container.textContent).toContain('Pipeline forecasting');expect(refreshWebflowPublished).not.toHaveBeenCalled();+ expect(refreshWordPressPublished).not.toHaveBeenCalled();});it('doesn’t ask Webflow for a brand with no page there', async () => {getContentDrafts.mockResolvedValue([row({})]);await renderPage();expect(refreshWebflowPublished).not.toHaveBeenCalled();+ expect(refreshWordPressPublished).not.toHaveBeenCalled();+ });++ it('says a page sent to WordPress is a draft post there, and asks WordPress once', async () => {+ getContentDrafts.mockResolvedValue([row({}), row({ id: 'd2', title: 'Churn' })]);+ const sent = (target: string) => ({+ status: 'sent',+ target,+ at: '2026-10-24T10:00:00Z',+ httpStatus: null,+ error: null,+ publishedUrl: null,+ });+ readCmsStatuses.mockResolvedValue(+ new Map([+ ['d1', sent('wordpress')],+ ['d2', sent('wordpress')],+ ]),+ );+ refreshWordPressPublished.mockResolvedValue(['d1']);+ await renderPage();+ await act(async () => {});+ expect(+ container.querySelectorAll('[aria-label^="In WordPress as a draft post since Oct 24, 2026"]'),+ ).toHaveLength(2);+ // WordPress says when a post goes live: asked once, the list read again as it marked one.+ expect(refreshWordPressPublished).toHaveBeenCalledTimes(1);+ expect(refreshWordPressPublished).toHaveBeenCalledWith('brand-1');+ expect(getContentDrafts).toHaveBeenCalledTimes(2);+ expect(refreshWebflowPublished).not.toHaveBeenCalled();+ });++ it('asks Webflow and WordPress once each when pages went to both', async () => {+ getContentDrafts.mockResolvedValue([row({}), row({ id: 'd2', title: 'Churn' })]);+ const sent = (target: string) => ({+ status: 'sent',+ target,+ at: '2026-10-24T10:00:00Z',+ httpStatus: null,+ error: null,+ publishedUrl: null,+ });+ readCmsStatuses.mockResolvedValue(+ new Map([+ ['d1', sent('webflow')],+ ['d2', sent('wordpress')],+ ]),+ );+ refreshWebflowPublished.mockResolvedValue(['d1']);+ refreshWordPressPublished.mockResolvedValue(['d2']);+ await renderPage();+ await act(async () => {});+ expect(refreshWebflowPublished).toHaveBeenCalledTimes(1);+ expect(refreshWordPressPublished).toHaveBeenCalledTimes(1);+ expect(refreshWebflowPublished).toHaveBeenCalledWith('brand-1');+ expect(refreshWordPressPublished).toHaveBeenCalledWith('brand-1');});it('says the workflow’s reason for a page its webhook took that then failed', async () => {diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.tsxindex 4b1fd60a9..651beee6f 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.tsx@@ -40,6 +40,7 @@ import { CMS_PAGES_PER_SEND, type CmsSource } from '@/lib/content/cms-send';import {readCmsStatuses,refreshWebflowPublished,+ refreshWordPressPublished,type CmsStatus,} from '@/lib/content/cms-send-client';import {@@ -209,13 +210,16 @@ export default function ContentLibraryPage() {return () => clearTimeout(timer);}, [cmsGoing, cms]);- // Pages in Webflow as draft items: Webflow says when one goes live, so the- // API reads them once as the Library opens for the brand (and daily); the- // list is read again when it marked any published.- const inWebflow = [...cms.values()].some(- (status) => status.target === 'webflow' && status.status === 'sent',- );+ // Pages in Webflow as draft items, or in WordPress as draft posts: the CMS+ // says when one goes live, so the API reads them once as the Library opens+ // for the brand (and daily); the list is read again when it marked any+ // published.+ const sentTo = (target: CmsStatus['target']) =>+ [...cms.values()].some((status) => status.target === target && status.status === 'sent');+ const inWebflow = sentTo('webflow');+ const inWordPress = sentTo('wordpress');const webflowRead = useRef(new Set<string>());+ const wordpressRead = useRef(new Set<string>());useEffect(() => {if (isLocked || !inWebflow || !activeBrandId || webflowRead.current.has(activeBrandId)) return;webflowRead.current.add(activeBrandId);@@ -225,6 +229,16 @@ export default function ContentLibraryPage() {if (published.length) setAttempt((n) => n + 1);});}, [isLocked, inWebflow, activeBrandId]);+ useEffect(() => {+ if (isLocked || !inWordPress || !activeBrandId || wordpressRead.current.has(activeBrandId)) {+ return;+ }+ wordpressRead.current.add(activeBrandId);+ // As Webflow's: not cancelled with the effect.+ void refreshWordPressPublished(activeBrandId).then((published) => {+ if (published.length) setAttempt((n) => n + 1);+ });+ }, [isLocked, inWordPress, activeBrandId]);const reload = () => setAttempt((n) => n + 1);const titleOf = (draft: ContentDraftListItem) => draft.title.trim() || t('untitled');diff --git a/web/src/components/content/cms-target.tsx b/web/src/components/content/cms-target.tsxindex 55af3b7fd..3fc108c8c 100644--- a/web/src/components/content/cms-target.tsx+++ b/web/src/components/content/cms-target.tsx@@ -7,26 +7,33 @@ import { LoadingDots } from '@/components/ui/loading-dots';import { cn } from '@/lib/utils';import type { CmsTarget } from '@/lib/content/cms-send-client';import { readWebflow } from '@/lib/webflow-client';+import { readWordPress } from '@/lib/wordpress-client';/**- * Where Send to CMS sends (#1331, phase 2): the brand's webhook, or its+ * Where Send to CMS sends (#1331, phase 2): the brand's webhook, its* Webflow collection once Settings › Integrations has it ready (connected,- * a collection with a body field). The choice, picked or sent to, is- * remembered per brand, in this browser; Webflow is the first choice where- * it's ready. A brand with- * Webflow connected but not ready sees it, off, so its pages don't go to- * the webhook unnoticed. A read that fails (or an API without Webflow)- * leaves the webhook as it was before Webflow: a webhook send doesn't need- * Webflow, and a person who picked Webflow before is told it couldn't be- * checked.+ * a collection with a body field), or its WordPress site once connected+ * (00294; no collection or fields to pick there). The choice, picked or+ * sent to, is remembered per brand, in this browser; the first ready of+ * Webflow and WordPress is the first choice where none is remembered, or+ * the remembered one is no longer connected. One remembered and connected+ * but not ready leaves the webhook, as before: the page never goes to+ * another CMS than the one picked. A brand with one connected but not ready+ * sees it, off, so its pages don't go to the webhook unnoticed. A read that+ * fails (or an API without them)+ * leaves the webhook as it was before: a webhook send doesn't need them,+ * and a person who picked the one that couldn't be read is told so.*/+/** The targets a brand connects in Settings › Integrations. */+type CmsLocal = Exclude<CmsTarget, 'webhook'>;+const storageKey = (brandId: string) => `aeo:cms-target:${brandId}`;function remembered(brandId: string): CmsTarget | null {try {const value = localStorage.getItem(storageKey(brandId));- return value === 'webhook' || value === 'webflow' ? value : null;+ return value === 'webhook' || value === 'webflow' || value === 'wordpress' ? value : null;} catch {return null;}@@ -49,16 +56,44 @@ export type CmsWebflow =/** Not connected, not set up on this server, or not read: the webhook only. */| null;+/** The brand's WordPress, as Send to CMS reads it. */+export type CmsWordPress =+ /** Ready: pages go to this site as draft posts (its name, else its address). */+ | { ready: true; site: string }+ /** Connected, but its sign-in refused. */+ | { ready: false }+ /** Not connected, not set up on this server, or not read. */+ | null;++function webflowOf(result: Awaited<ReturnType<typeof readWebflow>>): CmsWebflow {+ const connection = result.ok && result.configured ? result.connection : null;+ if (!connection) return null;+ return connection.status === 'connected' && connection.collectionId && connection.fieldMap.body+ ? { ready: true, collection: connection.collectionName ?? '' }+ : { ready: false };+}++function wordpressOf(result: Awaited<ReturnType<typeof readWordPress>>): CmsWordPress {+ const connection = result.ok && result.configured ? result.connection : null;+ if (!connection) return null;+ return connection.status === 'connected'+ ? { ready: true, site: connection.siteName || connection.siteUrl }+ : { ready: false };+}+/**- * The brand's send target: undefined while its Webflow connection is read,- * then where pages go and how to change it. A failed read is the webhook;- * `unchecked` says so when the person picked Webflow before, with `retry`.+ * The brand's send target: undefined while its Webflow and WordPress+ * connections are read, then where pages go and how to change it. A failed+ * read leaves that one out; `unchecked` names it when the person picked it+ * before, and the page goes to the webhook, with `retry`.*/export function useCmsTarget(brandId: string) {const [read, setRead] = useState<{key: string;webflow: CmsWebflow;- failed: boolean;+ wordpress: CmsWordPress;+ /** The connections that couldn't be read. */+ failed: CmsLocal[];} | null>(null);const [attempt, setAttempt] = useState(0);const [picked, setPicked] = useState<{ brandId: string; target: CmsTarget } | null>(null);@@ -66,19 +101,17 @@ export function useCmsTarget(brandId: string) {useEffect(() => {let cancelled = false;- readWebflow(brandId).then((result) => {+ Promise.all([readWebflow(brandId), readWordPress(brandId)]).then(([webflow, wordpress]) => {if (cancelled) return;- if (!result.ok) {- setRead({ key, webflow: null, failed: true });- return;- }- const connection = result.configured ? result.connection : null;- const webflow: CmsWebflow = !connection- ? null- : connection.status === 'connected' && connection.collectionId && connection.fieldMap.body- ? { ready: true, collection: connection.collectionName ?? '' }- : { ready: false };- setRead({ key, webflow, failed: false });+ setRead({+ key,+ webflow: webflowOf(webflow),+ wordpress: wordpressOf(wordpress),+ failed: [+ ...(webflow.ok ? [] : ['webflow' as const]),+ ...(wordpress.ok ? [] : ['wordpress' as const]),+ ],+ });});return () => {cancelled = true;@@ -87,20 +120,39 @@ export function useCmsTarget(brandId: string) {const current = read?.key === key ? read : null;const webflow = current ? current.webflow : undefined;+ const wordpress = current ? current.wordpress : undefined;const chosen = picked?.brandId === brandId ? picked.target : remembered(brandId);- const target: CmsTarget | undefined =- webflow === undefined ? undefined : webflow?.ready ? (chosen ?? 'webflow') : 'webhook';// Read again after a failure: the note stays, as trying, until the answer.- const failed = current- ? current.failed- : (read?.failed ?? false) && read?.key.startsWith(`${brandId}:`) === true;+ const failed = current ? current.failed : read?.key.startsWith(`${brandId}:`) ? read.failed : [];+ const unchecked = chosen && chosen !== 'webhook' && failed.includes(chosen) ? chosen : null;+ const connectionOf = (to: CmsLocal) => (to === 'webflow' ? webflow : wordpress);+ // The choice stands while it's still connected; ready or not, it's never swapped for the other CMS.+ const kept = chosen && (chosen === 'webhook' || connectionOf(chosen)) ? chosen : null;+ const target: CmsTarget | undefined = !current+ ? undefined+ : unchecked+ ? 'webhook'+ : kept+ ? kept === 'webhook' || connectionOf(kept)?.ready+ ? kept+ : 'webhook'+ : webflow?.ready+ ? 'webflow'+ : wordpress?.ready+ ? 'wordpress'+ : 'webhook';return {/** The brand's Webflow; undefined while read; null without one, or when it couldn't be read. */webflow,+ /** The brand's WordPress, as `webflow`. */+ wordpress,target,- /** Couldn't be read, for a person who picked Webflow before: the page goes to the webhook. */- unchecked: failed && chosen === 'webflow',+ /**+ * The target the person picked before that couldn't be read: the page+ * goes to the webhook meanwhile. Null otherwise.+ */+ unchecked,/** Reading again, after a failure. */reading: current === null,retry: () => setAttempt((n) => n + 1),@@ -113,42 +165,72 @@ export function useCmsTarget(brandId: string) {};}-const TARGETS = ['webflow', 'webhook'] as const;+const TARGETS = ['webflow', 'wordpress', 'webhook'] as const;/**- * The two targets, when the brand has Webflow: the person picks where pages- * go. Webflow connected but not ready shows, off, with what to do. One tab- * stop, the picked card; the arrow keys move to the other and pick it,- * past Webflow while it's off.+ * The targets the brand has, when it has Webflow or WordPress: the person+ * picks where pages go. The webhook is always one; a CMS connected but not+ * ready shows, off, with what to do. One tab stop, the picked card; the+ * arrow keys move to the next one and pick it, past one that's off.*/export function CmsTargetPicker({value,webflow,+ wordpress,onChange,disabled,}: {value: CmsTarget;- webflow: NonNullable<CmsWebflow>;+ webflow: CmsWebflow | undefined;+ wordpress: CmsWordPress | undefined;onChange: (target: CmsTarget) => void;disabled?: boolean;}) {const t = useTranslations('contentEditor.editor.send.target');const cards = useRef<Partial<Record<CmsTarget, HTMLButtonElement | null>>>({});- const off = (target: CmsTarget) => disabled || (target === 'webflow' && !webflow.ready);+ const shown = TARGETS.filter(+ (target) => target === 'webhook' || (target === 'webflow' ? webflow : wordpress),+ );+ const off = (target: CmsTarget) =>+ disabled ||+ (target === 'webflow' && !webflow?.ready) ||+ (target === 'wordpress' && !wordpress?.ready);const onKey = (event: KeyboardEvent, i: number) => {const step = ({ ArrowRight: 1, ArrowDown: 1, ArrowLeft: -1, ArrowUp: -1 } as const)[event.key as 'ArrowRight'];if (!step) return;event.preventDefault();- const next = TARGETS[(i + step + TARGETS.length) % TARGETS.length];- if (off(next)) return;- onChange(next);- cards.current[next]?.focus();+ // The next card that's on, that way round; none past this one, none picked.+ for (let n = 1; n < shown.length; n++) {+ const next = shown[(((i + step * n) % shown.length) + shown.length) % shown.length];+ if (off(next)) continue;+ onChange(next);+ cards.current[next]?.focus();+ return;+ }+ };+ const hint = (target: (typeof TARGETS)[number]) => {+ if (target === 'webhook') return t('webhook.hint');+ if (target === 'webflow') {+ return webflow?.ready+ ? t('webflow.hint', { collection: webflow.collection || t('webflow.collection') })+ : t('webflow.notReady');+ }+ return wordpress?.ready+ ? t('wordpress.hint', { site: wordpress.site })+ : t('wordpress.notReady');};return (- <div role="radiogroup" aria-label={t('label')} className="grid grid-cols-2 gap-2">- {TARGETS.map((target, i) => (+ <div+ role="radiogroup"+ aria-label={t('label')}+ className={cn(+ 'grid gap-2',+ shown.length === 3 ? 'grid-cols-1 sm:grid-cols-3' : 'grid-cols-2',+ )}+ >+ {shown.map((target, i) => (<buttonkey={target}ref={(el) => void (cards.current[target] = el)}@@ -166,11 +248,7 @@ export function CmsTargetPicker({><span className="block text-sm font-medium">{t(`${target}.title`)}</span><span className="block text-xs text-muted-foreground [overflow-wrap:anywhere]">- {target === 'webhook'- ? t('webhook.hint')- : webflow.ready- ? t('webflow.hint', { collection: webflow.collection || t('webflow.collection') })- : t('webflow.notReady')}+ {hint(target)}</span></button>))}@@ -178,12 +256,18 @@ export function CmsTargetPicker({);}-/** Webflow couldn't be checked for a person who picked it before: the page goes to the webhook. */+/**+ * The CMS a person picked before couldn't be checked: the page goes to the+ * webhook.+ */export function CmsTargetUnchecked({+ target,reading,onRetry,disabled,}: {+ /** The one that couldn't be read. */+ target: CmsLocal;reading: boolean;onRetry: () => void;/** While sending: the target is fixed until the send is over. */@@ -195,7 +279,9 @@ export function CmsTargetUnchecked({role="status"className="flex flex-wrap items-center gap-x-3 gap-y-1.5 text-sm text-muted-foreground">- <span className="min-w-0 flex-1">{t('unchecked')}</span>+ <span className="min-w-0 flex-1">+ {t(target === 'wordpress' ? 'uncheckedWordPress' : 'unchecked')}+ </span><Buttonsize="sm"variant="outline"diff --git a/web/src/components/content/send-to-cms-dialog.test.tsx b/web/src/components/content/send-to-cms-dialog.test.tsxindex 6b8c66ae4..1b78720be 100644--- a/web/src/components/content/send-to-cms-dialog.test.tsx+++ b/web/src/components/content/send-to-cms-dialog.test.tsx@@ -14,6 +14,9 @@ vi.mock('@/lib/content/cms-send-client', () => ({ readDraftCms, sendPagesToCms }// The brand's Webflow connection (#1331, phase 2): none unless a test gives one.const readWebflow = vi.hoisted(() => vi.fn());vi.mock('@/lib/webflow-client', () => ({ readWebflow }));+// And its WordPress site (00294): none unless a test gives one.+const readWordPress = vi.hoisted(() => vi.fn());+vi.mock('@/lib/wordpress-client', () => ({ readWordPress }));const { SendDialog } = await import('./send-to-cms-dialog');@@ -75,6 +78,7 @@ beforeEach(() => {toast.success.mockReset();readDraftCms.mockReset().mockResolvedValue(neverSent);readWebflow.mockReset().mockResolvedValue({ ok: true, configured: false, connection: null });+ readWordPress.mockReset().mockResolvedValue({ ok: true, configured: true, connection: null });// The send target remembered per brand, in this browser.const kept = new Map<string, string>();vi.stubGlobal('localStorage', {@@ -536,4 +540,288 @@ describe('SendDialog', () => {);});});++ describe('to WordPress (#1331, phase 2)', () => {+ const connection = {+ status: 'connected',+ siteUrl: 'https://blog.acme.example',+ siteName: 'Acme Blog',+ account: 'ansvisor',+ connectedAt: '2026-10-26T10:00:00Z',+ updatedAt: '2026-10-26T10:00:00Z',+ };+ const ready = { ok: true, configured: true, connection };+ const refused = {+ ok: true,+ configured: true,+ connection: { ...connection, status: 'auth_failed' },+ };+ const webflowReady = {+ ok: true,+ configured: true,+ connection: {+ status: 'connected',+ siteId: 's1',+ siteName: 'Acme',+ collectionId: 'c1',+ collectionName: 'Blog Posts',+ fieldMap: { body: 'post-body' },+ connectedAt: '2026-10-25T10:00:00Z',+ updatedAt: '2026-10-25T10:00:00Z',+ },+ };+ const radios = () => [...dialog().querySelectorAll<HTMLButtonElement>('[role="radio"]')];+ const radio = (name: string) => radios().find((r) => r.textContent?.startsWith(name));+ const sentWith = (over: object) =>+ sendPagesToCms.mockResolvedValueOnce({+ ok: true,+ deliveries: [{ id: 'x1', draftId: 'd1', status: 'sent', ...over }],+ });++ it('sends to WordPress first when it’s the brand’s only CMS', async () => {+ readWordPress.mockResolvedValue(ready);+ await render();+ expect(readWordPress).toHaveBeenCalledWith('brand-1');+ expect(radios().map((r) => r.textContent)).toEqual([+ 'WordPressA draft post on Acme Blog',+ "Your workflowThe brand's webhook (Zapier, Make, n8n)",+ ]);+ expect(dialog().querySelector('[role="radiogroup"]')!.className).toContain('grid-cols-2');+ expect(radio('WordPress')!.getAttribute('aria-checked')).toBe('true');+ expect(dialog().textContent).toContain(+ "The page goes to Acme Blog in WordPress as a draft post, with its slug, and its meta description as the excerpt. The meta title isn't sent: set it in your SEO plugin.",+ );+ sentWith({ updated: false, live: false, changed: { jsonLd: 0 } });+ await act(async () => button('Send').click());+ expect(sendPagesToCms).toHaveBeenCalledWith('brand-1', expect.any(Array), 'wordpress');+ expect(localStorage.getItem('aeo:cms-target:brand-1')).toBe('wordpress');+ expect(toast.success).toHaveBeenCalledWith('Sent to WordPress as a draft post', {+ description: undefined,+ });+ expect(onClose).toHaveBeenCalled();+ });++ it('names the site by its address when it has no name', async () => {+ readWordPress.mockResolvedValue({ ...ready, connection: { ...connection, siteName: null } });+ await render();+ expect(radio('WordPress')!.textContent).toContain(+ 'A draft post on https://blog.acme.example',+ );+ });++ it('shows all three with Webflow and WordPress, starting from the remembered WordPress', async () => {+ localStorage.setItem('aeo:cms-target:brand-1', 'wordpress');+ readWebflow.mockResolvedValue(webflowReady);+ readWordPress.mockResolvedValue(ready);+ await render();+ expect(radios().map((r) => r.querySelector('span')?.textContent)).toEqual([+ 'Webflow',+ 'WordPress',+ 'Your workflow',+ ]);+ expect(dialog().querySelector('[role="radiogroup"]')!.className).toContain(+ 'grid-cols-1 sm:grid-cols-3',+ );+ expect(radio('WordPress')!.getAttribute('aria-checked')).toBe('true');+ expect(radio('WordPress')!.tabIndex).toBe(0);+ await act(async () => button('Send').click());+ expect(sendPagesToCms).toHaveBeenLastCalledWith('brand-1', expect.any(Array), 'wordpress');+ });++ it('starts from Webflow when both are ready and nothing is remembered', async () => {+ readWebflow.mockResolvedValue(webflowReady);+ readWordPress.mockResolvedValue(ready);+ await render();+ expect(radio('Webflow')!.getAttribute('aria-checked')).toBe('true');+ });++ it('keeps a remembered Webflow that isn’t ready to the webhook, never WordPress in its place', async () => {+ localStorage.setItem('aeo:cms-target:brand-1', 'webflow');+ readWebflow.mockResolvedValue({+ ...webflowReady,+ connection: { ...webflowReady.connection, status: 'auth_failed' },+ });+ readWordPress.mockResolvedValue(ready);+ await render();+ expect(radio('Webflow')!.disabled).toBe(true);+ expect(radio('WordPress')!.getAttribute('aria-checked')).toBe('false');+ expect(radio('Your workflow')!.getAttribute('aria-checked')).toBe('true');+ await act(async () => button('Send').click());+ expect(sendPagesToCms).toHaveBeenLastCalledWith('brand-1', expect.any(Array), 'webhook');+ });++ it('starts from the first ready when the remembered one is no longer connected', async () => {+ localStorage.setItem('aeo:cms-target:brand-1', 'webflow');+ readWordPress.mockResolvedValue(ready);+ await render();+ expect(radio('Webflow')).toBeUndefined();+ expect(radio('WordPress')!.getAttribute('aria-checked')).toBe('true');+ });++ it('says only that the webhook is missing when a CMS is ready to pick instead', async () => {+ localStorage.setItem('aeo:cms-target:brand-1', 'webhook');+ readWebflow.mockResolvedValue(webflowReady);+ readWordPress.mockResolvedValue(refused);+ sendPagesToCms.mockResolvedValueOnce({ ok: false, code: 'no_webhook', field: null });+ await render();+ expect(radio('Your workflow')!.getAttribute('aria-checked')).toBe('true');+ await act(async () => button('Send').click());+ expect(sendPagesToCms).toHaveBeenLastCalledWith('brand-1', expect.any(Array), 'webhook');+ expect(alert()).toBe(+ 'This brand has no webhook yet. Set one up in Webhook Settings on Content Opportunities.',+ );+ });++ it('moves through the three with the arrow keys, past one that’s off', async () => {+ readWebflow.mockResolvedValue(webflowReady);+ readWordPress.mockResolvedValue(ready);+ await render();+ await vi.waitFor(() => expect(dialog().contains(document.activeElement)).toBe(true));+ const key = async (from: string, key: string) =>+ act(async () => {+ radio(from)!.dispatchEvent(new KeyboardEvent('keydown', { key, bubbles: true }));+ });+ await key('Webflow', 'ArrowRight');+ expect(radio('WordPress')!.getAttribute('aria-checked')).toBe('true');+ expect(document.activeElement).toBe(radio('WordPress'));+ await key('WordPress', 'ArrowDown');+ expect(radio('Your workflow')!.getAttribute('aria-checked')).toBe('true');+ // Round from the last to the first.+ await key('Your workflow', 'ArrowRight');+ expect(radio('Webflow')!.getAttribute('aria-checked')).toBe('true');+ expect(localStorage.getItem('aeo:cms-target:brand-1')).toBe('webflow');++ act(() => root.unmount());+ root = createRoot(container);+ readWordPress.mockResolvedValue(refused);+ await render();+ expect(radio('WordPress')!.disabled).toBe(true);+ await key('Webflow', 'ArrowRight');+ // WordPress, off, is passed over.+ expect(radio('Your workflow')!.getAttribute('aria-checked')).toBe('true');+ await key('Your workflow', 'ArrowLeft');+ expect(radio('Webflow')!.getAttribute('aria-checked')).toBe('true');+ });++ it('shows WordPress with its sign-in refused, off, and sends to the webhook', async () => {+ localStorage.setItem('aeo:cms-target:brand-1', 'wordpress');+ readWordPress.mockResolvedValue(refused);+ await render();+ expect(radio('WordPress')!.disabled).toBe(true);+ expect(radio('WordPress')!.textContent).toContain(+ 'Sign-in refused: connect WordPress again in Settings › Integrations',+ );+ expect(radio('Your workflow')!.getAttribute('aria-checked')).toBe('true');+ sendPagesToCms.mockResolvedValueOnce({ ok: false, code: 'no_webhook', field: null });+ await act(async () => button('Send').click());+ expect(sendPagesToCms).toHaveBeenLastCalledWith('brand-1', expect.any(Array), 'webhook');+ expect(alert()).toBe(+ "This brand's WordPress refused the sign-in, and it has no webhook. Connect WordPress again in Settings › Integrations.",+ );+ });++ it('says WordPress couldn’t be checked to a person who picked it, and reads again', async () => {+ localStorage.setItem('aeo:cms-target:brand-1', 'wordpress');+ readWebflow.mockResolvedValue(webflowReady);+ readWordPress.mockResolvedValueOnce({ ok: false, code: 'failed' }).mockResolvedValue(ready);+ await render();+ expect(dialog().querySelector('[role="status"]')!.textContent).toContain(+ "Couldn't check WordPress just now, so this send goes to your workflow.",+ );+ // Not Webflow in its place: the webhook, as the note says.+ expect(radio('WordPress')).toBeUndefined();+ expect(radio('Your workflow')!.getAttribute('aria-checked')).toBe('true');+ await act(async () => button('Try again').click());+ expect(readWordPress).toHaveBeenCalledTimes(2);+ expect(radio('WordPress')!.getAttribute('aria-checked')).toBe('true');+ expect(dialog().querySelector('[role="status"]')).toBeNull();+ });++ it('says nothing of a WordPress it can’t read to a person who didn’t pick it', async () => {+ readWebflow.mockResolvedValue(webflowReady);+ readWordPress.mockResolvedValue({ ok: false, code: 'failed' });+ await render();+ expect(dialog().querySelector('[role="status"]')).toBeNull();+ expect(radio('Webflow')!.getAttribute('aria-checked')).toBe('true');+ });++ it('says the draft post was updated, its post was live, and its JSON-LD left out', async () => {+ readWordPress.mockResolvedValue(ready);+ sentWith({ updated: true, live: false, changed: { jsonLd: 0 } });+ await render();+ await act(async () => button('Send').click());+ expect(toast.success).toHaveBeenLastCalledWith('Draft post updated in WordPress', {+ description: undefined,+ });++ // The dialog stays open here (onClose is the test's): sent again.+ sentWith({ updated: false, live: true, changed: { jsonLd: 2 } });+ await act(async () => button('Send').click());+ expect(toast.success).toHaveBeenLastCalledWith('Sent to WordPress as a draft post', {+ description:+ 'Its post was already published or scheduled, so the page went as a new draft. Move the text over in WordPress; published as it is, its slug gets "-2". JSON-LD left out: add schema with your SEO plugin.',+ });++ sentWith({ updated: false, live: false, changed: { jsonLd: 1 } });+ await act(async () => button('Send').click());+ expect(toast.success).toHaveBeenLastCalledWith('Sent to WordPress as a draft post', {+ description: 'JSON-LD left out: add schema with your SEO plugin.',+ });+ });++ it('says why WordPress didn’t take the page', async () => {+ readWordPress.mockResolvedValue(ready);+ await render();+ const said = async (result: object) => {+ sendPagesToCms.mockResolvedValueOnce(result);+ await act(async () => button('Send').click());+ return alert();+ };+ expect(await said({ ok: false, code: 'no_wordpress', field: null })).toBe(+ 'Connect WordPress in Settings › Integrations first.',+ );+ expect(await said({ ok: false, code: 'wordpress_refused', field: null })).toBe(+ 'WordPress refused the sign-in. Connect it again in Settings › Integrations.',+ );+ expect(await said({ ok: false, code: 'wordpress_not_configured', field: null })).toBe(+ "WordPress isn't set up on this server. Send to your workflow instead.",+ );+ expect(await said({ ok: false, code: 'in_progress', field: null })).toBe(+ 'This page is already on its way to WordPress. Wait for it, then send again.',+ );+ expect(+ await said({+ ok: true,+ deliveries: [+ {+ id: 'x2',+ draftId: 'd1',+ status: 'failed',+ error: 'WordPress refused the post: rest_cannot_create',+ },+ ],+ }),+ ).toBe("WordPress didn't take the page: WordPress refused the post: rest_cannot_create");+ expect(sendPagesToCms).toHaveBeenLastCalledWith('brand-1', expect.any(Array), 'wordpress');+ expect(onClose).not.toHaveBeenCalled();+ });++ it('says the last send went to WordPress', async () => {+ readWordPress.mockResolvedValue(ready);+ readDraftCms.mockResolvedValue({+ ...neverSent,+ last: { status: 'sent', target: 'wordpress', at: '2026-10-24T10:00:00Z', error: null },+ });+ await render();+ expect(dialog().textContent).toContain('In WordPress as a draft post since Oct 24, 2026');+ readDraftCms.mockResolvedValue({+ ...neverSent,+ last: { status: 'failed', target: 'wordpress', at: '2026-10-24T10:00:00Z', error: 'No' },+ });+ act(() => root.unmount());+ root = createRoot(container);+ await render();+ expect(dialog().textContent).toContain('The last send to WordPress failed, Oct 24, 2026');+ });+ });});diff --git a/web/src/components/content/send-to-cms-dialog.tsx b/web/src/components/content/send-to-cms-dialog.tsxindex c38defb33..7c4a3b440 100644--- a/web/src/components/content/send-to-cms-dialog.tsx+++ b/web/src/components/content/send-to-cms-dialog.tsx@@ -31,6 +31,7 @@ import {readDraftCms,sendPagesToCms,type CmsSendError,+ type CmsTarget,type DraftCms,} from '@/lib/content/cms-send-client';import { exportPlaceholders, pageFields, titlePlaceholders } from '@/lib/content/ready-to-publish';@@ -39,8 +40,9 @@ import { CmsTargetPicker, CmsTargetUnchecked, useCmsTarget } from './cms-target'/*** Send to CMS (#1331): the page to the brand's webhook, for the workspace's- * CMS or automation to publish, or to its Webflow collection as a draft item- * (phase 2, when Settings has Webflow ready). Its slug and meta are filled from the page,+ * CMS or automation to publish, to its Webflow collection as a draft item,+ * or to its WordPress site as a draft post (phase 2, when Settings has them+ * ready). Its slug and meta are filled from the page,* or what the draft kept, and editable; they stay on the draft. The page* goes as Export makes it ready (CE-057): no placeholder goes, so they are* filled first. From the editor's header and a Library row; rendered only@@ -101,14 +103,16 @@ export function SendDialog({const [sending, setSending] = useState(false);// Fill now: the editor selects the placeholder, so focus stays there.const filling = useRef(false);+ // With the target it went to: picking another clears it, a read again may not.const [problem, setProblem] = useState<- | { code: CmsSendError; field: string | null }+ | { code: CmsSendError; field: string | null; target: CmsTarget }| { status: number }- | { failed: string; webflow: boolean }+ | { failed: string; target: CmsTarget }| null>(null);const {webflow,+ wordpress,target,pick,sent: keepTarget,@@ -117,6 +121,7 @@ export function SendDialog({retry: retryTarget,} = useCmsTarget(brandId);const collection = webflow?.ready ? webflow.collection || t('target.webflow.collection') : '';+ const site = wordpress?.ready ? wordpress.site : '';useEffect(() => {let cancelled = false;@@ -171,7 +176,7 @@ export function SendDialog({if (!result.ok) {// A read-only workspace: the upgrade dialog, with the reason kept here.if (result.code === 'subscription') openUpgrade();- setProblem({ code: result.code, field: result.field });+ setProblem({ code: result.code, field: result.field, target });return;}const [delivery] = result.deliveries;@@ -184,7 +189,7 @@ export function SendDialog({setProblem(refused? { status: delivery.http_status! }- : { failed: delivery.error ?? t('errors.failed'), webflow: target === 'webflow' },+ : { failed: delivery.error ?? t('errors.failed'), target },);// The header says it failed too, with why, as the page's last send.onSent?.({@@ -212,9 +217,19 @@ export function SendDialog({toast.success(delivery?.updated ? t('sentWebflowUpdated') : t('sentWebflow'), {description:changed && (changed.tables || changed.images)- ? t('webflowChanged', { tables: changed.tables, images: changed.images })+ ? t('webflowChanged', { tables: changed.tables ?? 0, images: changed.images ?? 0 }): undefined,});+ } else if (target === 'wordpress') {+ // A live post isn't written to: the page went as a new draft. Its+ // JSON-LD stays out (WordPress would keep it as text).+ const notes = [+ delivery?.live ? t('wordpressLive') : null,+ delivery?.changed?.jsonLd ? t('wordpressJsonLd') : null,+ ].filter((note) => note !== null);+ toast.success(delivery?.updated ? t('sentWordPressUpdated') : t('sentWordPress'), {+ description: notes.length ? notes.join(' ') : undefined,+ });} else {toast.success(t('sent'));}@@ -224,16 +239,25 @@ export function SendDialog({const problemText = (shown: NonNullable<typeof problem>) => {if ('status' in shown) return t('errors.webhookStatus', { status: shown.status });if ('failed' in shown) {- return t(shown.webflow ? 'errors.webflowFailed' : 'errors.webhookFailed', {- reason: shown.failed,- });+ const failed = {+ webflow: 'errors.webflowFailed',+ wordpress: 'errors.wordpressFailed',+ webhook: 'errors.webhookFailed',+ } as const;+ return t(failed[shown.target], { reason: shown.failed });}const { code, field } = shown;if (code === 'session' || code === 'workspace' || code === 'busy' || code === 'subscription') {return tFailure(code);}- // Webflow not ready sent the page to the webhook: what to fix is Webflow.- if (code === 'no_webhook' && webflow && !webflow.ready) return t('errors.no_webhookWebflow');+ // No CMS ready sent the page to the webhook: what to fix is the one connected.+ if (code === 'no_webhook' && !webflow?.ready && !wordpress?.ready) {+ if (webflow) return t('errors.no_webhookWebflow');+ if (wordpress) return t('errors.no_webhookWordPress');+ }+ if (code === 'in_progress' && shown.target === 'wordpress') {+ return t('errors.in_progressWordPress');+ }// The server names the path ("pages.0.slug"); the field is its last part.if (code === 'invalid' && field) {return t('errors.invalidField', { field: field.split('.').pop() ?? 'other' });@@ -257,14 +281,17 @@ export function SendDialog({? t('descriptionReading'): target === 'webflow'? t('descriptionWebflow', { collection })- : t('description')}+ : target === 'wordpress'+ ? t('descriptionWordPress', { site })+ : t('description')}</DialogDescription></DialogHeader>- {webflow && target && (+ {(webflow || wordpress) && target && (<CmsTargetPickervalue={target}webflow={webflow}+ wordpress={wordpress}disabled={sending}onChange={(next) => {pick(next);@@ -273,7 +300,12 @@ export function SendDialog({/>)}{targetUnchecked && (- <CmsTargetUnchecked reading={targetReading} onRetry={retryTarget} disabled={sending} />+ <CmsTargetUnchecked+ target={targetUnchecked}+ reading={targetReading}+ onRetry={retryTarget}+ disabled={sending}+ />)}{pageProblem && (@@ -370,12 +402,19 @@ export function SendDialog({</>) : (last &&- t(last.target === 'webflow' ? `lastWebflow.${last.status}` : `last.${last.status}`, {- when: format.dateTime(new Date(last.at), {- dateStyle: 'medium',- timeStyle: 'short',- }),- })+ t(+ last.target === 'webflow'+ ? `lastWebflow.${last.status}`+ : last.target === 'wordpress'+ ? `lastWordPress.${last.status}`+ : `last.${last.status}`,+ {+ when: format.dateTime(new Date(last.at), {+ dateStyle: 'medium',+ timeStyle: 'short',+ }),+ },+ ))}</p>)}diff --git a/web/src/lib/content/cms-send-client.test.ts b/web/src/lib/content/cms-send-client.test.tsindex 2d3c0d7f8..c2b77fca0 100644--- a/web/src/lib/content/cms-send-client.test.ts+++ b/web/src/lib/content/cms-send-client.test.ts@@ -45,6 +45,7 @@ const {readDraftCms,readKeptFields,refreshWebflowPublished,+ refreshWordPressPublished,sendPagesToCms,} = await import('./cms-send-client');@@ -101,6 +102,26 @@ describe('sendPagesToCms', () => {deliveries: [{ updated: true }],});expect(JSON.parse(fetchMock.mock.calls.at(-1)![1].body)).toMatchObject({ target: 'webflow' });+ // To the brand's WordPress site (00294): its post live, its JSON-LD left out.+ answer(200, {+ deliveries: [+ {+ id: 'x4',+ draftId: 'd1',+ status: 'sent',+ updated: false,+ live: true,+ changed: { jsonLd: 2 },+ },+ ],+ });+ expect(await sendPagesToCms('brand-1', [page], 'wordpress')).toMatchObject({+ ok: true,+ deliveries: [{ updated: false, live: true, changed: { jsonLd: 2 } }],+ });+ expect(JSON.parse(fetchMock.mock.calls.at(-1)![1].body)).toMatchObject({+ target: 'wordpress',+ });});it('gives the server’s reason, and the field a 400 names', async () => {@@ -126,6 +147,18 @@ describe('sendPagesToCms', () => {answer(409, { code });expect(await sendPagesToCms('brand-1', [page], 'webflow')).toMatchObject({ ok: false, code });}+ for (const code of [+ 'wordpress_not_configured',+ 'no_wordpress',+ 'wordpress_refused',+ 'in_progress',+ ]) {+ answer(409, { code });+ expect(await sendPagesToCms('brand-1', [page], 'wordpress')).toMatchObject({+ ok: false,+ code,+ });+ }});it('says when a request was more than the API’s proxy takes', async () => {@@ -187,6 +220,35 @@ describe('refreshWebflowPublished', () => {});});+describe('refreshWordPressPublished', () => {+ it('asks the API to read the brand’s WordPress posts, and gives the drafts it marked published', async () => {+ answer(200, {+ checked: 2,+ published: [+ { draftId: 'd1', url: 'https://a.example/cold-brew/' },+ // A page deleted since: no draft to mark.+ { draftId: null, url: 'https://a.example/espresso/' },+ ],+ });+ expect(await refreshWordPressPublished('brand-1')).toEqual(['d1']);+ expect(fetchMock).toHaveBeenCalledWith('/api/aeo/api/content-drafts/wordpress-status', {+ method: 'POST',+ headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token-1' },+ body: JSON.stringify({ brandId: 'brand-1' }),+ });+ // Read a moment ago, or not there (an API before 00294): none.+ answer(200, { checked: 0, published: [], recent: true });+ expect(await refreshWordPressPublished('brand-1')).toEqual([]);+ answer(404, {});+ expect(await refreshWordPressPublished('brand-1')).toEqual([]);+ fetchMock.mockRejectedValueOnce(new Error('offline'));+ expect(await refreshWordPressPublished('brand-1')).toEqual([]);+ session = null;+ expect(await refreshWordPressPublished('brand-1')).toEqual([]);+ expect(fetchMock).toHaveBeenCalledTimes(4);+ });+});+describe('readDraftCms', () => {it('gives the kept fields, where the page went live and its last send', async () => {reads = {@@ -346,6 +408,21 @@ describe('readCmsStatuses', () => {});});+ it('says which sends went to WordPress, and reads an unknown target as the webhook', async () => {+ statusReads = [+ {+ data: [+ delivery('d1', 'sent', '2026-10-24T10:00:00Z', { target: 'wordpress' }),+ delivery('d2', 'sent', '2026-10-24T10:00:00Z', { target: 'shopify' }),+ ],+ error: null,+ },+ ];+ const statuses = await readCmsStatuses(['d1', 'd2']);+ expect(statuses.get('d1')).toMatchObject({ status: 'sent', target: 'wordpress' });+ expect(statuses.get('d2')).toMatchObject({ target: 'webhook' });+ });+it('leaves a read that fails with no sends, as before its table is there', async () => {statusReads = [{ data: null, error: { message: 'relation does not exist' } }];expect((await readCmsStatuses(['d1'])).size).toBe(0);diff --git a/web/src/lib/content/cms-send-client.ts b/web/src/lib/content/cms-send-client.tsindex ef6e3fba7..731b12805 100644--- a/web/src/lib/content/cms-send-client.ts+++ b/web/src/lib/content/cms-send-client.ts@@ -9,8 +9,11 @@ import type { CmsFields, CmsPage } from '@/lib/content/cms-send';* which Next runs one at a time, behind the editor's own.*/-/** Where pages go: the brand's webhook (phase 1) or its Webflow collection (phase 2). */-export type CmsTarget = 'webhook' | 'webflow';+/**+ * Where pages go: the brand's webhook (phase 1), its Webflow collection or+ * its WordPress site (phase 2).+ */+export type CmsTarget = 'webhook' | 'webflow' | 'wordpress';/** Why a send didn't go, as the server names it. */export type CmsSendError =@@ -22,6 +25,10 @@ export type CmsSendError =| 'no_webflow'| 'webflow_refused'| 'webflow_not_ready'+ // WordPress (00294): not on this server, not connected, or its sign-in refused.+ | 'wordpress_not_configured'+ | 'no_wordpress'+ | 'wordpress_refused'| 'in_progress'| 'daily_limit'| 'forbidden'@@ -45,9 +52,15 @@ export interface CmsDelivery {http_status?: number | null;/** Why it failed, as the server wrote it ("The webhook could not be reached"). */error?: string | null;- /** Webflow, one page: its item updated (not made), and what of the page changed on the way. */+ /**+ * Webflow or WordPress, one page: its item (or draft post) updated, not+ * made, and what of the page changed on the way: Webflow's tables and+ * images, WordPress's JSON-LD blocks left out.+ */updated?: boolean;- changed?: { tables: number; images: number };+ changed?: { tables?: number; images?: number; jsonLd?: number };+ /** WordPress: the page's post was live, so the page went as a new draft post. */+ live?: boolean;}export type CmsSendResult =@@ -63,6 +76,9 @@ const KNOWN: readonly CmsSendError[] = ['no_webflow','webflow_refused','webflow_not_ready',+ 'wordpress_not_configured',+ 'no_wordpress',+ 'wordpress_refused','in_progress','daily_limit','forbidden',@@ -74,8 +90,8 @@ const KNOWN: readonly CmsSendError[] = [const GENERAL: readonly CmsSendError[] = ['session', 'workspace', 'busy', 'subscription'];/**- * Sends pages of one brand to its webhook, or its Webflow collection: one is- * sent before this answers, more go on.+ * Sends pages of one brand to its webhook, its Webflow collection or its+ * WordPress site: one is sent before this answers, more go on.*/export async function sendPagesToCms(brandId: string,@@ -116,17 +132,21 @@ export async function sendPagesToCms(}/**- * Asks the API to read the brand's pages sent to Webflow, and mark the ones- * published there since (#1331, phase 2). The pages it marked, by draft;- * none when it couldn't read or read a moment ago.+ * Asks the API to read the brand's pages sent to a CMS that says when a page+ * goes live there, and mark the ones published since. The pages it marked,+ * by draft; none when it couldn't read or read a moment ago.*/-export async function refreshWebflowPublished(brandId: string): Promise<string[]> {+async function refreshPublished(+ brandId: string,+ route: 'webflow-status' | 'wordpress-status',+ label: string,+): Promise<string[]> {try {const {data: { session },} = await createClient().auth.getSession();if (!session) return [];- const res = await fetch(`${BROWSER_API_BASE_URL}/api/content-drafts/webflow-status`, {+ const res = await fetch(`${BROWSER_API_BASE_URL}/api/content-drafts/${route}`, {method: 'POST',headers: {'Content-Type': 'application/json',@@ -140,15 +160,25 @@ export async function refreshWebflowPublished(brandId: string): Promise<string[]};return (body.published ?? []).flatMap((p) => (p.draftId ? [p.draftId] : []));} catch (err) {- console.error('Failed to read the pages sent to Webflow:', err);+ console.error(`Failed to read the pages sent to ${label}:`, err);return [];}}+/** The brand's pages sent to Webflow, published there since (#1331, phase 2). */+export function refreshWebflowPublished(brandId: string): Promise<string[]> {+ return refreshPublished(brandId, 'webflow-status', 'Webflow');+}++/** The brand's pages sent to WordPress as draft posts, published there since (00294). */+export function refreshWordPressPublished(brandId: string): Promise<string[]> {+ return refreshPublished(brandId, 'wordpress-status', 'WordPress');+}+/** A draft's last send, as the Library shows it beside its status. */export interface CmsStatus {status: CmsDelivery['status'];- /** Where it went: the webhook, or Webflow (a draft item there once sent). */+ /** Where it went: the webhook, Webflow (a draft item there once sent) or WordPress (a draft post). */target: CmsTarget;/** When it was published, sent or queued. */at: string;@@ -182,7 +212,7 @@ function lastSend(row: {row.status === 'queued' && Date.parse(row.created_at) < Date.now() - INTERRUPTED_AFTER_MS;return {status: interrupted ? 'failed' : (row.status as CmsDelivery['status']),- target: row.target === 'webflow' ? 'webflow' : 'webhook',+ target: row.target === 'webflow' || row.target === 'wordpress' ? row.target : 'webhook',at: row.published_at ?? row.sent_at ?? row.created_at,error: interrupted ? 'Not sent: interrupted' : row.error,};