Description
The plugin's options are almost universally namespaced with the wpai_ prefix (wpai_features_enabled, wpai_feature_*, wpai_version, etc.), but the post meta keys are inconsistent:
| Current meta key |
Prefix |
Where registered |
wpai_meta_description |
✅ wpai_ |
SEO_Integration::FALLBACK_META_KEY |
ai_generated |
❌ ai_ |
Image Generation feature |
ai_generated_summary |
❌ ai_ |
Summarization experiment |
ai_note |
❌ ai_ |
Comment Generation experiment |
wpai_meta_description already follows the convention, so it can serve as the reference. The two ai_-prefixed keys (ai_generated, ai_generated_summary) should be renamed so all plugin-owned meta consistently uses the wpai_ prefix.
This makes plugin data easier to identify, query, and clean up (e.g. the uninstall routine can then rely on a single wpai_ prefix sweep).
Proposed rename
| Old key |
New key |
ai_generated |
wpai_generated |
ai_generated_summary |
wpai_generated_summary |
ai_note |
wpai_note |
(Exact new names are open for discussion — the goal is simply a consistent wpai_ prefix.)
Important: this is a breaking change and needs a data migration
Renaming a meta key changes:
- The row stored in
wp_postmeta (existing content keeps the old key).
- The row stored in
wp_commentmeta (existing content keeps the old key).
- The REST API field name (since these are registered with
show_in_rest), which the editor JS reads/writes.
So the rename must ship with a migration that copies existing values from the old key to the new key (and removes the old one) for all affected posts, comments meta, plus a lockstep update of every PHP and JS reference. Without a migration, existing AI-generated flags and saved summaries would be orphaned.
Files to change
1. Meta registration
includes/Features/Image_Generation/Image_Generation.php -
|
public function register_post_meta(): void { |
|
register_post_meta( |
|
'attachment', |
|
'ai_generated', |
|
array( |
|
'type' => 'integer', |
|
'single' => true, |
|
'show_in_rest' => true, |
|
) |
|
); |
|
} |
includes/Experiments/Summarization/Summarization.php -
|
public function register_post_meta(): void { |
|
register_meta( |
|
'post', |
|
'ai_generated_summary', |
|
array( |
|
'type' => 'string', |
|
'single' => true, |
|
'show_in_rest' => true, |
|
) |
|
); |
|
} |
includes/Experiments/Editorial_Notes/Editorial_Notes.php -
|
register_meta( |
|
'comment', |
|
'ai_note', |
|
array( |
|
if ( ! is_array( $meta ) || empty( $meta['ai_note'] ) ) { |
|
return $prepared_comment; |
|
} |
2. PHP read/write of the meta
includes/Abilities/Image/Import_Base64_Image.php -
|
if ( $args['ai_generated'] ) { |
|
$post_data['meta_input']['ai_generated'] = 1; |
|
} |
3. Editor JavaScript / TypeScript (must change in lockstep with REST field)
src/experiments/summarization/bulk.ts -
|
await apiFetch( { |
|
path: `/wp/v2/${ restBase }/${ id }`, |
|
method: 'POST', |
|
data: { |
|
content: newContent, |
|
meta: { ai_generated_summary: summary }, |
|
}, |
src/experiments/summarization/functions/useSummaryGeneration.ts -
|
editPost( { |
|
meta: { |
|
...meta, |
|
ai_generated_summary: generatedSummary, |
|
}, |
|
} ); |
src/features/image-generation/components/AILabel.tsx -
|
{ image && image?.meta?.ai_generated === 1 && ( |
src/experiments/editorial-notes/hooks/useEditorialNotes.ts -
|
post: postId, |
|
content: noteContent, |
|
type: 'note', |
|
status: 'hold', |
|
parent: existingNoteId ?? 0, |
|
meta: { ai_note: true }, |
4. New migration
includes/Admin/Upgrades/V_x_x_x.php (new) — extend Abstract_Upgrade, copy ai_generated → wpai_generated and ai_generated_summary → wpai_generated_summary for existing posts, then delete the old keys.
includes/Admin/Upgrades.php (line ~51, UPGRADE_CLASSES) — register the new upgrade class (follows the existing V0_5_0 / V0_6_0 / V1_0_0 pattern).
5. Uninstall cleanup
includes/Admin/Uninstall.php (delete_meta()) — update the meta key patterns; after the rename, both keys fall under the wpai_ prefix so the cleanup can be simplified accordingly.
6. Tests
tests/Integration/Includes/Features/Image_Generation/Image_GenerationTest.php -
|
$this->assertEquals( 'integer', $meta['ai_generated']['type'], 'ai_generated meta type should be integer' ); |
|
$this->assertTrue( $meta['ai_generated']['show_in_rest'], 'ai_generated meta should be available in REST API' ); |
tests/Integration/Includes/Abilities/Image_ImportTest.php -
|
$this->assertSame( '1', get_post_meta( $result['image']['id'], 'ai_generated', true ), 'AI-generated flag should be saved' ); |
tests/Integration/Includes/Experiments/Editorial_Notes/Editorial_NotesTest.php and wp-content/plugins/ai/tests/e2e/specs/experiments/editorial-updates.spec.js
- Add a test for the new migration (old key → new key, old key removed).
Acceptance criteria
Step-by-step reproduction instructions
- Enable AI Plugin.
- Generate AI summary on any post/page with content.
- Check the DB, and notice the meta stored for that post ID has key
ai_generated_summary.
- Generate the meta description.
- Check for the same post ID and would have key
wpai_meta_description.
Screenshots, screen recording, code snippet
Environment info
- WordPress 7.0.1.
- AI plugin develop branch.
- No extra plugin/theme activated.
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except the AI plugin.
Please confirm which theme type you used for testing.
Usage of AI tool
- Claude Opus 4.8 to generate the description and PR title.
- Used to make it more polished and detailed.
Description
The plugin's options are almost universally namespaced with the
wpai_prefix (wpai_features_enabled,wpai_feature_*,wpai_version, etc.), but the post meta keys are inconsistent:wpai_meta_descriptionwpai_SEO_Integration::FALLBACK_META_KEYai_generatedai_ai_generated_summaryai_ai_noteai_wpai_meta_descriptionalready follows the convention, so it can serve as the reference. The twoai_-prefixed keys (ai_generated,ai_generated_summary) should be renamed so all plugin-owned meta consistently uses thewpai_prefix.This makes plugin data easier to identify, query, and clean up (e.g. the uninstall routine can then rely on a single
wpai_prefix sweep).Proposed rename
ai_generatedwpai_generatedai_generated_summarywpai_generated_summaryai_notewpai_note(Exact new names are open for discussion — the goal is simply a consistent
wpai_prefix.)Important: this is a breaking change and needs a data migration
Renaming a meta key changes:
wp_postmeta(existing content keeps the old key).wp_commentmeta(existing content keeps the old key).show_in_rest), which the editor JS reads/writes.So the rename must ship with a migration that copies existing values from the old key to the new key (and removes the old one) for all affected posts, comments meta, plus a lockstep update of every PHP and JS reference. Without a migration, existing AI-generated flags and saved summaries would be orphaned.
Files to change
1. Meta registration
includes/Features/Image_Generation/Image_Generation.php-ai/includes/Features/Image_Generation/Image_Generation.php
Lines 134 to 144 in 8c3606a
includes/Experiments/Summarization/Summarization.php-ai/includes/Experiments/Summarization/Summarization.php
Lines 89 to 99 in 8c3606a
includes/Experiments/Editorial_Notes/Editorial_Notes.php-ai/includes/Experiments/Editorial_Notes/Editorial_Notes.php
Lines 60 to 63 in 656fbde
ai/includes/Experiments/Editorial_Notes/Editorial_Notes.php
Lines 117 to 119 in 656fbde
2. PHP read/write of the meta
includes/Abilities/Image/Import_Base64_Image.php-ai/includes/Abilities/Image/Import_Base64_Image.php
Lines 297 to 299 in 8c3606a
3. Editor JavaScript / TypeScript (must change in lockstep with REST field)
src/experiments/summarization/bulk.ts-ai/src/experiments/summarization/bulk.ts
Lines 165 to 171 in 8c3606a
src/experiments/summarization/functions/useSummaryGeneration.ts-ai/src/experiments/summarization/functions/useSummaryGeneration.ts
Lines 82 to 87 in 8c3606a
src/features/image-generation/components/AILabel.tsx-ai/src/features/image-generation/components/AILabel.tsx
Line 51 in 8c3606a
src/experiments/editorial-notes/hooks/useEditorialNotes.ts-ai/src/experiments/editorial-notes/hooks/useEditorialNotes.ts
Lines 477 to 482 in 656fbde
4. New migration
includes/Admin/Upgrades/V_x_x_x.php(new) — extendAbstract_Upgrade, copyai_generated→wpai_generatedandai_generated_summary→wpai_generated_summaryfor existing posts, then delete the old keys.includes/Admin/Upgrades.php(line ~51,UPGRADE_CLASSES) — register the new upgrade class (follows the existingV0_5_0/V0_6_0/V1_0_0pattern).5. Uninstall cleanup
includes/Admin/Uninstall.php(delete_meta()) — update the meta key patterns; after the rename, both keys fall under thewpai_prefix so the cleanup can be simplified accordingly.6. Tests
tests/Integration/Includes/Features/Image_Generation/Image_GenerationTest.php-ai/tests/Integration/Includes/Features/Image_Generation/Image_GenerationTest.php
Lines 131 to 132 in 8c3606a
tests/Integration/Includes/Abilities/Image_ImportTest.php-ai/tests/Integration/Includes/Abilities/Image_ImportTest.php
Line 261 in 8c3606a
tests/Integration/Includes/Experiments/Editorial_Notes/Editorial_NotesTest.phpandwp-content/plugins/ai/tests/e2e/specs/experiments/editorial-updates.spec.jsAcceptance criteria
ai_generated,ai_generated_summaryandai_noterenamed towpai_-prefixed keys across PHP and JS.Step-by-step reproduction instructions
ai_generated_summary.wpai_meta_description.Screenshots, screen recording, code snippet
Environment info
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except the AI plugin.
Please confirm which theme type you used for testing.
Usage of AI tool