• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / 206a3a63b4f934f01dbd25b9bb584b937ff1a44b

05 Feb 2026 11:15AM UTC coverage: 51.231% (-1.7%) from 52.911%
206a3a63b4f934f01dbd25b9bb584b937ff1a44b

push

github

web-flow
Merge pull request #22948 from Yoast/1052-keep-website-node-since-its-so-central-to-our-graph-but-remove-unneeded-nodes

Loosen our filtering a bit for website specific nodes to keep the integrity of the schema web.

3428 of 6452 branches covered (53.13%)

Branch coverage included in aggregate %.

12474 of 24588 relevant lines covered (50.73%)

117276.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.24
/src/schema-aggregator/application/filtering/default-filter.php
1
<?php
2
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
3
namespace Yoast\WP\SEO\Schema_Aggregator\Application\Filtering;
4

5
use Yoast\WP\SEO\Schema_Aggregator\Application\Filtering\Schema_Node_Property_Filter\Base_Schema_Node_Property_Filter;
6
use Yoast\WP\SEO\Schema_Aggregator\Domain\Schema_Piece_Collection;
7
use Yoast\WP\SEO\Schema_Aggregator\Infrastructure\Elements_Context_Map\Elements_Context_Map_Repository_Interface;
8

9
/**
10
 * Default filtering strategy implementation.
11
 */
12
class Default_Filter implements Filtering_Strategy_Interface {
13

14
        /**
15
         * The categories to filter.
16
         *
17
         * @var array<string>
18
         */
19
        private $filter_categories = [
20
                'action',
21
                'enumeration',
22
                'meta',
23
                'website-meta',
24
        ];
25

26
        /**
27
         * The elements context map repository.
28
         *
29
         * @var Elements_Context_Map_Repository_Interface
30
         */
31
        private $elements_context_map_repository;
32

33
        /**
34
         * Class constructor.
35
         *
36
         * @param Elements_Context_Map_Repository_Interface $elements_context_map_repository The elements-context map repository.
37
         */
38
        public function __construct( Elements_Context_Map_Repository_Interface $elements_context_map_repository ) {
2✔
39
                $this->elements_context_map_repository = $elements_context_map_repository;
2✔
40
        }
41

42
        /**
43
         * Applies filtering to the given schema.
44
         *
45
         * @param Schema_Piece_Collection $schema The schema to be filtered.
46
         *
47
         * @return Schema_Piece_Collection The filtered schema.
48
         */
49
        public function filter( Schema_Piece_Collection $schema ): Schema_Piece_Collection {
18✔
50
                $filtered_schema      = [];
18✔
51
                $elements_context_map = $this->elements_context_map_repository->get_map();
18✔
52
                foreach ( $schema->to_array() as $schema_piece ) {
18✔
53
                        $should_keep = true;
16✔
54
                        foreach ( $this->filter_categories as $category ) {
16✔
55
                                if ( \in_array( $schema_piece->get_type(), $elements_context_map[ $category ], true ) ) {
16✔
56
                                        $filter_class_name = 'Yoast\WP\SEO\Schema_Aggregator\Application\Filtering\Schema_Node_Filter\\' . $schema_piece->get_type() . '_Schema_Node_Filter';
6✔
57
                                        if ( \class_exists( $filter_class_name ) && \is_a( $filter_class_name, 'Yoast\WP\SEO\Schema_Aggregator\Application\Filtering\Schema_Node_Filter\Schema_Node_Filter_Decider_Interface', true ) ) {
6✔
58
                                                $should_keep = ( new $filter_class_name() )->should_filter( $schema, $schema_piece );
×
59
                                        }
60
                                        else {
61
                                                $should_keep = false;
6✔
62
                                        }
63
                                        break;
6✔
64
                                }
65
                        }
66
                        if ( $should_keep ) {
16✔
67
                                $properties_filter_class_name = 'Yoast\WP\SEO\Schema_Aggregator\Application\Filtering\Schema_Node_Property_Filter\\' . $schema_piece->get_type() . '_Schema_Node_Property_Filter';
16✔
68
                                if ( \class_exists( $properties_filter_class_name ) && \is_a( $properties_filter_class_name, 'Yoast\WP\SEO\Schema_Aggregator\Application\Filtering\Schema_Node_Property_Filter\Schema_Node_Property_Filter_Interface', true ) ) {
16✔
69
                                        $schema_piece = ( new $properties_filter_class_name() )->filter_properties( $schema_piece );
4✔
70
                                }
71
                                else {
72
                                        $schema_piece = ( new Base_Schema_Node_Property_Filter() )->filter_properties( $schema_piece );
14✔
73
                                }
74
                                $filtered_schema[] = $schema_piece;
16✔
75
                        }
76
                }
77
                return new Schema_Piece_Collection( $filtered_schema );
18✔
78
        }
79
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc