Skip to content

2974 major user should not be able to publish post without content#23221

Merged
vraja-pro merged 16 commits intorelease/27.6from
2974-major-user-should-not-be-able-to-publish-post-without-content
May 1, 2026
Merged

2974 major user should not be able to publish post without content#23221
vraja-pro merged 16 commits intorelease/27.6from
2974-major-user-should-not-be-able-to-publish-post-without-content

Conversation

@FAMarfuaty
Copy link
Copy Markdown
Contributor

@FAMarfuaty FAMarfuaty commented Apr 30, 2026

Context

Summary

This PR can be summarized in the following changelog entry:

  • Disables the save button when post contains only Content planner banner.

Relevant technical choices:

  • The inline banner is now saved as post meta and not as Gutenberg anymore. Gutenberg recognizes the inline banner block as a valid content. Hence on a new empty post with only inline banner block, Gutenberg considers it as not empty. As a result, the save button is enabled in this case.
  • WP BlockListBlock filter is used instead of BlockEdit so that the banner is not rendered as part of the attached empty post
  • The inline banner is now rendered above the empty paragraph block on a new empty post, instead of below it. This is to avoid Gutenberg's between-block inserter from being shown when hovering over the banner.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

Setup

  • Have a WordPress install with this branch active.
  • Make sure you are logged in as an editor or admin.

Banner appears on a new post

  1. Go to Posts → Add New to open the block editor for a new post.
  2. Confirm the inline banner appears above the first paragraph block with the text "Stuck on what to write next?".
    • Before, the banner appears below the first empty paragraph
  3. If testing with a free (non-Premium) account, confirm the banner shows a "Using 1 spark" note. If testing with a Premium account, confirm that note is absent.
  4. Hover over the banner and confirm that you don't see Gutenberg's between-block inserter, as shown in the screenshot below:
Screenshot 2026-04-30 at 14 21 54
  1. Confirm that the save draft/publish/update button is disabled
    • Before this PR, the button was enabled

Dismiss persists across reloads
6. Click the X button on the banner — confirm the banner disappears.
7. Save or publish the post, then reload the page.
8. Confirm the banner does not reappear after the reload.

Rendered state persists across reloads
9. Create another new post (Posts → Add New) and let the banner render without dismissing it.
10. Save the post as a draft or publish, then reload the page.
11. Confirm the banner is still visible after the reload.

Existing post — no banner
12. Open an existing post that has never had the banner rendered (i.e. was created before this branch was active, or was never opened with the banner).
13. Confirm the banner does not appear.

Non-post post types
14. Go to Pages → Add New to open the block editor for a new page.
15. Confirm the banner does not appear.

Site contains less than 5 public posts - no banner

  • Have a site with less than 5 published posts
  • Go to create a new post and confirm that you don't see the inline banner
  • Add more than 5 published posts
  • Create a new post and confirm that you now see the inline banner

Get content suggestions button still works as expected

  • Create a new post
  • Click on the "Get content suggestions" button
  • Confirm that the Content suggestions modal appear and show the loading state
  • Once the request is successful, confirm that you see the suggestions
  • Click on one of the suggestions and apply the outline to the post
  • Once the outline is applied, confirm that the banner is removed

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

QA can test this PR by following these steps:

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.
  • This PR also affects Yoast SEO for Google Docs. I have added a changelog entry starting with [yoast-doc-extension], added test instructions for Yoast SEO for Google Docs and attached the Google Docs Add-on label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.
  • I have run grunt build:images and committed the results, if my PR introduces or edits images or SVGs.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes https://github.com/Yoast/plugins-automated-testing/issues/2974

@coveralls
Copy link
Copy Markdown

coveralls commented May 1, 2026

Coverage Report for CI Build 161

Coverage decreased (-0.2%) to 53.168%

Details

  • Coverage decreased (-0.2%) from the base build.
  • Patch coverage: 35 uncovered changes across 6 files (45 of 80 lines covered, 56.25%).
  • 7 coverage regressions across 1 file.

Uncovered Changes

File Changed Covered %
packages/js/src/ai-content-planner/components/with-inline-banner.js 36 28 77.78%
packages/js/src/ai-content-planner/store/banner.js 14 6 42.86%
packages/js/src/ai-content-planner/helpers/fields.js 12 6 50.0%
packages/js/src/ai-content-planner/initialize.js 8 2 25.0%
admin/metabox/class-metabox.php 6 2 33.33%
packages/js/src/ai-content-planner/hooks/use-apply-outline.js 3 0 0.0%

Coverage Regressions

7 previously-covered lines in 1 file lost coverage.

File Lines Losing Coverage Coverage
packages/js/src/ai-content-planner/initialize.js 7 35.29%

Coverage Stats

Coverage Status
Relevant Lines: 48828
Covered Lines: 25793
Line Coverage: 52.82%
Relevant Branches: 12669
Covered Branches: 6904
Branch Coverage: 54.5%
Branches in Coverage %: Yes
Coverage Strength: 61606.58 hits per line

💛 - Coveralls

@FAMarfuaty FAMarfuaty added changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog innovation Innovative issue. Relating to performance, memory or data-flow. labels May 1, 2026
@FAMarfuaty FAMarfuaty added this to the 27.6 milestone May 1, 2026
@FAMarfuaty FAMarfuaty marked this pull request as ready for review May 1, 2026 07:53
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 1, 2026

A merge conflict has been detected for the proposed code changes in this PR. Please resolve the conflict by either rebasing the PR or merging in changes from the base branch.

…74-major-user-should-not-be-able-to-publish-post-without-content
Comment thread admin/metabox/class-metabox.php Outdated

// We can't detect in save_postdata whether the request is coming from the block editor, so we gate the content_planner fields on post type only.
$is_block_editor = WP_Screen::get()->is_block_editor();
if ( $post->post_type === 'post' && $is_block_editor ) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the is_block_editor variable and check, following the comment that says we can't detect that on save.

},
} );
} );
registerInlineBanner();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…but the store is registered inside domReady( () => { registerStore(...) } ).
The withInlineBanner HOC selects from CONTENT_PLANNER_STORE on first render. If blocks render before the DOM-ready callback fires, the store won't exist yet and select(CONTENT_PLANNER_STORE) will throw or return undefined.
The store registration should happen before the filter is added, or both should be wrapped in domReady.

Comment thread admin/metabox/class-metabox.php Outdated
echo new Meta_Fields_Presenter( $this->get_metabox_post(), 'social' );
}

$is_block_editor = WP_Screen::get()->is_block_editor();
Copy link
Copy Markdown
Contributor

@vraja-pro vraja-pro May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though it is not done elsewhere in this file, maybe we should include null check here:

$screen = WP_Screen::get();
$is_block_editor = $screen && $screen->is_block_editor(); 


/**
* Editor plugin that auto-inserts the Content Planner Banner block
* Editor plugin that auto-inserts the Content Planner Banner component (via the `editor.BlockListBlock` filter) in new posts of the "post" type,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent indentation on the * continuation line — minor but noteworthy.

Copy link
Copy Markdown
Contributor

@vraja-pro vraja-pro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AC ✅ CR 🚧

Copy link
Copy Markdown
Contributor

@vraja-pro vraja-pro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR & AC ✅

@vraja-pro vraja-pro merged commit 106c280 into release/27.6 May 1, 2026
46 of 50 checks passed
@vraja-pro vraja-pro deleted the 2974-major-user-should-not-be-able-to-publish-post-without-content branch May 1, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog innovation Innovative issue. Relating to performance, memory or data-flow.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants