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

rtCamp / snapwp-helper / 13493190054

24 Feb 2025 07:50AM UTC coverage: 82.131% (-1.3%) from 83.424%
13493190054

Pull #80

github

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

1549 of 1886 relevant lines covered (82.13%)

12.83 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 Remove when WPGraphQL >= 1.30.0 is required.
6
 *
7
 * @see https://github.com/wp-graphql/wp-graphql/pull/3196
8
 *
9
 * @package SnapWP\Helper\Modules\GraphQL\Type\Fields
10
 */
11

12
declare( strict_types = 1 );
13

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

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

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

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

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