| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [View Raw Code] [Original HTTPS Page] |
The AI Editorial Notes experiment adds a block-by-block AI editorial review to the WordPress post editor. Clicking "Generate Editorial Notes" in the post sidebar triggers the AI to examine each reviewable block and create WordPress Notes directly on the relevant blocks with concise, actionable suggestions across four categories: Accessibility, Readability, Grammar, and SEO.
When enabled, a "Generate Editorial Notes" button appears in the post status info panel (the sidebar area below the post status). Clicking it triggers a review pass:
Key Features:
const REVIEWABLE_BLOCK_TYPES = [
'core/paragraph',
'core/heading',
'core/list',
'core/list-item',
'core/quote',
'core/verse',
'core/image',
'core/table',
'core/preformatted',
'core/pullquote',
];Blocks with fewer than 20 characters of text content are skipped. The review is capped at 25 blocks per run to control cost.
array(
'block_type' => array(
'type' => 'string',
'sanitize_callback' => 'sanitize_text_field',
'description' => 'The block type, e.g. core/paragraph, core/heading.',
),
'block_content' => array(
'type' => 'string',
'sanitize_callback' => 'sanitize_text_field',
'description' => 'The plain-text content of the block to review.',
),
'context' => array(
'type' => 'string',
'sanitize_callback' => 'sanitize_text_field',
'description' => 'Surrounding content to improve review relevance.',
),
'post_id' => array(
'type' => 'integer',
'sanitize_callback' => 'absint',
'description' => 'ID of the post being reviewed.',
),
'existing_notes' => array(
'type' => 'array',
'items' => array( 'type' => 'string' ),
'description' => 'Existing Note texts for this block from prior review runs, used to avoid repeating suggestions.',
),
'review_types' => array(
'type' => 'array',
'items' => array( 'type' => 'string', 'enum' => array( 'accessibility', 'readability', 'grammar', 'seo' ) ),
'description' => 'Review types to perform.',
),
)array(
'type' => 'object',
'properties' => array(
'suggestions' => array(
'type' => 'array',
'items' => array(
'type' => 'object',
'properties' => array(
'review_type' => array( 'type' => 'string' ),
'text' => array( 'type' => 'string' ),
),
),
),
),
)The ability's permission_callback has two paths:
In both cases, users without the required capability receive an insufficient_capabilities WP_Error.
Notes are WP_Comment objects with comment_type = 'note' and status = 'hold'. Block association is maintained via block metadata:
POST /wp-json/wp-abilities/v1/abilities/ai/editorial-notes/run
See TESTING_REST_API.md for authentication details (application passwords or cookie + nonce).
curl -X POST "https://yoursite.com/wp-json/wp-abilities/v1/abilities/ai/editorial-notes/run" \
-u "username:application-password" \
-H "Content-Type: application/json" \
-d '{
"input": {
"block_type": "core/paragraph",
"block_content": "The committee was formed by the director in order to study the problem and make recommendations.",
"review_types": ["readability", "grammar"],
"existing_notes": [],
"post_id": 42
}
}'Response:
{
"suggestions": [
{
"review_type": "readability",
"text": "Rewrite in active voice: \"The director formed a committee to study the problem and make recommendations.\""
}
]
}curl -X POST "https://yoursite.com/wp-json/wp-abilities/v1/abilities/ai/editorial-notes/run" \
-u "username:application-password" \
-H "Content-Type: application/json" \
-d '{
"input": {
"block_type": "core/image",
"block_content": "",
"review_types": ["accessibility"],
"existing_notes": []
}
}'Response (missing alt text):
{
"suggestions": [
{
"review_type": "accessibility",
"text": "Add descriptive alt text to this image so screen reader users understand its content."
}
]
}import apiFetch from '@wordpress/api-fetch';
async function reviewBlock( blockType, blockContent, existingNotes = [] ) {
const result = await apiFetch( {
path: '/wp-abilities/v1/abilities/ai/editorial-notes/run',
method: 'POST',
data: {
input: {
block_type: blockType,
block_content: blockContent,
review_types: [ 'accessibility', 'readability', 'grammar', 'seo' ],
existing_notes: existingNotes,
context: String( postId ), // numeric post ID as string
},
},
} );
return result.suggestions; // Array of { review_type, text }
}| Code | Meaning |
|---|---|
| block_content_required | block_content was empty |
| post_not_found | The post ID passed does not exist |
| insufficient_capabilities | User lacks edit_posts (or edit_post for the specific post) |
Enable the experiment:
Run a review:
Re-run accumulation:
Resolved Notes:
Note deletion cleanup:
Edge cases:
| Back | FazBrowse Home | New Git URL |