fix: find-similar marks replaceable matches and names excluded types (review M-3, M-7, M-8)

Every match carries replaceable: true only when it is identical and in a
page or post, the scope lit/library-make-global replaces; the description
and the guide say so. An excluded post type is answered like any
unavailable one, by its name (PostGuard::unavailableType()), and the
excluded list takes the Theme Builder types from DiviThemeBuilder::postTypes().

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:
2026-09-27 23:09:13 +02:00
co-authored by Claude Opus 5.5
parent 5290a9d81d
commit e7bbe1e9d7
4 changed files with 80 additions and 28 deletions
+10 -4
View File
@@ -136,15 +136,21 @@ final class PostGuard
* so a plain `object` return type is accurate and still lets callers branch with
* `is_wp_error()` / `instanceof WP_Error`, exactly like editable() above.
*/
/** The answer for a post type that is not available to the tools – the same for unknown and excluded ones. */
public static function unavailableType(string $name): WP_Error
{
return Errors::notFound(
sprintf('Inhaltstyp "%s" ist nicht verfügbar.', $name),
'Verfügbare Inhaltstypen über lit/content-types (direkt: lit-content-types) abrufen.'
);
}
public static function postType(mixed $postType, ContentSchema $schema, string $cap): object
{
$name = is_string($postType) ? $postType : '';
$object = $name !== '' && $schema->isManaged($name) ? get_post_type_object($name) : null;
if (! is_object($object)) {
return Errors::notFound(
sprintf('Inhaltstyp "%s" ist nicht verfügbar.', $name),
'Verfügbare Inhaltstypen über lit/content-types (direkt: lit-content-types) abrufen.'
);
return self::unavailableType($name);
}
$capability = isset($object->cap->{$cap}) ? (string) $object->cap->{$cap} : $cap;