PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.4
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.4
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / schema-aggregator / infrastructure / aggregator-config.php

aggregator-config.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.4, at src/schema-aggregator/infrastructure/aggregator-config.php

78 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
3 namespace Yoast\WP\SEO\Schema_Aggregator\Infrastructure;
4
5 use Yoast\WP\SEO\Conditionals\WooCommerce_Conditional;
6 use Yoast\WP\SEO\Helpers\Post_Type_Helper;
7 /**
8 * Configuration for the Schema Aggregator.
9 */
10 class Aggregator_Config {
11 /**
12 * Default schema types to include (whitelist)
13 *
14 * @var array<string>
15 */
16 private const DEFAULT_SCHEMA_TYPES = [
17 'Recipe',
18 'Article',
19 'Product',
20 'ProductGroup',
21 'Event',
22 'Person',
23 'Organization',
24 'WebSite',
25 ];
26
27 /**
28 * The WooCommerce Conditional.
29 *
30 * @var WooCommerce_Conditional
31 */
32 private $woocommerce_conditional;
33
34 /**
35 * The Post Type Helper.
36 *
37 * @var Post_Type_Helper
38 */
39 private $post_type_helper;
40
41 /**
42 * Aggregator_Config constructor.
43 *
44 * @param WooCommerce_Conditional $woocommerce_conditional The WooCommerce Conditional.
45 * @param Post_Type_Helper $post_type_helper The Post Type Helper.
46 */
47 public function __construct( WooCommerce_Conditional $woocommerce_conditional, Post_Type_Helper $post_type_helper ) {
48 $this->woocommerce_conditional = $woocommerce_conditional;
49 $this->post_type_helper = $post_type_helper;
50 }
51
52 /**
53 * Get configured post types
54 *
55 * @return array<string>
56 */
57 public function get_allowed_post_types(): array {
58 $default_post_types = $this->post_type_helper->get_indexable_post_types();
59
60 foreach ( $default_post_types as $key => $post_type ) {
61 if ( ! $this->post_type_helper->is_indexable( $post_type ) ) {
62 unset( $default_post_types[ $key ] );
63 }
64 }
65
66 // Reindex the array to avoid gaps.
67 $default_post_types = \array_values( $default_post_types );
68
69 $post_types = \apply_filters( 'wpseo_schema_aggregator_post_types', $default_post_types );
70
71 if ( ! \is_array( $post_types ) ) {
72 return $default_post_types;
73 }
74
75 return $post_types;
76 }
77 }
78