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

AxeWP / wp-graphql-rank-math / 15507492505

07 Jun 2025 11:44AM UTC coverage: 86.429% (-2.0%) from 88.44%
15507492505

push

github

web-flow
dev: add support for lazy-loading `description`/`deprecationReason` config values (#121)

* chore: update strauss and deps

* dev: use callable descriptions/deprecations

* fix: dont prefix `NodeWithRankMathSeo`

* chore: fix backcompat on connections

* chore: update dep

* chore: update deps

* tests: ensure schema can build

* chore: update and cleanup

* fix: regenerate autoloader

357 of 367 new or added lines in 66 files covered. (97.28%)

60 existing lines in 60 files now uncovered.

2541 of 2940 relevant lines covered (86.43%)

11.49 hits per line

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

81.73
/src/Type/WPObject/OpenGraphMeta.php
1
<?php
2
/**
3
 * The Rank Math OpenGraph meta tags GraphQL Object.
4
 *
5
 * @package WPGraphQL\RankMath\Type\WPObject
6
 */
7

8
declare( strict_types = 1 );
9

10
namespace WPGraphQL\RankMath\Type\WPObject;
11

12
use WPGraphQL\RankMath\Type\Enum\OpenGraphLocaleEnum;
13
use WPGraphQL\RankMath\Type\WPObject\OpenGraph;
14
use WPGraphQL\RankMath\Vendor\AxeWP\GraphQL\Abstracts\ObjectType;
15

16
/**
17
 * Class - OpenGraphMeta
18
 */
19
class OpenGraphMeta extends ObjectType {
20
        /**
21
         * {@inheritDoc}
22
         */
23
        protected static function type_name(): string {
24
                return 'OpenGraphMeta';
20✔
25
        }
26

27
        /**
28
         * {@inheritDoc}
29
         */
30
        public static function get_description(): string {
UNCOV
31
                return __( 'The OpenGraph meta.', 'wp-graphql-rank-math' );
×
32
        }
33

34
        /**
35
         * {@inheritDoc}
36
         */
37
        public static function get_fields(): array {
38
                return [
20✔
39
                        'articleMeta'       => [
20✔
40
                                'type'        => OpenGraph\Article::get_type_name(),
20✔
41
                                'description' => static fn () => __( 'The OpenGraph Article meta.', 'wp-graphql-rank-math' ),
20✔
42
                                'resolve'     => static fn ( $source ): ?array => ! empty( $source['article'] ) ? $source['article'] : null,
20✔
43
                        ],
20✔
44
                        'alternateLocales'  => [
20✔
45
                                'type'        => [ 'list_of' => OpenGraphLocaleEnum::get_type_name() ],
20✔
46
                                'description' => static fn () => __( 'A list of other locales this page is available in', 'wp-graphql-rank-math' ),
20✔
47
                                'resolve'     => static function ( $source ): ?array {
20✔
48
                                        $value = ! empty( $source['og']['locale:alternate'] ) ? $source['og']['locale:alternate'] : null;
1✔
49

50
                                        if ( is_string( $value ) ) {
1✔
51
                                                $value = [ $value ];
×
52
                                        }
53

54
                                        return $value;
1✔
55
                                },
20✔
56
                        ],
20✔
57
                        'description'       => [
20✔
58
                                'type'        => 'String',
20✔
59
                                'description' => static fn () => __( 'A brief description of the content, usually between 2 and 4 sentences. ', 'wp-graphql-rank-math' ),
20✔
60
                                'resolve'     => static fn ( $source ): ?string => ! empty( $source['og']['description'] ) ? (string) $source['og']['description'] : null,
20✔
61
                        ],
20✔
62
                        'image'             => [
20✔
63
                                'type'        => OpenGraph\Image::get_type_name(),
20✔
64
                                'description' => static fn () => __( 'The OpenGraph image meta', 'wp-graphql-rank-math' ),
20✔
65
                                'resolve'     => static function ( $source ): ?array {
20✔
66
                                        $values = ! empty( $source['og']['image'] ) ? $source['og']['image'] : [];
×
67

68
                                        if ( ! empty( $source['og']['image'][0] ) ) {
×
69
                                                $values['url'] = (string) $source['og']['image'][0];
×
70
                                        }
71

72
                                        return ! empty( $values ) ? $values : null;
×
73
                                },
20✔
74
                        ],
20✔
75
                        'facebookMeta'      => [
20✔
76
                                'type'        => OpenGraph\Facebook::get_type_name(),
20✔
77
                                'description' => static fn () => __( 'The Facebook OpenGraph meta values.', 'wp-graphql-rank-math' ),
20✔
78
                                'resolve'     => static fn ( $source ): ?array => ! empty( $source['fb'] ) ? $source['fb'] : null,
20✔
79

80
                        ],
20✔
81
                        'locale'            => [
20✔
82
                                'type'        => OpenGraphLocaleEnum::get_type_name(),
20✔
83
                                'description' => static fn () => __( 'The locale of the resource.', 'wp-graphql-rank-math' ),
20✔
84
                                'resolve'     => static fn ( $source ): ?string => ! empty( $source['og']['locale'] ) ? $source['og']['locale'] : null,
20✔
85
                        ],
20✔
86
                        'productMeta'       => [
20✔
87
                                'type'        => OpenGraph\Product::get_type_name(),
20✔
88
                                'description' => static fn () => __( 'The Facebook OpenGraph meta values.', 'wp-graphql-rank-math' ),
20✔
89
                                'resolve'     => static fn ( $source ) => ! empty( $source['product'] ) ? $source['product'] : null,
20✔
90
                        ],
20✔
91
                        'slackEnhancedData' => [
20✔
92
                                'type'        => [ 'list_of' => OpenGraph\SlackEnhancedData::get_type_name() ],
20✔
93
                                'description' => static fn () => __( 'The Slack Enhanced Data meta values.', 'wp-graphql-rank-math' ),
20✔
94
                                'resolve'     => static function ( $source ): ?array {
20✔
95
                                        $values  = [];
×
96
                                        $counter = 1;
×
97

98
                                        while ( isset( $source['twitter'][ 'label' . $counter ] ) ) {
×
99
                                                $values[] = [
×
100
                                                        'label' => $source['twitter'][ 'label' . $counter ],
×
101
                                                        'data'  => $source['twitter'][ 'data' . $counter ],
×
102
                                                ];
×
103
                                                ++$counter;
×
104
                                        }
105

106
                                        return $values ?: null;
×
107
                                },
20✔
108
                        ],
20✔
109
                        'siteName'          => [
20✔
110
                                'type'        => 'String',
20✔
111
                                'description' => static fn () => __( 'The name of the site this resource is associated with.', 'wp-graphql-rank-math' ),
20✔
112
                                'resolve'     => static fn ( $source ): ?string => ! empty( $source['og']['site_name'] ) ? (string) $source['og']['site_name'] : null,
20✔
113
                        ],
20✔
114
                        'title'             => [
20✔
115
                                'type'        => 'String',
20✔
116
                                'description' => static fn () => __( 'The title of your object as it should appear within the graph.', 'wp-graphql-rank-math' ),
20✔
117
                                'resolve'     => static fn ( $source ): ?string => ! empty( $source['og']['title'] ) ? (string) $source['og']['title'] : null,
20✔
118
                        ],
20✔
119
                        'twitterMeta'       => [
20✔
120
                                'type'        => OpenGraph\Twitter::get_type_name(),
20✔
121
                                'description' => static fn () => __( 'The Twitter OpenGraph meta values.', 'wp-graphql-rank-math' ),
20✔
122
                                'resolve'     => static fn ( $source ): ?array => ! empty( $source['twitter'] ) ? $source['twitter'] : null,
20✔
123
                        ],
20✔
124
                        'type'              => [
20✔
125
                                'type'        => 'String',
20✔
126
                                'description' => static fn () => __( 'The OpenGraph object type.', 'wp-graphql-rank-math' ),
20✔
127
                                'resolve'     => static fn ( $source ): ?string => ! empty( $source['og']['type'] ) ? (string) $source['og']['type'] : null,
20✔
128
                        ],
20✔
129
                        'updatedTime'       => [
20✔
130
                                'type'        => 'String',
20✔
131
                                'description' => static fn () => __( 'The updated time', 'wp-graphql-rank-math' ),
20✔
132
                                'resolve'     => static fn ( $source ): ?string => ! empty( $source['og']['updated_time'] ) ? (string) $source['og']['updated_time'] : null,
20✔
133
                        ],
20✔
134
                        'url'               => [
20✔
135
                                'type'        => 'String',
20✔
136
                                'description' => static fn () => __( 'The canonical URL of your object that will be used as its permanent ID in the graph.', 'wp-graphql-rank-math' ),
20✔
137
                                'resolve'     => static fn ( $source ): ?string => ! empty( $source['og']['url'] ) ? (string) $source['og']['url'] : null,
20✔
138
                        ],
20✔
139
                        'videoMeta'         => [
20✔
140
                                'type'        => OpenGraph\Video::get_type_name(),
20✔
141
                                'description' => static fn () => __( 'The Twitter OpenGraph meta values.', 'wp-graphql-rank-math' ),
20✔
142
                                'resolve'     => static function ( $source ): ?array {
20✔
143
                                        $values = ! empty( $source['video'] ) ? $source['video'] : [];
×
144

145
                                        if ( isset( $source['og']['video'] ) ) {
×
146
                                                $values['url'] = $source['og']['video'];
×
147
                                        }
148

149
                                        return $values ?: null;
×
150
                                },
20✔
151
                        ],
20✔
152
                ];
20✔
153
        }
154
}
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

© 2025 Coveralls, Inc