true` only for previews); and it must not be on the filterable * `thinkrank_global_seo_excluded_post_types` deny list. * * @param \WP_Post_Type|string $post_type Post type object or name. * @return bool */ public static function is_allowed($post_type): bool { $object = is_string($post_type) ? get_post_type_object($post_type) : $post_type; if (!$object instanceof \WP_Post_Type || empty($object->public)) { return false; } // Builder/utility CPTs that register public => true for preview purposes // but aren't front-end viewable content (e.g. Elementor's "Floating // Elements"). Built-in types (post/page/attachment) are always kept. if ($object->_builtin === false && !is_post_type_viewable($object)) { return false; } return !in_array($object->name, self::excluded_post_types($object), true); } /** * Every post type that passes {@see self::is_allowed()}. * * The sitewide half of duplicate snippet detection needs the whole list * rather than one name, because a duplicate title is a duplicate whichever * post type the other page happens to be (#564). * * @since 2.10.0 * * @return string[] Post type names. */ public static function allowed(): array { $allowed = []; foreach (get_post_types(['public' => true], 'objects') as $object) { if (self::is_allowed($object)) { $allowed[] = $object->name; } } return $allowed; } /** * Builder and utility CPTs that are not optimizable content. * * These register `public => true` for preview purposes but are layout * fragments, not pages anyone gives a title and a meta description. * * Shared rather than duplicated: the per-post SEO metabox discovers post * types by the same public/`show_ui` rule and used to keep its own * exclusion list, which named only WordPress internals. The two policies * disagreed — a builder template CPT was denied Global SEO while still * getting a full metabox — so both now read this one list (#621). * * @since 2.2.1 * * Deliberately untyped: this is passed straight to a public filter whose * existing contract accepts whatever the caller has (a `WP_Post_Type`, or * null when the list is wanted without a subject). * * @param mixed $post_type_object Post type being judged, passed to the filter. * @return string[] Post type names to exclude. */ public static function excluded_post_types($post_type_object = null): array { // Filterable so integrators can tune it without patching core. The // post-type object is passed as the second argument (matches the admin // discovery filter usage). $excluded = apply_filters('thinkrank_global_seo_excluded_post_types', [ 'elementor_library', 'oceanwp_library', 'ae_global_templates', 'e-floating-buttons', 'elementor_component', // Divi: the library plus every Theme Builder template type. 'et_pb_layout', 'et_theme_builder', 'et_template', 'et_header_layout', 'et_body_layout', 'et_footer_layout', // Beaver Builder: saved templates (rows, columns, modules) and // Beaver Themer's layouts. Same clutter Divi's Theme Builder // templates caused before they were listed here (#449). 'fl-builder-template', 'fl-theme-layout', // Bricks: saved templates plus the header/footer/section layouts // its Theme Builder stores as the same CPT (#257). 'bricks_template', ], $post_type_object); return array_values(array_filter((array) $excluded, 'is_string')); } }