Skip to content

Send Custom HTML blocks to beehiiv as HTML Snippets with a Newsletter only option - #205

Draft
phpbits wants to merge 5 commits into
mainfrom
auto-intake/19821634-custom-html-snippet
Draft

phpbits wants to merge 5 commits into
mainfrom
auto-intake/19821634-custom-html-snippet

Conversation

@phpbits

@phpbits phpbits commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Sends each WordPress Custom HTML block to beehiiv as an HTML Snippet, with a per-block "Newsletter only" option.

What changed

  • A Custom HTML block becomes one beehiiv HTML block in the same position. Script and iframe elements are removed first. An empty block sends nothing.
  • Inside a Group the snippet stays in the section. Inside Columns or Media & Text it follows the parent's columns block, because beehiiv columns do not accept HTML blocks.
  • "Newsletter only" (off by default) hides the block on the site, the RSS feed, the excerpt and the REST API content. The block still syncs to beehiiv.
  • In the editor: a "Newsletter only" label, a notice when script or iframe elements will be left out, and a sidebar toggle. The block is no longer marked as omitted.

Requirements: PRD-07.2.02 (AC-001 to AC-022). Relay PR: https://github.com/10up/beehiiv-exensions-relay/pull/5
Decisions to review are listed in the relay PR.

Checks

  • phpcs, lint:js, lint:css: pass. npm run build: pass.
  • PHPUnit (tests/phpunit/BlockConverterHtmlTest.php) and the Playwright spec (tests/e2e/specs/html-snippet-block-conversion.spec.js, 22 of 22 ACs covered) were written but not run on the build machine (no Docker). The Test workflow runs them on this PR. No AC is claimed to pass until that run is read. Likely spec-side failures to check first: AC-013 (opening the block settings sidebar) and AC-021 (checks only what the plugin sends).
  • AC-022 (the full flow on a real post) is not verified.

Flags

  • beehiiv documents that it removes style elements from HTML blocks; inline styles are the reliable choice (PRD Q-002).
  • Newsletter-only snippets are sent with no visibility rule, so beehiiv's default decides whether they show on the web version (Q-005).
  • Duplicate request: a second Brief for the same work exists (task 19821983). Do not build it twice.

Teamwork task: 19821634

Rerun 1

What failed. One PHPUnit test, BlockConverterHtmlTest::test_script_and_iframe_elements_are_removed, failed on every PHP and WordPress combination (212 tests, 1 failure: expected 1 snippet, got 2). Lint passed. The E2E job had not finished.

Cause. The test saved its posts with no logged-in user, so WordPress removed the <script> tags when the post was saved and kept their text. The block that held only a script then held plain text, and was correctly sent as a snippet. The converter was right. The test setup was not.

What changed. The test class now runs as an administrator, who can save unfiltered HTML, so script tags survive saving as they do for a publisher. One commit, test file only. phpcs is clean. PHPUnit was not run on this machine.

Still needs a person. Check that PHPUnit passes on the new commit. Read the E2E result when it finishes. The intake stays executing until that is done.

Rerun 2

  • Fixed AC-012: on WordPress 7.1.5 a saved Custom HTML block has no content attribute in the editor until it is edited, so the script and iframe notice never showed. The editor now falls back to the saved markup.
  • Fixed the editor specs: the Newsletter only label and the notice render just before their block, not inside it. The specs now find them by the block that follows. The AC-013 spec also opens the Block settings tab before looking for the option.
  • Ran the Custom HTML spec against the latest WordPress locally: 21 of 22 passed, then AC-013 (the one failing, a spec selector problem) passed after its fix, along with AC-012, AC-018 and AC-022 rerun together.
  • Added the demo walkthrough script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant