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

wp-graphql / wp-graphql / 14716683875

28 Apr 2025 07:58PM UTC coverage: 84.287% (+1.6%) from 82.648%
14716683875

push

github

actions-user
release: merge develop into master for v2.3.0

15905 of 18870 relevant lines covered (84.29%)

257.23 hits per line

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

95.65
/src/Type/InterfaceType/MenuItemLinkable.php
1
<?php
2

3
namespace WPGraphQL\Type\InterfaceType;
4

5
use WPGraphQL\Model\Post;
6
use WPGraphQL\Model\Term;
7
use WPGraphQL\Registry\TypeRegistry;
8

9
class MenuItemLinkable {
10

11
        /**
12
         * Registers the MenuItemLinkable Interface Type
13
         *
14
         * @param \WPGraphQL\Registry\TypeRegistry $type_registry Instance of the WPGraphQL Type Registry
15
         *
16
         * @throws \Exception
17
         */
18
        public static function register_type( TypeRegistry $type_registry ): void {
593✔
19
                register_graphql_interface_type(
593✔
20
                        'MenuItemLinkable',
593✔
21
                        [
593✔
22
                                'description' => static function () {
593✔
23
                                        return __( 'Content that can be referenced by navigation menu items. Provides the essential fields needed to create links within navigation structures.', 'wp-graphql' );
18✔
24
                                },
593✔
25
                                'interfaces'  => [ 'Node', 'UniformResourceIdentifiable', 'DatabaseIdentifier' ],
593✔
26
                                'fields'      => [],
593✔
27
                                'resolveType' => static function ( $node ) use ( $type_registry ) {
593✔
28
                                        switch ( true ) {
29
                                                case $node instanceof Post && isset( $node->post_type ):
17✔
30
                                                        /** @var \WP_Post_Type $post_type_object */
31
                                                        $post_type_object = get_post_type_object( $node->post_type );
16✔
32
                                                        $type             = $type_registry->get_type( $post_type_object->graphql_single_name );
16✔
33
                                                        break;
16✔
34
                                                case $node instanceof Term && isset( $node->taxonomyName ):
1✔
35
                                                        /** @var \WP_Taxonomy $tax_object */
36
                                                        $tax_object = get_taxonomy( $node->taxonomyName );
1✔
37
                                                        $type       = $type_registry->get_type( $tax_object->graphql_single_name );
1✔
38
                                                        break;
1✔
39
                                                default:
40
                                                        $type = null;
×
41
                                        }
42

43
                                        return $type;
17✔
44
                                },
593✔
45
                        ]
593✔
46
                );
593✔
47
        }
48
}
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