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

rtCamp / snapwp-helper / 13435152591

20 Feb 2025 12:21PM UTC coverage: 82.646% (-0.8%) from 83.424%
13435152591

Pull #80

github

web-flow
Merge e36eee2d3 into 8e49111f1
Pull Request #80: dev!: Replace `EnqueuedScript.location` with `EnqueuedScript.groupLocation`

1524 of 1844 relevant lines covered (82.65%)

12.66 hits per line

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

16.67
/src/Modules/GraphQL/Type/Fields/EnqueuedScript.php
1
<?php
2
/**
3
 * Registers custom fields to the GraphQL EnqueuedScript Object.
4
 *
5
 * @todo Temporary (non-conflicting) backport until supported by WPGraphQL.
6
 * @todo Remove when WPGraphQL >= 1.30.0 is required.
7
 *
8
 * @see https://github.com/wp-graphql/wp-graphql/pull/3196
9
 *
10
 * @package SnapWP\Helper\Modules\GraphQL\Type\Fields
11
 */
12

13
declare( strict_types = 1 );
14

15
namespace SnapWP\Helper\Modules\GraphQL\Type\Fields;
16

17
/**
18
 * Class - EnqueuedScript
19
 */
20
final class EnqueuedScript extends AbstractFields {
21
        /**
22
         * {@inheritDoc}
23
         */
24
        public static function get_type_name(): string {
×
25
                return 'EnqueuedScript';
×
26
        }
27

28
        /**
29
         * {@inheritDoc}
30
         */
31
        public function register(): void {
34✔
32
                // Early return if WPGraphQL will register the field itself.
33
                if ( defined( 'WPGRAPHQL_VERSION' ) && version_compare( WPGRAPHQL_VERSION, '1.30.0', '>=' ) ) {
34✔
34
                        return;
34✔
35
                }
36

37
                parent::register();
×
38
        }
39

40
        /**
41
         * {@inheritDoc}
42
         */
43
        public function get_fields(): array {
×
44
                return [
×
45
                        'groupLocation' => [
×
46
                                'type'        => 'String',
×
47
                                'description' => __( 'The location where this script should be loaded', 'snapwp-helper' ),
×
48
                                'resolve'     => static function ( \_WP_Dependency $script ) {
×
49
                                        if ( isset( $script->extra['group'] ) && 1 === (int) $script->extra['group'] ) {
×
50
                                                return 'footer';
×
51
                                        }
52
                                        return 'header';
×
53
                                },
×
54
                        ],
×
55
                ];
×
56
        }
57
}
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