feat: field validation, term resolution, post guard and revision points
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Integrations\WordPress;
|
||||
|
||||
/**
|
||||
* Restore point before a change (spec §2 principle 7): WordPress stores the
|
||||
* current state as a revision (only if it differs from the newest one) and the
|
||||
* newest revision ID is returned as revision_id of the ToolResult.
|
||||
* Note: revisions cover title, content and excerpt; meta and terms are not revisioned.
|
||||
*/
|
||||
final class RevisionPoint
|
||||
{
|
||||
public static function capture(int $postId): ?int
|
||||
{
|
||||
wp_save_post_revision($postId);
|
||||
|
||||
return self::latest($postId);
|
||||
}
|
||||
|
||||
public static function latest(int $postId): ?int
|
||||
{
|
||||
$revisions = wp_get_post_revisions($postId, ['posts_per_page' => 1]);
|
||||
$newest = is_array($revisions) ? reset($revisions) : false;
|
||||
|
||||
return is_object($newest) ? (int) $newest->ID : null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user