| @@ -54,9 +54,56 @@ | ||
| 54 | 54 | if ($object->_builtin === false && !is_post_type_viewable($object)) { |
| 55 | 55 | return false; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - // Named deny list for viewable-but-unsuitable builder/utility CPTs. | |
| 58 | + return !in_array($object->name, self::excluded_post_types($object), true); | |
| 59 | + } | |
| 60 | + | |
| 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 | + /** | |
| 85 | + * Builder and utility CPTs that are not optimizable content. | |
| 86 | + * | |
| 87 | + * These register `public => true` for preview purposes but are layout | |
| 88 | + * fragments, not pages anyone gives a title and a meta description. | |
| 89 | + * | |
| 90 | + * Shared rather than duplicated: the per-post SEO metabox discovers post | |
| 91 | + * types by the same public/`show_ui` rule and used to keep its own | |
| 92 | + * exclusion list, which named only WordPress internals. The two policies | |
| 93 | + * disagreed — a builder template CPT was denied Global SEO while still | |
| 94 | + * getting a full metabox — so both now read this one list (#621). | |
| 95 | + * | |
| 96 | + * @since 2.2.1 | |
| 97 | + * | |
| 98 | + * Deliberately untyped: this is passed straight to a public filter whose | |
| 99 | + * existing contract accepts whatever the caller has (a `WP_Post_Type`, or | |
| 100 | + * null when the list is wanted without a subject). | |
| 101 | + * | |
| 102 | + * @param mixed $post_type_object Post type being judged, passed to the filter. | |
| 103 | + * @return string[] Post type names to exclude. | |
| 104 | + */ | |
| 105 | + public static function excluded_post_types($post_type_object = null): array { | |
| 59 | 106 | // Filterable so integrators can tune it without patching core. The |
| 60 | 107 | // post-type object is passed as the second argument (matches the admin |
| 61 | 108 | // discovery filter usage). |
| 62 | 109 | $excluded = apply_filters('thinkrank_global_seo_excluded_post_types', [ |
| @@ -68,9 +115,12 @@ | ||
| 68 | 115 | // Beaver Builder: saved templates (rows, columns, modules) and |
| 69 | 116 | // Beaver Themer's layouts. Same clutter Divi's Theme Builder |
| 70 | 117 | // templates caused before they were listed here (#449). |
| 71 | 118 | 'fl-builder-template', 'fl-theme-layout', |
| 72 | - ], $object); | |
| 119 | + // Bricks: saved templates plus the header/footer/section layouts | |
| 120 | + // its Theme Builder stores as the same CPT (#257). | |
| 121 | + 'bricks_template', | |
| 122 | + ], $post_type_object); | |
| 73 | 123 | |
| 74 | - return !in_array($object->name, (array) $excluded, true); | |
| 124 | + return array_values(array_filter((array) $excluded, 'is_string')); | |
| 75 | 125 | } |
| 76 | 126 | } |