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

AxeWP / wp-graphql-rank-math / 14814051199

03 May 2025 07:46PM UTC coverage: 86.429% (-2.0%) from 88.44%
14814051199

Pull #121

github

web-flow
Merge 10822768c into 3bd3ede8c
Pull Request #121: dev: add support for lazy-loading `description`/`deprecationReason` config values

356 of 366 new or added lines in 65 files covered. (97.27%)

60 existing lines in 60 files now uncovered.

2541 of 2940 relevant lines covered (86.43%)

11.01 hits per line

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

98.11
/src/Type/WPObject/Settings/Meta/TaxonomyMeta.php
1
<?php
2
/**
3
 * The TaxonomyMeta GraphQL object.
4
 *
5
 * @package WPGraphQL\RankMath\Type\WPObject\Settings\Meta
6
 */
7

8
declare( strict_types = 1 );
9

10
namespace WPGraphQL\RankMath\Type\WPObject\Settings\Meta;
11

12
use WPGraphQL\RankMath\Type\WPInterface\MetaSettingWithArchive;
13
use WPGraphQL\RankMath\Type\WPInterface\MetaSettingWithRobots;
14
use WPGraphQL\RankMath\Vendor\AxeWP\GraphQL\Abstracts\ObjectType;
15
use WPGraphQL\RankMath\Vendor\AxeWP\GraphQL\Helper\Compat;
16

17
/**
18
 * Class - TaxonomyMeta
19
 *
20
 * @phpstan-import-type FieldConfig from \WPGraphQL\RankMath\Vendor\AxeWP\GraphQL\Interfaces\TypeWithFields
21
 */
22
class TaxonomyMeta extends ObjectType {
23
        /**
24
         * {@inheritDoc}
25
         */
26
        protected static function type_name(): string {
27
                return 'TaxonomyMetaSettings';
19✔
28
        }
29

30
        /**
31
         * {@inheritDoc}
32
         */
33
        public static function get_description(): string {
UNCOV
34
                return __( 'The RankMath SEO Taxonomy meta settings.', 'wp-graphql-rank-math' );
×
35
        }
36

37
        /**
38
         * {@inheritDoc}
39
         */
40
        public static function register(): void {
41
                /** @var \WP_Taxonomy[] */
42
                $allowed_taxonomies = \WPGraphQL::get_allowed_taxonomies( 'objects', [ 'public' => true ] );
19✔
43

44
                foreach ( $allowed_taxonomies as $tax_object ) {
19✔
45
                        $interfaces = [
19✔
46
                                MetaSettingWithRobots::get_type_name(),
19✔
47
                                MetaSettingWithArchive::get_type_name(),
19✔
48
                        ];
19✔
49

50
                        register_graphql_object_type(
19✔
51
                                ucfirst( $tax_object->graphql_single_name ) . 'MetaSettings',
19✔
52
                                Compat::resolve_graphql_config( // @todo Remove when WPGraphQL < 2.3.0 is dropped.
19✔
53
                                        [
19✔
54
                                                'description' => static fn () => sprintf(
19✔
55
                                                // translators: post type name.
56
                                                        __( 'The RankMath SEO meta settings for %s.', 'wp-graphql-rank-math' ),
19✔
57
                                                        $tax_object->label,
19✔
58
                                                ),
19✔
59
                                                'interfaces'  => $interfaces,
19✔
60
                                                'fields'      => self::get_child_type_fields( $tax_object ),
19✔
61
                                        ]
19✔
62
                                ),
19✔
63
                        );
19✔
64
                }
65

66
                parent::register();
19✔
67
        }
68

69
        /**
70
         * {@inheritDoc}
71
         */
72
        public static function get_fields(): array {
73
                /** @var \WP_Taxonomy[] */
74
                $allowed_taxonomies = \WPGraphQL::get_allowed_taxonomies( 'objects', [ 'public' => true ] );
19✔
75

76
                $fields = [];
19✔
77

78
                foreach ( $allowed_taxonomies as $tax_object ) {
19✔
79
                        $fields[ lcfirst( $tax_object->graphql_single_name ) ] = [
19✔
80
                                'type'        => $tax_object->graphql_single_name . 'MetaSettings',
19✔
81
                                'description' => static fn () => sprintf(
19✔
82
                                        // translators: taxonomy name.
83
                                        __( 'The RankMath SEO meta settings for %s.', 'wp-graphql-rank-math' ),
19✔
84
                                        $tax_object->label,
19✔
85
                                ),
19✔
86
                        ];
19✔
87
                }
88

89
                return $fields;
19✔
90
        }
91

92
        /**
93
         * Get the fields for the provided content type.
94
         *
95
         * @param \WP_Taxonomy $tax_object .
96
         *
97
         * @return array<string, FieldConfig>
98
         */
99
        public static function get_child_type_fields( \WP_Taxonomy $tax_object ): array {
100
                $fields = [
19✔
101
                        'hasCustomRobotsMeta'     => [
19✔
102
                                'type'        => 'Boolean',
19✔
103
                                'description' => static fn () => __( 'Whether custom robots meta for author page are set. Otherwise the default meta will be used, as set in the Global Meta tab.', 'wp-graphql-rank-math' ),
19✔
104
                        ],
19✔
105
                        'hasSlackEnhancedSharing' => [
19✔
106
                                'type'        => 'Boolean',
19✔
107
                                'description' => static fn () => __( 'Whether to show additional information (name & total number of posts) when an author archive is shared on Slack.', 'wp-graphql-rank-math' ),
19✔
108
                        ],
19✔
109
                ];
19✔
110

111
                if ( 'post_format' !== $tax_object->name ) {
19✔
112
                        $fields['hasSeoControls'] = [
19✔
113
                                'type'        => 'Boolean',
19✔
114
                                'description' => static fn () => __( 'Whether the SEO Controls meta box for user profile pages is enabled.', 'wp-graphql-rank-math' ),
19✔
115
                        ];
19✔
116
                        $fields['hasSnippetData'] = [
19✔
117
                                'type'        => 'Boolean',
19✔
118
                                'description' => static fn () => __( 'Whether to include snippet data for this taxonomy.', 'wp-graphql-rank-math' ),
19✔
119
                        ];
19✔
120
                }
121

122
                return $fields;
19✔
123
        }
124
}
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