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

Yoast / wordpress-seo / 7255789135

19 Dec 2023 12:48AM UTC coverage: 49.39%. Remained the same
7255789135

push

github

web-flow
Merge pull request #20975 from Yoast/JRF/QA/no-fqn-in-non-namespaced-files

CS/QA: don't use fully qualified global functions and constants in non-namespaced files

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

2 existing lines in 1 file now uncovered.

15426 of 31233 relevant lines covered (49.39%)

4.07 hits per line

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

33.58
/admin/class-admin-asset-manager.php
1
<?php
2
/**
3
 * WPSEO plugin file.
4
 *
5
 * @package WPSEO\Admin
6
 */
7

8
/**
9
 * This class registers all the necessary styles and scripts.
10
 *
11
 * Also has methods for the enqueing of scripts and styles.
12
 * It automatically adds a prefix to the handle.
13
 */
14
class WPSEO_Admin_Asset_Manager {
15

16
        /**
17
         * Prefix for naming the assets.
18
         *
19
         * @var string
20
         */
21
        public const PREFIX = 'yoast-seo-';
22

23
        /**
24
         * Class that manages the assets' location.
25
         *
26
         * @var WPSEO_Admin_Asset_Location
27
         */
28
        protected $asset_location;
29

30
        /**
31
         * Prefix for naming the assets.
32
         *
33
         * @var string
34
         */
35
        private $prefix;
36

37
        /**
38
         * Constructs a manager of assets. Needs a location to know where to register assets at.
39
         *
40
         * @param WPSEO_Admin_Asset_Location|null $asset_location The provider of the asset location.
41
         * @param string                          $prefix         The prefix for naming assets.
42
         */
43
        public function __construct( WPSEO_Admin_Asset_Location $asset_location = null, $prefix = self::PREFIX ) {
×
44
                if ( $asset_location === null ) {
×
45
                        $asset_location = self::create_default_location();
×
46
                }
47

48
                $this->asset_location = $asset_location;
×
49
                $this->prefix         = $prefix;
×
50
        }
51

52
        /**
53
         * Enqueues scripts.
54
         *
55
         * @param string $script The name of the script to enqueue.
56
         */
57
        public function enqueue_script( $script ) {
4✔
58
                wp_enqueue_script( $this->prefix . $script );
4✔
59
        }
2✔
60

61
        /**
62
         * Enqueues styles.
63
         *
64
         * @param string $style The name of the style to enqueue.
65
         */
66
        public function enqueue_style( $style ) {
8✔
67
                wp_enqueue_style( $this->prefix . $style );
8✔
68
        }
4✔
69

70
        /**
71
         * Enqueues the appropriate language for the user.
72
         */
73
        public function enqueue_user_language_script() {
×
74
                $this->enqueue_script( 'language-' . YoastSEO()->helpers->language->get_researcher_language() );
×
75
        }
76

77
        /**
78
         * Registers scripts based on it's parameters.
79
         *
80
         * @param WPSEO_Admin_Asset $script The script to register.
81
         */
82
        public function register_script( WPSEO_Admin_Asset $script ) {
8✔
83
                $url = $script->get_src() ? $this->get_url( $script, WPSEO_Admin_Asset::TYPE_JS ) : false;
8✔
84

85
                wp_register_script(
8✔
86
                        $this->prefix . $script->get_name(),
8✔
87
                        $url,
8✔
88
                        $script->get_deps(),
8✔
89
                        $script->get_version(),
8✔
90
                        $script->is_in_footer()
8✔
91
                );
4✔
92

93
                if ( in_array( 'wp-i18n', $script->get_deps(), true ) ) {
8✔
94
                        wp_set_script_translations( $this->prefix . $script->get_name(), 'wordpress-seo' );
×
95
                }
96
        }
4✔
97

98
        /**
99
         * Registers styles based on it's parameters.
100
         *
101
         * @param WPSEO_Admin_Asset $style The style to register.
102
         */
103
        public function register_style( WPSEO_Admin_Asset $style ) {
8✔
104
                wp_register_style(
8✔
105
                        $this->prefix . $style->get_name(),
8✔
106
                        $this->get_url( $style, WPSEO_Admin_Asset::TYPE_CSS ),
8✔
107
                        $style->get_deps(),
8✔
108
                        $style->get_version(),
8✔
109
                        $style->get_media()
8✔
110
                );
4✔
111
        }
4✔
112

113
        /**
114
         * Calls the functions that register scripts and styles with the scripts and styles to be registered as arguments.
115
         */
116
        public function register_assets() {
4✔
117
                $this->register_scripts( $this->scripts_to_be_registered() );
4✔
118
                $this->register_styles( $this->styles_to_be_registered() );
4✔
119
        }
2✔
120

121
        /**
122
         * Registers all the scripts passed to it.
123
         *
124
         * @param array $scripts The scripts passed to it.
125
         */
126
        public function register_scripts( $scripts ) {
4✔
127
                foreach ( $scripts as $script ) {
4✔
128
                        $script = new WPSEO_Admin_Asset( $script );
4✔
129
                        $this->register_script( $script );
4✔
130
                }
131
        }
2✔
132

133
        /**
134
         * Registers all the styles it receives.
135
         *
136
         * @param array $styles Styles that need to be registered.
137
         */
138
        public function register_styles( $styles ) {
4✔
139
                foreach ( $styles as $style ) {
4✔
140
                        $style = new WPSEO_Admin_Asset( $style );
4✔
141
                        $this->register_style( $style );
4✔
142
                }
143
        }
2✔
144

145
        /**
146
         * Localizes the script.
147
         *
148
         * @param string $handle      The script handle.
149
         * @param string $object_name The object name.
150
         * @param array  $data        The l10n data.
151
         */
152
        public function localize_script( $handle, $object_name, $data ) {
×
NEW
153
                wp_localize_script( $this->prefix . $handle, $object_name, $data );
×
154
        }
155

156
        /**
157
         * Adds an inline script.
158
         *
159
         * @param string $handle   The script handle.
160
         * @param string $data     The l10n data.
161
         * @param string $position Optional. Whether to add the inline script before the handle or after.
162
         */
163
        public function add_inline_script( $handle, $data, $position = 'after' ) {
×
NEW
164
                wp_add_inline_script( $this->prefix . $handle, $data, $position );
×
165
        }
166

167
        /**
168
         * A list of styles that shouldn't be registered but are needed in other locations in the plugin.
169
         *
170
         * @return array
171
         */
172
        public function special_styles() {
×
173
                $flat_version = $this->flatten_version( WPSEO_VERSION );
×
174
                $asset_args   = [
175
                        'name' => 'inside-editor',
×
176
                        'src'  => 'inside-editor-' . $flat_version,
×
177
                ];
178

179
                return [ 'inside-editor' => new WPSEO_Admin_Asset( $asset_args ) ];
×
180
        }
181

182
        /**
183
         * Flattens a version number for use in a filename.
184
         *
185
         * @param string $version The original version number.
186
         *
187
         * @return string The flattened version number.
188
         */
189
        public function flatten_version( $version ) {
24✔
190
                $parts = explode( '.', $version );
24✔
191

192
                if ( count( $parts ) === 2 && preg_match( '/^\d+$/', $parts[1] ) === 1 ) {
24✔
193
                        $parts[] = '0';
8✔
194
                }
195

196
                return implode( '', $parts );
24✔
197
        }
198

199
        /**
200
         * Creates a default location object for use in the admin asset manager.
201
         *
202
         * @return WPSEO_Admin_Asset_Location The location to use in the asset manager.
203
         */
204
        public static function create_default_location() {
×
205
                if ( defined( 'YOAST_SEO_DEV_SERVER' ) && YOAST_SEO_DEV_SERVER ) {
×
206
                        $url = defined( 'YOAST_SEO_DEV_SERVER_URL' ) ? YOAST_SEO_DEV_SERVER_URL : WPSEO_Admin_Asset_Dev_Server_Location::DEFAULT_URL;
×
207

208
                        return new WPSEO_Admin_Asset_Dev_Server_Location( $url );
×
209
                }
210

211
                return new WPSEO_Admin_Asset_SEO_Location( WPSEO_FILE, false );
×
212
        }
213

214
        /**
215
         * Checks if the given script is enqueued.
216
         *
217
         * @param string $script The script to check.
218
         *
219
         * @return bool True when the script is enqueued.
220
         */
221
        public function is_script_enqueued( $script ) {
×
NEW
222
                return wp_script_is( $this->prefix . $script );
×
223
        }
224

225
        /**
226
         * Returns the scripts that need to be registered.
227
         *
228
         * @todo Data format is not self-documenting. Needs explanation inline. R.
229
         *
230
         * @return array The scripts that need to be registered.
231
         */
232
        protected function scripts_to_be_registered() {
×
233
                $header_scripts          = [
234
                        'admin-global',
×
235
                        'block-editor',
236
                        'classic-editor',
237
                        'post-edit',
238
                        'help-scout-beacon',
239
                        'redirect-old-features-tab',
240
                ];
241
                $additional_dependencies = [
242
                        'analysis-worker'          => [ self::PREFIX . 'analysis-package' ],
×
243
                        'api-client'               => [ 'wp-api' ],
244
                        'crawl-settings'           => [ 'jquery' ],
245
                        'dashboard-widget'         => [ self::PREFIX . 'api-client' ],
246
                        'wincher-dashboard-widget' => [ self::PREFIX . 'api-client' ],
247
                        'editor-modules'           => [ 'jquery' ],
248
                        'elementor'                => [
249
                                self::PREFIX . 'api-client',
250
                                self::PREFIX . 'externals-components',
251
                                self::PREFIX . 'externals-contexts',
252
                                self::PREFIX . 'externals-redux',
253
                        ],
254
                        'indexation'               => [
255
                                'jquery-ui-core',
256
                                'jquery-ui-progressbar',
257
                        ],
258
                        'first-time-configuration' => [
259
                                self::PREFIX . 'api-client',
260
                                self::PREFIX . 'externals-components',
261
                                self::PREFIX . 'externals-contexts',
262
                                self::PREFIX . 'externals-redux',
263
                        ],
264
                        'integrations-page'        => [
265
                                self::PREFIX . 'api-client',
266
                                self::PREFIX . 'externals-components',
267
                                self::PREFIX . 'externals-contexts',
268
                                self::PREFIX . 'externals-redux',
269
                        ],
270
                        'post-edit'                => [
271
                                self::PREFIX . 'api-client',
272
                                self::PREFIX . 'block-editor',
273
                                self::PREFIX . 'externals-components',
274
                                self::PREFIX . 'externals-contexts',
275
                                self::PREFIX . 'externals-redux',
276
                        ],
277
                        'reindex-links'            => [
278
                                'jquery-ui-core',
279
                                'jquery-ui-progressbar',
280
                        ],
281
                        'settings'                 => [
282
                                'jquery-ui-core',
283
                                'jquery-ui-progressbar',
284
                                self::PREFIX . 'api-client',
285
                                self::PREFIX . 'externals-components',
286
                                self::PREFIX . 'externals-contexts',
287
                                self::PREFIX . 'externals-redux',
288
                        ],
289
                        'term-edit'                => [
290
                                self::PREFIX . 'api-client',
291
                                self::PREFIX . 'classic-editor',
292
                                self::PREFIX . 'externals-components',
293
                                self::PREFIX . 'externals-contexts',
294
                                self::PREFIX . 'externals-redux',
295
                        ],
296
                ];
297

298
                $plugin_scripts   = $this->load_generated_asset_file(
×
299
                        [
300
                                'asset_file'      => __DIR__ . '/../src/generated/assets/plugin.php',
×
301
                                'ext_length'      => 3,
×
302
                                'additional_deps' => $additional_dependencies,
×
303
                                'header_scripts'  => $header_scripts,
×
304
                        ]
305
                );
306
                $external_scripts = $this->load_generated_asset_file(
×
307
                        [
308
                                'asset_file'      => __DIR__ . '/../src/generated/assets/externals.php',
×
309
                                'ext_length'      => 3,
×
310
                                'suffix'          => '-package',
×
311
                                'base_dir'        => 'externals/',
×
312
                                'additional_deps' => $additional_dependencies,
×
313
                                'header_scripts'  => $header_scripts,
×
314
                        ]
315
                );
316
                $language_scripts = $this->load_generated_asset_file(
×
317
                        [
318
                                'asset_file'      => __DIR__ . '/../src/generated/assets/languages.php',
×
319
                                'ext_length'      => 3,
×
320
                                'suffix'          => '-language',
×
321
                                'base_dir'        => 'languages/',
×
322
                                'additional_deps' => $additional_dependencies,
×
323
                                'header_scripts'  => $header_scripts,
×
324
                        ]
325
                );
326
                $renamed_scripts  = $this->load_renamed_scripts();
×
327

328
                $scripts = array_merge(
×
329
                        $plugin_scripts,
×
330
                        $external_scripts,
×
331
                        $language_scripts,
×
332
                        $renamed_scripts
×
333
                );
334

335
                $scripts['installation-success'] = [
×
336
                        'name'    => 'installation-success',
×
337
                        'src'     => 'installation-success.js',
×
338
                        'deps'    => [
339
                                'wp-a11y',
340
                                'wp-dom-ready',
341
                                'wp-components',
342
                                'wp-element',
343
                                'wp-i18n',
344
                                self::PREFIX . 'yoast-components',
345
                                self::PREFIX . 'externals-components',
346
                        ],
347
                        'version' => $scripts['installation-success']['version'],
×
348
                ];
349

350
                $scripts['post-edit-classic'] = [
×
351
                        'name'      => 'post-edit-classic',
×
352
                        'src'       => $scripts['post-edit']['src'],
×
353
                        'deps'      => array_map(
×
354
                                static function ( $dep ) {
355
                                        if ( $dep === self::PREFIX . 'block-editor' ) {
×
356
                                                return self::PREFIX . 'classic-editor';
357
                                        }
358
                                        return $dep;
×
359
                                },
×
360
                                $scripts['post-edit']['deps']
361
                        ),
362
                        'in_footer' => ! in_array( 'post-edit-classic', $header_scripts, true ),
×
363
                        'version'   => $scripts['post-edit']['version'],
364
                ];
365

366
                $scripts['workouts'] = [
×
367
                        'name'    => 'workouts',
×
368
                        'src'     => 'workouts.js',
369
                        'deps'    => [
370
                                'clipboard',
371
                                'lodash',
372
                                'wp-api-fetch',
373
                                'wp-a11y',
374
                                'wp-components',
375
                                'wp-compose',
376
                                'wp-data',
377
                                'wp-dom-ready',
378
                                'wp-element',
379
                                'wp-i18n',
380
                                self::PREFIX . 'externals-components',
381
                                self::PREFIX . 'externals-contexts',
382
                                self::PREFIX . 'externals-redux',
383
                                self::PREFIX . 'analysis',
384
                                self::PREFIX . 'react-select',
385
                                self::PREFIX . 'yoast-components',
386
                        ],
387
                        'version' => $scripts['workouts']['version'],
388
                ];
389

390
                // Add the current language to every script that requires the analysis package.
391
                foreach ( $scripts as $name => $script ) {
×
392
                        if ( substr( $name, -8 ) === 'language' ) {
×
393
                                continue;
394
                        }
395
                        if ( in_array( self::PREFIX . 'analysis-package', $script['deps'], true ) ) {
×
396
                                $scripts[ $name ]['deps'][] = self::PREFIX . YoastSEO()->helpers->language->get_researcher_language() . '-language';
397
                        }
398
                }
399

400
                return $scripts;
401
        }
402

403
        /**
404
         * Loads a generated asset file.
405
         *
406
         * @param array $args {
407
         *     The arguments.
408
         *
409
         *     @type string                  $asset_file      The asset file to load.
410
         *     @type int                     $ext_length      The length of the extension, including suffix, of the filename.
411
         *     @type string                  $suffix          Optional. The suffix of the asset name.
412
         *     @type array<string, string[]> $additional_deps Optional. The additional dependencies assets may have.
413
         *     @type string                  $base_dir        Optional. The base directory of the asset.
414
         *     @type string[]                $header_scripts  Optional. The script names that should be in the header.
415
         * }
416
         *
417
         * @return array {
418
         *     The scripts to be registered.
419
         *
420
         *     @type string   $name      The name of the asset.
421
         *     @type string   $src       The src of the asset.
422
         *     @type string[] $deps      The dependenies of the asset.
423
         *     @type bool     $in_footer Whether or not the asset should be in the footer.
424
         * }
425
         */
426
        protected function load_generated_asset_file( $args ) {
×
427
                $args    = wp_parse_args(
×
428
                        $args,
429
                        [
430
                                'suffix'          => '',
431
                                'additional_deps' => [],
432
                                'base_dir'        => '',
433
                                'header_scripts'  => [],
434
                        ]
435
                );
436
                $scripts = [];
×
437
                $assets  = require $args['asset_file'];
×
438
                foreach ( $assets as $file => $data ) {
×
439
                        $name  = substr( $file, 0, -$args['ext_length'] );
×
440
                        $name  = strtolower( preg_replace( '/([A-Z])/', '-$1', $name ) );
×
441
                        $name .= $args['suffix'];
442

443
                        $deps = $data['dependencies'];
×
444
                        if ( isset( $args['additional_deps'][ $name ] ) ) {
×
445
                                $deps = array_merge( $deps, $args['additional_deps'][ $name ] );
446
                        }
447

448
                        $scripts[ $name ] = [
×
449
                                'name'      => $name,
×
450
                                'src'       => $args['base_dir'] . $file,
×
451
                                'deps'      => $deps,
×
452
                                'in_footer' => ! in_array( $name, $args['header_scripts'], true ),
×
453
                                'version'   => $data['version'],
454
                        ];
455
                }
456

457
                return $scripts;
458
        }
459

460
        /**
461
         * Loads the scripts that should be renamed for BC.
462
         *
463
         * @return array {
464
         *     The scripts to be registered.
465
         *
466
         *     @type string   $name      The name of the asset.
467
         *     @type string   $src       The src of the asset.
468
         *     @type string[] $deps      The dependenies of the asset.
469
         *     @type bool     $in_footer Whether or not the asset should be in the footer.
470
         * }
471
         */
472
        protected function load_renamed_scripts() {
×
473
                $scripts         = [];
474
                $renamed_scripts = [
475
                        'admin-global-script'         => 'admin-global',
476
                        'analysis'                    => 'analysis-package',
477
                        'analysis-report'             => 'analysis-report-package',
478
                        'api'                         => 'api-client',
479
                        'commons'                     => 'commons-package',
480
                        'edit-page'                   => 'edit-page-script',
481
                        'draft-js'                    => 'draft-js-package',
482
                        'feature-flag'                => 'feature-flag-package',
483
                        'helpers'                     => 'helpers-package',
484
                        'jed'                         => 'jed-package',
485
                        'chart.js'                    => 'chart.js-package',
486
                        'legacy-components'           => 'components-package',
487
                        'network-admin-script'        => 'network-admin',
488
                        'redux'                       => 'redux-package',
489
                        'replacement-variable-editor' => 'replacement-variable-editor-package',
490
                        'search-metadata-previews'    => 'search-metadata-previews-package',
491
                        'social-metadata-forms'       => 'social-metadata-forms-package',
492
                        'styled-components'           => 'styled-components-package',
493
                        'style-guide'                 => 'style-guide-package',
494
                        'yoast-components'            => 'components-new-package',
495
                ];
496

497
                foreach ( $renamed_scripts as $original => $replacement ) {
×
498
                        $scripts[] = [
×
499
                                'name' => $original,
500
                                'src'  => false,
501
                                'deps' => [ self::PREFIX . $replacement ],
502
                        ];
503
                }
504

505
                return $scripts;
506
        }
507

508
        /**
509
         * Returns the styles that need to be registered.
510
         *
511
         * @todo Data format is not self-documenting. Needs explanation inline. R.
512
         *
513
         * @return array Styles that need to be registered.
514
         */
515
        protected function styles_to_be_registered() {
516
                $flat_version = $this->flatten_version( WPSEO_VERSION );
517

518
                return [
519
                        [
520
                                'name' => 'admin-css',
521
                                'src'  => 'yst_plugin_tools-' . $flat_version,
522
                                'deps' => [ self::PREFIX . 'toggle-switch' ],
523
                        ],
524
                        [
525
                                'name' => 'toggle-switch',
526
                                'src'  => 'toggle-switch-' . $flat_version,
527
                        ],
528
                        [
529
                                'name' => 'dismissible',
530
                                'src'  => 'wpseo-dismissible-' . $flat_version,
531
                        ],
532
                        [
533
                                'name' => 'notifications',
534
                                'src'  => 'notifications-' . $flat_version,
535
                        ],
536
                        [
537
                                'name' => 'alert',
538
                                'src'  => 'alerts-' . $flat_version,
539
                        ],
540
                        [
541
                                'name' => 'edit-page',
542
                                'src'  => 'edit-page-' . $flat_version,
543
                        ],
544
                        [
545
                                'name' => 'featured-image',
546
                                'src'  => 'featured-image-' . $flat_version,
547
                        ],
548
                        [
549
                                'name' => 'metabox-css',
550
                                'src'  => 'metabox-' . $flat_version,
551
                                'deps' => [
552
                                        self::PREFIX . 'admin-css',
553
                                        self::PREFIX . 'tailwind',
554
                                        'wp-components',
555
                                ],
556
                        ],
557
                        [
558
                                'name' => 'ai-generator',
559
                                'src'  => 'ai-generator-' . $flat_version,
560
                                'deps' => [
561
                                        self::PREFIX . 'tailwind',
562
                                        self::PREFIX . 'introductions',
563
                                ],
564
                        ],
565
                        [
566
                                'name' => 'introductions',
567
                                'src'  => 'introductions-' . $flat_version,
568
                                'deps' => [ self::PREFIX . 'tailwind' ],
569
                        ],
570
                        [
571
                                'name' => 'wp-dashboard',
572
                                'src'  => 'dashboard-' . $flat_version,
573
                        ],
574
                        [
575
                                'name' => 'scoring',
576
                                'src'  => 'yst_seo_score-' . $flat_version,
577
                        ],
578
                        [
579
                                'name' => 'adminbar',
580
                                'src'  => 'adminbar-' . $flat_version,
581
                                'deps' => [
582
                                        'admin-bar',
583
                                ],
584
                        ],
585
                        [
586
                                'name' => 'primary-category',
587
                                'src'  => 'metabox-primary-category-' . $flat_version,
588
                        ],
589
                        [
590
                                'name' => 'admin-global',
591
                                'src'  => 'admin-global-' . $flat_version,
592
                        ],
593
                        [
594
                                'name' => 'extensions',
595
                                'src'  => 'yoast-extensions-' . $flat_version,
596
                                'deps' => [
597
                                        'wp-components',
598
                                ],
599
                        ],
600
                        [
601
                                'name' => 'filter-explanation',
602
                                'src'  => 'filter-explanation-' . $flat_version,
603
                        ],
604
                        [
605
                                'name' => 'monorepo',
606
                                'src'  => 'monorepo-' . $flat_version,
607
                        ],
608
                        [
609
                                'name' => 'structured-data-blocks',
610
                                'src'  => 'structured-data-blocks-' . $flat_version,
611
                                'deps' => [ 'wp-edit-blocks' ],
612
                        ],
613
                        [
614
                                'name' => 'elementor',
615
                                'src'  => 'elementor-' . $flat_version,
616
                        ],
617
                        [
618
                                'name' => 'tailwind',
619
                                'src'  => 'tailwind-' . $flat_version,
620
                        ],
621
                        [
622
                                'name' => 'new-settings',
623
                                'src'  => 'new-settings-' . $flat_version,
624
                                'deps' => [ self::PREFIX . 'tailwind' ],
625
                        ],
626
                        [
627
                                'name' => 'black-friday-banner',
628
                                'src'  => 'black-friday-banner-' . $flat_version,
629
                                'deps' => [ self::PREFIX . 'tailwind' ],
630
                        ],
631
                        [
632
                                'name' => 'academy',
633
                                'src'  => 'academy-' . $flat_version,
634
                                'deps' => [ self::PREFIX . 'tailwind' ],
635
                        ],
636
                        [
637
                                'name' => 'support',
638
                                'src'  => 'support-' . $flat_version,
639
                                'deps' => [ self::PREFIX . 'tailwind' ],
640
                        ],
641
                        [
642
                                'name' => 'workouts',
643
                                'src'  => 'workouts-' . $flat_version,
644
                                'deps' => [
645
                                        self::PREFIX . 'monorepo',
646
                                ],
647
                        ],
648
                        [
649
                                'name' => 'first-time-configuration',
650
                                'src'  => 'first-time-configuration-' . $flat_version,
651
                                'deps' => [ self::PREFIX . 'tailwind' ],
652
                        ],
653
                        [
654
                                'name' => 'inside-editor',
655
                                'src'  => 'inside-editor-' . $flat_version,
656
                        ],
657
                ];
658
        }
659

660
        /**
661
         * Determines the URL of the asset.
662
         *
663
         * @param WPSEO_Admin_Asset $asset The asset to determine the URL for.
664
         * @param string            $type  The type of asset. Usually JS or CSS.
665
         *
666
         * @return string The URL of the asset.
667
         */
668
        protected function get_url( WPSEO_Admin_Asset $asset, $type ) {
×
669
                $scheme = wp_parse_url( $asset->get_src(), PHP_URL_SCHEME );
×
670
                if ( in_array( $scheme, [ 'http', 'https' ], true ) ) {
×
671
                        return $asset->get_src();
672
                }
673

674
                return $this->asset_location->get_url( $asset, $type );
675
        }
676
}
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