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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user