| @@ -58,8 +58,31 @@ | ||
| 58 | 58 | return !in_array($object->name, self::excluded_post_types($object), true); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | + * Every post type that passes {@see self::is_allowed()}. | |
| 63 | + * | |
| 64 | + * The sitewide half of duplicate snippet detection needs the whole list | |
| 65 | + * rather than one name, because a duplicate title is a duplicate whichever | |
| 66 | + * post type the other page happens to be (#564). | |
| 67 | + * | |
| 68 | + * @since 2.10.0 | |
| 69 | + * | |
| 70 | + * @return string[] Post type names. | |
| 71 | + */ | |
| 72 | + public static function allowed(): array { | |
| 73 | + $allowed = []; | |
| 74 | + | |
| 75 | + foreach (get_post_types(['public' => true], 'objects') as $object) { | |
| 76 | + if (self::is_allowed($object)) { | |
| 77 | + $allowed[] = $object->name; | |
| 78 | + } | |
| 79 | + } | |
| 80 | + | |
| 81 | + return $allowed; | |
| 82 | + } | |
| 83 | + | |
| 84 | + /** | |
| 62 | 85 | * Builder and utility CPTs that are not optimizable content. |
| 63 | 86 | * |
| 64 | 87 | * These register `public => true` for preview purposes but are layout |
| 65 | 88 | * fragments, not pages anyone gives a title and a meta description. |