Summary
Introduce a pre-publish validation system that prevents publishing when editorial rules are not met. The first rule will enforce excerpt length requirements across all post types that support excerpts.
Requirements
Excerpt Validation
A post must not be published unless its excerpt:
- Is not empty
- Is at least 120 characters
- Is no more than 160 characters
This applies only to post types that support excerpts.
Allowed Statuses
Validation must not run when transitioning to:
Only publishing-related transitions (such as publish, future) should be blocked.
User Feedback
If the excerpt fails validation:
- Publishing is blocked
- A clear warning is displayed in the editor (using
core/notices)
Extensibility
The implementation must support additional pre-publish rules. Example follow-up validations might require:
- At least one category that isn’t
Uncategorized
- A featured image
- Required custom fields
The system should expose a registration API so new rules can be added without modifying core logic.
Technical Approach
- Use an
addFilter hook to intercept publish attempts.
- Read post data from the editor store (
core/editor).
- Skip validation when the post type does not support excerpts.
- Provide a reusable rule registry, e.g.:
registerPrePublishRule( 'excerptLength', ( post ) => {
// return { valid: boolean, message: string }
} );
- Evaluate all registered rules before allowing the publish.
- If any rule fails:
- Block publish
- Add a notice via
core/notices
Acceptance Criteria
- Publishing is blocked when excerpt length is invalid.
- Draft and pending review operations are unaffected.
- Unsupported post types are ignored.
- Multiple rules can be added through a stable registration API.
- Editor notices appear consistently and clearly.
Notes
- This is the first step of a general pre-publish validation framework. Additional checks will be added in later issues.
Summary
Introduce a pre-publish validation system that prevents publishing when editorial rules are not met. The first rule will enforce excerpt length requirements across all post types that support excerpts.
Requirements
Excerpt Validation
A post must not be published unless its excerpt:
This applies only to post types that support excerpts.
Allowed Statuses
Validation must not run when transitioning to:
draftpending_reviewOnly publishing-related transitions (such as
publish,future) should be blocked.User Feedback
If the excerpt fails validation:
core/notices)Extensibility
The implementation must support additional pre-publish rules. Example follow-up validations might require:
UncategorizedThe system should expose a registration API so new rules can be added without modifying core logic.
Technical Approach
addFilterhook to intercept publish attempts.core/editor).core/noticesAcceptance Criteria
Notes