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

AxeWP / wp-graphql-rank-math / 14947513062

10 May 2025 05:19PM UTC coverage: 86.429% (-2.0%) from 88.44%
14947513062

Pull #121

github

web-flow
Merge f69ff5d7f 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

83.61
/src/Type/WPInterface/Seo.php
1
<?php
2
/**
3
 * The shared SEO fields interface.
4
 *
5
 * @package WPGraphQL\RankMath\Type\WPInterface
6
 * @since 0.0.8
7
 */
8

9
declare( strict_types = 1 );
10

11
namespace WPGraphQL\RankMath\Type\WPInterface;
12

13
use RankMath\Helper;
14
use WPGraphQL\RankMath\Model\ContentNodeSeo;
15
use WPGraphQL\RankMath\Model\ContentTypeSeo;
16
use WPGraphQL\RankMath\Model\TermNodeSeo;
17
use WPGraphQL\RankMath\Model\UserSeo;
18
use WPGraphQL\RankMath\Type\WPObject\Breadcrumbs;
19
use WPGraphQL\RankMath\Type\WPObject\JsonLd;
20
use WPGraphQL\RankMath\Type\WPObject\OpenGraphMeta;
21
use WPGraphQL\RankMath\Vendor\AxeWP\GraphQL\Abstracts\InterfaceType;
22
use WPGraphQL\RankMath\Vendor\AxeWP\GraphQL\Traits\TypeResolverTrait;
23

24
/**
25
 * Class - Seo
26
 */
27
class Seo extends InterfaceType {
28
        use TypeResolverTrait;
29

30
        /**
31
         * {@inheritDoc}
32
         */
33
        protected static function type_name(): string {
34
                return 'Seo';
19✔
35
        }
36

37
        /**
38
         * {@inheritDoc}
39
         */
40
        public static function get_description(): string {
UNCOV
41
                return __( 'Base SEO fields shared across WP types.', 'wp-graphql-rank-math' );
×
42
        }
43

44
        /**
45
         * {@inheritDoc}
46
         */
47
        public static function get_fields(): array {
48
                $fields = [
19✔
49
                        'title'           => [
19✔
50
                                'type'        => 'String',
19✔
51
                                'description' => static fn () => __( 'The title.', 'wp-graphql-rank-math' ),
19✔
52
                        ],
19✔
53
                        'description'     => [
19✔
54
                                'type'        => 'String',
19✔
55
                                'description' => static fn () => __( 'The meta description.', 'wp-graphql-rank-math' ),
19✔
56
                        ],
19✔
57
                        'robots'          => [
19✔
58
                                'type'        => [ 'list_of' => 'String' ],
19✔
59
                                'description' => static fn () => __( 'A list of the robots meta properties to output.', 'wp-graphql-rank-math' ),
19✔
60
                        ],
19✔
61
                        'focusKeywords'   => [
19✔
62
                                'type'        => [ 'list_of' => 'String' ],
19✔
63
                                'description' => static fn () => __( 'The focus keywords you want to rank for', 'wp-graphql-rank-math' ),
19✔
64
                        ],
19✔
65
                        'canonicalUrl'    => [
19✔
66
                                'type'        => 'String',
19✔
67
                                'description' => static fn () => __( 'The canonical url.', 'wp-graphql-rank-math' ),
19✔
68
                        ],
19✔
69
                        'breadcrumbTitle' => [
19✔
70
                                'type'        => 'String',
19✔
71
                                'description' => static fn () => __( 'The title to use in the breadcrumbs for this post', 'wp-graphql-rank-math' ),
19✔
72
                        ],
19✔
73
                        'fullHead'        => [
19✔
74
                                'type'        => 'String',
19✔
75
                                'description' => static fn () => __( 'The fully-rendered `head` tag for the given item', 'wp-graphql-rank-math' ),
19✔
76
                        ],
19✔
77
                        'jsonLd'          => [
19✔
78
                                'type'        => JsonLd::get_type_name(),
19✔
79
                                'description' => static fn () => __( 'The JSON+LD data', 'wp-graphql-rank-math' ),
19✔
80
                        ],
19✔
81
                        'openGraph'       => [
19✔
82
                                'type'        => OpenGraphMeta::get_type_name(),
19✔
83
                                'description' => static fn () => __( 'The open graph meta properties.', 'wp-graphql-rank-math' ),
19✔
84
                        ],
19✔
85

86
                ];
19✔
87

88
                // Add breadcrumbs field.
89
                if ( Helper::is_breadcrumbs_enabled() ) {
19✔
90
                        $fields['breadcrumbs'] = [
7✔
91
                                'type'        => [ 'list_of' => Breadcrumbs::get_type_name() ],
7✔
92
                                'description' => static fn () => __( 'The breadcrumbs trail for the given object', 'wp-graphql-rank-math' ),
7✔
93
                        ];
7✔
94
                }
95

96
                return $fields;
19✔
97
        }
98

99
        /**
100
         * {@inheritDoc}
101
         *
102
         * @param \WPGraphQL\Model\Model $value The value from the resolver of the parent field.
103
         */
104
        public static function get_resolved_type_name( $value ): ?string {
105
                switch ( true ) {
106
                        case $value instanceof ContentNodeSeo:
1✔
107
                                $type_name = 'RankMath' . graphql_format_type_name( $value->get_object_type() . 'ObjectSeo' );
×
108
                                break;
×
109
                        case $value instanceof ContentTypeSeo:
1✔
110
                                $type_name = 'RankMath' . graphql_format_type_name( $value->get_object_type() . 'TypeSeo' );
1✔
111
                                break;
1✔
112
                        case $value instanceof TermNodeSeo:
×
113
                                $type_name = 'RankMath' . graphql_format_type_name( $value->get_object_type() . 'TermSeo' );
×
114
                                break;
×
115
                        case $value instanceof UserSeo:
×
116
                                $type_name = graphql_format_type_name( 'RankMathUserSeo' );
×
117
                                break;
×
118
                        default:
119
                                $type_name = null;
×
120
                }
121

122
                /**
123
                 * Filters the GraphQL Object type name for the given SEO model.
124
                 *
125
                 * @param string|null $type_name The GraphQL type name for the SEO Object.
126
                 * @param \WPGraphQL\Model\Model $model The SEO model for the type.
127
                 */
128
                $type_name = apply_filters( 'graphql_seo_resolved_type_name', $type_name, $value );
1✔
129

130
                return $type_name;
1✔
131
        }
132
}
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