2974 major user should not be able to publish post without content#23221
Conversation
Coverage Report for CI Build 161Coverage decreased (-0.2%) to 53.168%Details
Uncovered Changes
Coverage Regressions7 previously-covered lines in 1 file lost coverage.
Coverage Stats💛 - Coveralls |
|
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
|
|
||
| // 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 ) { |
There was a problem hiding this comment.
Remove the is_block_editor variable and check, following the comment that says we can't detect that on save.
| }, | ||
| } ); | ||
| } ); | ||
| registerInlineBanner(); |
There was a problem hiding this comment.
…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.
| echo new Meta_Fields_Presenter( $this->get_metabox_post(), 'social' ); | ||
| } | ||
|
|
||
| $is_block_editor = WP_Screen::get()->is_block_editor(); |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
Inconsistent indentation on the * continuation line — minor but noteworthy.
Context
Summary
This PR can be summarized in the following changelog entry:
Relevant technical choices:
BlockListBlockfilter is used instead ofBlockEditso that the banner is not rendered as part of the attached empty postTest instructions
Test instructions for the acceptance test before the PR gets merged
This PR can be acceptance tested by following these steps:
Setup
Banner appears on a new post
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
Get content suggestions button still works as expected
Relevant test scenarios
Test instructions for QA when the code is in the RC
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
[shopify-seo], added test instructions for Shopify and attached theShopifylabel to this PR.[yoast-doc-extension], added test instructions for Yoast SEO for Google Docs and attached theGoogle Docs Add-onlabel to this PR.Documentation
Quality assurance
grunt build:imagesand committed the results, if my PR introduces or edits images or SVGs.Innovation
innovationlabel.Fixes https://github.com/Yoast/plugins-automated-testing/issues/2974