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

AxeWP / wp-graphql-rank-math / 6257663232

21 Sep 2023 05:40AM UTC coverage: 92.176% (+0.8%) from 91.344%
6257663232

push

github

web-flow
chore: Update dev-deps and lint (#59)

* chore: update dev deps

* chore: Lint for wp-graphql-cs:2.0.0-beta

* chore: lint access-functions

* chore: set wp-graphql-stubs to fixed version

27 of 27 new or added lines in 12 files covered. (100.0%)

2533 of 2748 relevant lines covered (92.18%)

11.22 hits per line

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

81.13
/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
namespace WPGraphQL\RankMath\Type\WPObject;
9

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

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

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

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

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

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

66
                                        // The URL is stored in it's own key.
67
                                        if ( ! empty( $source['og']['image'] ) ) {
×
68
                                                $values['url'] = $source['og']['image'];
×
69
                                        }
70

71
                                        // The rest of the data is stored in an array.
72
                                        if ( ! empty( $source['og:image'] ) ) {
×
73
                                                $values = array_merge( $values, $source['og:image'] );
×
74
                                        }
75

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

102
                                        while ( isset( $source['twitter'][ 'label' . $counter ] ) ) {
×
103
                                                $values[] = [
×
104
                                                        'label' => $source['twitter'][ 'label' . $counter ],
×
105
                                                        'data'  => $source['twitter'][ 'data' . $counter ],
×
106
                                                ];
×
107
                                                ++$counter;
×
108
                                        }
109

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

150
                                        if ( isset( $source['og']['video'] ) ) {
×
151
                                                $values['url'] = $source['og']['video'];
×
152
                                        }
153

154
                                        return $values ?: null;
×
155
                                },
18✔
156
                        ],
18✔
157
                ];
18✔
158
        }
159
}
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