Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e92bf22
feat(admin-interface): add Subscriber gating defaults to settings page
phpbits Nov 2, 2026
415943a
feat(custom-blocks): add gated content and gate divider blocks
phpbits Nov 2, 2026
59ca990
fix(custom-blocks): stop gated content render loop with several previ…
phpbits Nov 2, 2026
dcc0833
fix(custom-blocks): hide gate card at once for returning readers and …
phpbits Nov 2, 2026
c1a5063
fix(custom-blocks): init gate after DOM ready and restyle gate card o…
phpbits Nov 2, 2026
c7b3988
feat(custom-blocks): add card background and text color options to ga…
phpbits Nov 2, 2026
969e477
fix(custom-blocks): apply card text color to the gate headline
phpbits Nov 2, 2026
8c3776d
fix(custom-blocks): keep gate on repeat renders, allow a divider per …
phpbits Nov 2, 2026
79d5591
feat(custom-blocks): show a missing-publication notice with a setting…
phpbits Nov 2, 2026
bbffdbd
feat(admin-interface): add a default subscribe form ID to the Subscri…
phpbits Nov 2, 2026
a9efe06
style(custom-blocks): use a dotted outline on the gated block in the …
phpbits Nov 2, 2026
5a57477
feat(gated-content): remove default headline and text; blank hides them
phpbits Nov 3, 2026
76e4b30
feat(gated-content): start new blocks with paragraph, divider, paragraph
phpbits Nov 3, 2026
416cadf
refactor(gated-content): rely on the block template only; drop empty-…
phpbits Nov 3, 2026
e9b5bdb
feat(gated-content): gate every gated block on a page; one subscribe …
phpbits Nov 3, 2026
5f88fe1
fix(gated-content): center the beehiiv form inside the gate card
phpbits Nov 3, 2026
cc7fc82
Revert "fix(gated-content): center the beehiiv form inside the gate c…
phpbits Nov 3, 2026
027cbd8
feat(gated-content): size the gate card to the form width
phpbits Nov 3, 2026
237a8cc
style(gated-content): set gate card min width to 400px
phpbits Nov 3, 2026
670843e
style(gated-content): set gate card min width to 500px
phpbits Nov 3, 2026
693b9b5
feat(gated-content): gate the whole block when there is no divider
phpbits Nov 3, 2026
511e424
fix(gated-content): follow the theme base color for the fade and card
phpbits Nov 3, 2026
0b76661
fix(gated-content): address code review findings
phpbits Nov 3, 2026
17155f3
refactor(gated-content): render the headline as a styled paragraph; d…
phpbits Nov 3, 2026
8574cf6
fix(gated-content): size the card from the form, not from the headlin…
phpbits Nov 3, 2026
34aa3ff
fix(gated-content): open the gate before first paint, announce unlock…
phpbits Nov 3, 2026
ff8ce7a
fix(gated-content): lint clean; static boot script with tests; reserv…
phpbits Nov 3, 2026
c2fe08c
fix(ci): register gate blocks in PHPUnit without a build; pin the E2E…
phpbits Nov 3, 2026
c022211
fix(gated-content): resolve review items; add E2E spec, readme and ch…
phpbits Nov 3, 2026
d4dc673
fix(ci): match the render callback signature in the PHPUnit block reg…
phpbits Nov 3, 2026
c83b39f
chore(i18n): regenerate the translation template; tidy the multi-gate…
phpbits Nov 3, 2026
b35eb80
feat(editor-integration): preview the real beehiiv email in the post …
phpbits Nov 9, 2026
a71b2c6
Meet WordPress VIP Integration Center conformance checks (#196)
phpbits Nov 9, 2026
85c68f3
Keep publication fields on the first settings save and fix stale E2E …
phpbits Nov 9, 2026
42a586f
Disable the post template dropdown until a publication is selected
phpbits Nov 9, 2026
59a9d57
Ignore stale template requests on the settings page
phpbits Nov 9, 2026
b94fc82
test(e2e): add demo walkthrough recorder and four demo scripts (#202)
phpbits Nov 9, 2026
8eabf11
Convert Group blocks to beehiiv sections (#200)
phpbits Nov 12, 2026
1f2f5b1
Add setting to require editors to choose a post template (#198)
phpbits Nov 12, 2026
1ba0b89
feat(newsletter-publishing): convert top-level Columns blocks to beeh…
phpbits Nov 12, 2026
290731a
Pin the E2E job to Ubuntu 24.04 and fix a Prettier error in the struc…
phpbits Nov 12, 2026
4681cd9
Prepare the 1.2.0 release: bump the version, add the changelog, fill …
phpbits Nov 12, 2026
5bce72c
Keep Group sections when a preview draft is refreshed
phpbits Nov 12, 2026
23faa55
Merge remote-tracking branch 'origin/release/1.2.0' into feature/1981…
phpbits Nov 13, 2026
894d263
Add tests for the gate settings page, focus and status, long content,…
phpbits Nov 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- { series: "8.3", patch: "8.3.36" }
- { series: "8.4", patch: "8.4.27" }
- { series: "8.5", patch: "8.5.12" }
wp-version: ["6.8", "latest"]
wp-version: ["6.8", "6.9", "7.0", "latest"]

steps:
- name: Checkout
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
run: npm run env:start

- name: Run PHPUnit
run: npx wp-env run tests-cli -- bash -c "cd wp-content/plugins/$(basename "$GITHUB_WORKSPACE") && composer test"
run: npx wp-env run tests-cli -- bash -c "cd wp-content/plugins/$(basename "$GITHUB_WORKSPACE") && composer test:unit"

- name: Generate PHPUnit dashboard
if: always() && hashFiles('tests/phpunit/test-results/junit.xml') != ''
Expand All @@ -82,7 +82,8 @@ jobs:

e2e:
name: E2E tests
runs-on: ubuntu-latest
# Playwright does not support Ubuntu 26.04, which ubuntu-latest now uses.
runs-on: ubuntu-24.04
timeout-minutes: 60

steps:
Expand Down
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,34 @@ define( 'BEEHIIV_SSLVERIFY', false ); // optional; local private CA only

Post template for API payloads uses the plugin default `post_template_id`; omit `post_template_id` from the request when unset (`Newsletter\PostSettingsBuilder`).

## WordPress VIP runtime config

On WordPress VIP, the platform defines `VIP_BEEHIIV_CONFIG` before the plugin loads. It is a plain PHP array built from the config form in the VIP Dashboard. The plugin reads it in `Beehiiv\OAuth\Config`. The field is declared in `vip-manifest.yaml`.

| Key | Type | Required | Effect |
| -------------- | ---- | -------- | ---------------------------------------------------------------------- |
| `api_base_url` | url | No | Overrides the beehiiv API base URL. Empty or invalid values are ignored. |

The plugin resolves the API base URL in this order: `VIP_BEEHIIV_CONFIG['api_base_url']`, then the `BEEHIIV_API_BASE_URL` constant from `wp-config.php`, then the production default. The plugin never fatals on missing or malformed config. It falls back to the next source.

Valid example:

```php
define( 'VIP_BEEHIIV_CONFIG', [
'api_base_url' => 'https://api.example.test/v2',
] );
```

Incomplete example (setup in progress, the field saved blank). The plugin ignores the blank value and uses the default API URL:

```php
define( 'VIP_BEEHIIV_CONFIG', [
'api_base_url' => '',
] );
```

Test fixtures for the valid, minimal, incomplete and invalid states live in `tests/phpunit/fixtures/`.

## Linting

```bash
Expand Down
4 changes: 2 additions & 2 deletions beehiiv.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Plugin Name: beehiiv
* Description: Official beehiiv WordPress plugin. Publish posts as newsletters and grow your audience with beehiiv.
* Version: 1.1.0
* Version: 1.2.0
* Author: beehiiv
* Text Domain: beehiiv
* Domain Path: /languages
Expand All @@ -18,7 +18,7 @@
defined( 'ABSPATH' ) || exit;

if ( ! defined( 'BEEHIIV_VERSION' ) ) {
define( 'BEEHIIV_VERSION', '1.1.0' );
define( 'BEEHIIV_VERSION', '1.2.0' );
}

if ( ! defined( 'BEEHIIV_PLUGIN_FILE' ) ) {
Expand Down
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
}
},
"scripts": {
"test": "phpunit -c phpunit.xml.dist"
"test": [
"@test:unit",
"@test:e2e"
],
"test:unit": "phpunit -c phpunit.xml.dist",
"test:e2e": "npx playwright test"
},
"minimum-stability": "stable",
"require": {
Expand Down
2 changes: 1 addition & 1 deletion includes/API/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static function set_publications( array $items ): void {
/**
* Clear the cached publications list so the next read fetches it from beehiiv.
*
* @since x.x.x
* @since 1.1.0
*
* @return void
*/
Expand Down
103 changes: 85 additions & 18 deletions includes/API/Resources/Posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,22 @@ public static function create( string $publication_id, array $payload ): array {
/**
* Fetch a single post from a beehiiv publication.
*
* @param string $publication_id Publication ID.
* @param string $post_id beehiiv post ID.
* @return array{success: bool, post: array<string, mixed>, error: string}
* @since x.x.x
* @param string $publication_id Publication ID.
* @param string $post_id beehiiv post ID.
* @param string|null $expand Optional `expand` value, for example `free_email_content`.
* @return array{success: bool, post: array<string, mixed>, error: string, status_code: int|null}
* @since 1.1.0
*/
public static function get( string $publication_id, string $post_id ): array {
public static function get( string $publication_id, string $post_id, ?string $expand = null ): array {
$publication_id = trim( $publication_id );
$post_id = trim( $post_id );

if ( '' === $publication_id || '' === $post_id ) {
return [
'success' => false,
'post' => [],
'error' => 'Publication ID or post ID is empty.',
'success' => false,
'post' => [],
'error' => 'Publication ID or post ID is empty.',
'status_code' => null,
];
}

Expand All @@ -106,32 +108,35 @@ public static function get( string $publication_id, string $post_id ): array {
rawurlencode( $publication_id ),
rawurlencode( $post_id )
);
$response = Client::request( $path );
$response = Client::request( $path, null === $expand ? [] : [ 'expand' => $expand ] );

$wp_error = Client::get_last_wp_error();

if ( null !== $wp_error ) {
return [
'success' => false,
'post' => [],
'error' => $wp_error,
'success' => false,
'post' => [],
'error' => $wp_error,
'status_code' => null,
];
}

$status_code = Client::get_last_status_code();

if ( null !== $status_code && $status_code > 299 ) {
return [
'success' => false,
'post' => [],
'error' => self::format_error_message( $response, $status_code ),
'success' => false,
'post' => [],
'error' => self::format_error_message( $response, $status_code ),
'status_code' => $status_code,
];
}

return [
'success' => true,
'post' => isset( $response['data'] ) && is_array( $response['data'] ) ? $response['data'] : [],
'error' => '',
'success' => true,
'post' => isset( $response['data'] ) && is_array( $response['data'] ) ? $response['data'] : [],
'error' => '',
'status_code' => $status_code,
];
}

Expand Down Expand Up @@ -274,6 +279,51 @@ public static function get_creation_state( string $publication_id, string $post_
return $result;
}

/**
* Read a post together with its rendered free email content.
*
* @link https://developers.beehiiv.com/api-reference/posts/show
*
* @param string $publication_id Publication ID.
* @param string $post_id beehiiv post ID.
* @return array{
* success: bool,
* email_html: string,
* subject: string,
* preview_text: string,
* error: string,
* status_code: int|null
* }
* @since 1.2.0
*/
public static function get_email_content( string $publication_id, string $post_id ): array {
$fetched = self::get( $publication_id, $post_id, 'free_email_content' );
$result = [
'success' => false,
'email_html' => '',
'subject' => '',
'preview_text' => '',
'error' => $fetched['error'],
'status_code' => $fetched['status_code'],
];

if ( ! $fetched['success'] ) {
return $result;
}

$data = $fetched['post'];
$html = $data['content']['free']['email'] ?? '';

$result['success'] = true;
$result['email_html'] = is_string( $html ) ? $html : '';
$result['subject'] = self::first_non_empty( [ $data['email_settings']['email_subject_line'] ?? '' ] );
$result['preview_text'] = self::first_non_empty(
[ $data['email_settings']['email_preview_text'] ?? '', $data['subtitle'] ?? '' ]
);

return $result;
}

/**
* Send a test email of a beehiiv post to one or more addresses.
*
Expand Down Expand Up @@ -398,6 +448,23 @@ public static function update( string $publication_id, string $post_id, array $p
];
}

/**
* First value that is a non-empty string, or an empty string.
*
* @param array<int, mixed> $values Candidate values in priority order.
* @return string
* @since 1.2.0
*/
private static function first_non_empty( array $values ): string {
foreach ( $values as $value ) {
if ( is_string( $value ) && '' !== trim( $value ) ) {
return $value;
}
}

return '';
}

/**
* Build a log-friendly error string from an API error response.
*
Expand Down
Loading
Loading