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

Yoast / wordpress-seo / 2ff3eaf8f186484de922491150d64aa304b32a2f

15 May 2024 02:29PM UTC coverage: 48.235% (-4.4%) from 52.638%
2ff3eaf8f186484de922491150d64aa304b32a2f

push

github

web-flow
Merge pull request #21348 from Yoast/implementation-ai-buttons-next-to-seo-keyphrase-assessments

Implementation ai buttons next to seo keyphrase assessments

7418 of 13479 branches covered (55.03%)

Branch coverage included in aggregate %.

47 of 65 new or added lines in 14 files covered. (72.31%)

3709 existing lines in 108 files now uncovered.

24419 of 52525 relevant lines covered (46.49%)

42869.12 hits per line

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

0.0
/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
 * It automatically adds a prefix to the handle.
12
 */
13
class WPSEO_Admin_Asset_Manager {
14

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

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

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

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

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

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

62
        /**
63
         * Enqueues styles.
64
         *
65
         * @param string $style The name of the style to enqueue.
66
         *
67
         * @return void
68
         */
UNCOV
69
        public function enqueue_style( $style ) {
×
UNCOV
70
                wp_enqueue_style( $this->prefix . $style );
×
71
        }
72

73
        /**
74
         * Enqueues the appropriate language for the user.
75
         *
76
         * @return void
77
         */
78
        public function enqueue_user_language_script() {
×
79
                $this->enqueue_script( 'language-' . YoastSEO()->helpers->language->get_researcher_language() );
×
80
        }
81

82
        /**
83
         * Registers scripts based on it's parameters.
84
         *
85
         * @param WPSEO_Admin_Asset $script The script to register.
86
         *
87
         * @return void
88
         */
UNCOV
89
        public function register_script( WPSEO_Admin_Asset $script ) {
×
UNCOV
90
                $url = $script->get_src() ? $this->get_url( $script, WPSEO_Admin_Asset::TYPE_JS ) : false;
×
91

UNCOV
92
                wp_register_script(
×
UNCOV
93
                        $this->prefix . $script->get_name(),
×
UNCOV
94
                        $url,
×
UNCOV
95
                        $script->get_deps(),
×
UNCOV
96
                        $script->get_version(),
×
UNCOV
97
                        $script->is_in_footer()
×
98
                );
99

UNCOV
100
                if ( in_array( 'wp-i18n', $script->get_deps(), true ) ) {
×
101
                        wp_set_script_translations( $this->prefix . $script->get_name(), 'wordpress-seo' );
×
102
                }
103
        }
104

105
        /**
106
         * Registers styles based on it's parameters.
107
         *
108
         * @param WPSEO_Admin_Asset $style The style to register.
109
         *
110
         * @return void
111
         */
UNCOV
112
        public function register_style( WPSEO_Admin_Asset $style ) {
×
UNCOV
113
                wp_register_style(
×
UNCOV
114
                        $this->prefix . $style->get_name(),
×
UNCOV
115
                        $this->get_url( $style, WPSEO_Admin_Asset::TYPE_CSS ),
×
UNCOV
116
                        $style->get_deps(),
×
UNCOV
117
                        $style->get_version(),
×
UNCOV
118
                        $style->get_media()
×
119
                );
120
        }
121

122
        /**
123
         * Calls the functions that register scripts and styles with the scripts and styles to be registered as arguments.
124
         *
125
         * @return void
126
         */
UNCOV
127
        public function register_assets() {
×
UNCOV
128
                $this->register_scripts( $this->scripts_to_be_registered() );
×
UNCOV
129
                $this->register_styles( $this->styles_to_be_registered() );
×
130
        }
131

132
        /**
133
         * Registers all the scripts passed to it.
134
         *
135
         * @param array $scripts The scripts passed to it.
136
         *
137
         * @return void
138
         */
UNCOV
139
        public function register_scripts( $scripts ) {
×
UNCOV
140
                foreach ( $scripts as $script ) {
×
UNCOV
141
                        $script = new WPSEO_Admin_Asset( $script );
×
UNCOV
142
                        $this->register_script( $script );
×
143
                }
144
        }
145

146
        /**
147
         * Registers all the styles it receives.
148
         *
149
         * @param array $styles Styles that need to be registered.
150
         *
151
         * @return void
152
         */
UNCOV
153
        public function register_styles( $styles ) {
×
UNCOV
154
                foreach ( $styles as $style ) {
×
UNCOV
155
                        $style = new WPSEO_Admin_Asset( $style );
×
UNCOV
156
                        $this->register_style( $style );
×
157
                }
158
        }
159

160
        /**
161
         * Localizes the script.
162
         *
163
         * @param string $handle      The script handle.
164
         * @param string $object_name The object name.
165
         * @param array  $data        The l10n data.
166
         *
167
         * @return void
168
         */
169
        public function localize_script( $handle, $object_name, $data ) {
×
170
                wp_localize_script( $this->prefix . $handle, $object_name, $data );
×
171
        }
172

173
        /**
174
         * Adds an inline script.
175
         *
176
         * @param string $handle   The script handle.
177
         * @param string $data     The l10n data.
178
         * @param string $position Optional. Whether to add the inline script before the handle or after.
179
         *
180
         * @return void
181
         */
182
        public function add_inline_script( $handle, $data, $position = 'after' ) {
×
183
                wp_add_inline_script( $this->prefix . $handle, $data, $position );
×
184
        }
185

186
        /**
187
         * A list of styles that shouldn't be registered but are needed in other locations in the plugin.
188
         *
189
         * @return array
190
         */
191
        public function special_styles() {
×
192
                $flat_version = $this->flatten_version( WPSEO_VERSION );
×
193
                $asset_args   = [
194
                        'name' => 'inside-editor',
×
195
                        'src'  => 'inside-editor-' . $flat_version,
×
196
                ];
197

198
                return [ 'inside-editor' => new WPSEO_Admin_Asset( $asset_args ) ];
×
199
        }
200

201
        /**
202
         * Flattens a version number for use in a filename.
203
         *
204
         * @param string $version The original version number.
205
         *
206
         * @return string The flattened version number.
207
         */
UNCOV
208
        public function flatten_version( $version ) {
×
UNCOV
209
                $parts = explode( '.', $version );
×
210

UNCOV
211
                if ( count( $parts ) === 2 && preg_match( '/^\d+$/', $parts[1] ) === 1 ) {
×
UNCOV
212
                        $parts[] = '0';
×
213
                }
214

UNCOV
215
                return implode( '', $parts );
×
216
        }
217

218
        /**
219
         * Creates a default location object for use in the admin asset manager.
220
         *
221
         * @return WPSEO_Admin_Asset_Location The location to use in the asset manager.
222
         */
223
        public static function create_default_location() {
×
224
                if ( defined( 'YOAST_SEO_DEV_SERVER' ) && YOAST_SEO_DEV_SERVER ) {
×
225
                        $url = defined( 'YOAST_SEO_DEV_SERVER_URL' ) ? YOAST_SEO_DEV_SERVER_URL : WPSEO_Admin_Asset_Dev_Server_Location::DEFAULT_URL;
×
226

227
                        return new WPSEO_Admin_Asset_Dev_Server_Location( $url );
×
228
                }
229

230
                return new WPSEO_Admin_Asset_SEO_Location( WPSEO_FILE, false );
×
231
        }
232

233
        /**
234
         * Checks if the given script is enqueued.
235
         *
236
         * @param string $script The script to check.
237
         *
238
         * @return bool True when the script is enqueued.
239
         */
240
        public function is_script_enqueued( $script ) {
×
241
                return wp_script_is( $this->prefix . $script );
×
242
        }
243

244
        /**
245
         * Returns the scripts that need to be registered.
246
         *
247
         * @todo Data format is not self-documenting. Needs explanation inline. R.
248
         *
249
         * @return array The scripts that need to be registered.
250
         */
251
        protected function scripts_to_be_registered() {
×
252
                $header_scripts          = [
253
                        'admin-global',
×
254
                        'block-editor',
255
                        'classic-editor',
256
                        'post-edit',
257
                        'help-scout-beacon',
258
                        'redirect-old-features-tab',
259
                ];
260
                $additional_dependencies = [
261
                        'analysis-worker'          => [ self::PREFIX . 'analysis-package' ],
×
262
                        'api-client'               => [ 'wp-api' ],
263
                        'crawl-settings'           => [ 'jquery' ],
264
                        'dashboard-widget'         => [ self::PREFIX . 'api-client' ],
265
                        'wincher-dashboard-widget' => [ self::PREFIX . 'api-client' ],
266
                        'editor-modules'           => [ 'jquery' ],
267
                        'elementor'                => [
268
                                self::PREFIX . 'api-client',
269
                                self::PREFIX . 'externals-components',
270
                                self::PREFIX . 'externals-contexts',
271
                                self::PREFIX . 'externals-redux',
272
                        ],
273
                        'indexation'               => [
274
                                'jquery-ui-core',
275
                                'jquery-ui-progressbar',
276
                        ],
277
                        'first-time-configuration' => [
278
                                self::PREFIX . 'api-client',
279
                                self::PREFIX . 'externals-components',
280
                                self::PREFIX . 'externals-contexts',
281
                                self::PREFIX . 'externals-redux',
282
                        ],
283
                        'integrations-page'        => [
284
                                self::PREFIX . 'api-client',
285
                                self::PREFIX . 'externals-components',
286
                                self::PREFIX . 'externals-contexts',
287
                                self::PREFIX . 'externals-redux',
288
                        ],
289
                        'post-edit'                => [
290
                                self::PREFIX . 'api-client',
291
                                self::PREFIX . 'block-editor',
292
                                self::PREFIX . 'externals-components',
293
                                self::PREFIX . 'externals-contexts',
294
                                self::PREFIX . 'externals-redux',
295
                        ],
296
                        'reindex-links'            => [
297
                                'jquery-ui-core',
298
                                'jquery-ui-progressbar',
299
                        ],
300
                        'settings'                 => [
301
                                'jquery-ui-core',
302
                                'jquery-ui-progressbar',
303
                                self::PREFIX . 'api-client',
304
                                self::PREFIX . 'externals-components',
305
                                self::PREFIX . 'externals-contexts',
306
                                self::PREFIX . 'externals-redux',
307
                        ],
308
                        'term-edit'                => [
309
                                self::PREFIX . 'api-client',
310
                                self::PREFIX . 'classic-editor',
311
                                self::PREFIX . 'externals-components',
312
                                self::PREFIX . 'externals-contexts',
313
                                self::PREFIX . 'externals-redux',
314
                        ],
315
                ];
316

317
                $plugin_scripts   = $this->load_generated_asset_file(
×
318
                        [
319
                                'asset_file'      => __DIR__ . '/../src/generated/assets/plugin.php',
×
320
                                'ext_length'      => 3,
×
321
                                'additional_deps' => $additional_dependencies,
×
322
                                'header_scripts'  => $header_scripts,
×
323
                        ]
324
                );
325
                $external_scripts = $this->load_generated_asset_file(
×
326
                        [
327
                                'asset_file'      => __DIR__ . '/../src/generated/assets/externals.php',
×
328
                                'ext_length'      => 3,
×
329
                                'suffix'          => '-package',
×
330
                                'base_dir'        => 'externals/',
×
331
                                'additional_deps' => $additional_dependencies,
×
332
                                'header_scripts'  => $header_scripts,
×
333
                        ]
334
                );
335
                $language_scripts = $this->load_generated_asset_file(
×
336
                        [
337
                                'asset_file'      => __DIR__ . '/../src/generated/assets/languages.php',
×
338
                                'ext_length'      => 3,
×
339
                                'suffix'          => '-language',
×
340
                                'base_dir'        => 'languages/',
×
341
                                'additional_deps' => $additional_dependencies,
×
342
                                'header_scripts'  => $header_scripts,
×
343
                        ]
344
                );
345
                $renamed_scripts  = $this->load_renamed_scripts();
×
346

347
                $scripts = array_merge(
×
348
                        $plugin_scripts,
×
349
                        $external_scripts,
×
350
                        $language_scripts,
×
351
                        $renamed_scripts
×
352
                );
353

354
                $scripts['installation-success'] = [
×
355
                        'name'    => 'installation-success',
×
356
                        'src'     => 'installation-success.js',
×
357
                        'deps'    => [
358
                                'wp-a11y',
359
                                'wp-dom-ready',
360
                                'wp-components',
361
                                'wp-element',
362
                                'wp-i18n',
363
                                self::PREFIX . 'components-new-package',
364
                                self::PREFIX . 'externals-components',
365
                        ],
366
                        'version' => $scripts['installation-success']['version'],
×
367
                ];
368

369
                $scripts['post-edit-classic'] = [
×
370
                        'name'      => 'post-edit-classic',
×
371
                        'src'       => $scripts['post-edit']['src'],
×
372
                        'deps'      => array_map(
×
373
                                static function ( $dep ) {
374
                                        if ( $dep === self::PREFIX . 'block-editor' ) {
×
375
                                                return self::PREFIX . 'classic-editor';
376
                                        }
377
                                        return $dep;
×
378
                                },
×
379
                                $scripts['post-edit']['deps']
UNCOV
380
                        ),
×
381
                        'in_footer' => ! in_array( 'post-edit-classic', $header_scripts, true ),
×
382
                        'version'   => $scripts['post-edit']['version'],
383
                ];
384

385
                $scripts['workouts'] = [
×
386
                        'name'    => 'workouts',
×
387
                        'src'     => 'workouts.js',
388
                        'deps'    => [
389
                                'clipboard',
390
                                'lodash',
391
                                'wp-api-fetch',
392
                                'wp-a11y',
393
                                'wp-components',
394
                                'wp-compose',
395
                                'wp-data',
396
                                'wp-dom-ready',
397
                                'wp-element',
398
                                'wp-i18n',
399
                                self::PREFIX . 'externals-components',
400
                                self::PREFIX . 'externals-contexts',
401
                                self::PREFIX . 'externals-redux',
402
                                self::PREFIX . 'analysis',
403
                                self::PREFIX . 'react-select',
404
                                self::PREFIX . 'components-new-package',
UNCOV
405
                        ],
×
406
                        'version' => $scripts['workouts']['version'],
407
                ];
408

409
                // Add the current language to every script that requires the analysis package.
410
                foreach ( $scripts as $name => $script ) {
×
411
                        if ( substr( $name, -8 ) === 'language' ) {
×
412
                                continue;
413
                        }
414
                        if ( in_array( self::PREFIX . 'analysis-package', $script['deps'], true ) ) {
×
415
                                $scripts[ $name ]['deps'][] = self::PREFIX . YoastSEO()->helpers->language->get_researcher_language() . '-language';
416
                        }
417
                }
418

419
                return $scripts;
420
        }
421

422
        /**
423
         * Loads a generated asset file.
424
         *
425
         * @param array $args {
426
         *     The arguments.
427
         *
428
         *     @type string                  $asset_file      The asset file to load.
429
         *     @type int                     $ext_length      The length of the extension, including suffix, of the filename.
430
         *     @type string                  $suffix          Optional. The suffix of the asset name.
431
         *     @type array<string, string[]> $additional_deps Optional. The additional dependencies assets may have.
432
         *     @type string                  $base_dir        Optional. The base directory of the asset.
433
         *     @type string[]                $header_scripts  Optional. The script names that should be in the header.
434
         * }
435
         *
436
         * @return array {
437
         *     The scripts to be registered.
438
         *
439
         *     @type string   $name      The name of the asset.
440
         *     @type string   $src       The src of the asset.
441
         *     @type string[] $deps      The dependenies of the asset.
442
         *     @type bool     $in_footer Whether or not the asset should be in the footer.
443
         * }
444
         */
445
        protected function load_generated_asset_file( $args ) {
×
446
                $args    = wp_parse_args(
×
447
                        $args,
UNCOV
448
                        [
×
449
                                'suffix'          => '',
450
                                'additional_deps' => [],
451
                                'base_dir'        => '',
452
                                'header_scripts'  => [],
453
                        ]
UNCOV
454
                );
×
455
                $scripts = [];
×
456
                $assets  = require $args['asset_file'];
×
457
                foreach ( $assets as $file => $data ) {
×
458
                        $name  = substr( $file, 0, -$args['ext_length'] );
×
459
                        $name  = strtolower( preg_replace( '/([A-Z])/', '-$1', $name ) );
×
460
                        $name .= $args['suffix'];
461

462
                        $deps = $data['dependencies'];
×
463
                        if ( isset( $args['additional_deps'][ $name ] ) ) {
×
464
                                $deps = array_merge( $deps, $args['additional_deps'][ $name ] );
465
                        }
466

467
                        $scripts[ $name ] = [
×
468
                                'name'      => $name,
×
469
                                'src'       => $args['base_dir'] . $file,
×
470
                                'deps'      => $deps,
×
471
                                'in_footer' => ! in_array( $name, $args['header_scripts'], true ),
×
472
                                'version'   => $data['version'],
473
                        ];
474
                }
475

476
                return $scripts;
477
        }
478

479
        /**
480
         * Loads the scripts that should be renamed for BC.
481
         *
482
         * @return array {
483
         *     The scripts to be registered.
484
         *
485
         *     @type string   $name      The name of the asset.
486
         *     @type string   $src       The src of the asset.
487
         *     @type string[] $deps      The dependenies of the asset.
488
         *     @type bool     $in_footer Whether or not the asset should be in the footer.
489
         * }
490
         */
491
        protected function load_renamed_scripts() {
×
492
                $scripts         = [];
493
                $renamed_scripts = [
494
                        'admin-global-script'         => 'admin-global',
495
                        'analysis'                    => 'analysis-package',
496
                        'analysis-report'             => 'analysis-report-package',
497
                        'api'                         => 'api-client',
498
                        'commons'                     => 'commons-package',
499
                        'edit-page'                   => 'edit-page-script',
500
                        'draft-js'                    => 'draft-js-package',
501
                        'feature-flag'                => 'feature-flag-package',
502
                        'helpers'                     => 'helpers-package',
503
                        'jed'                         => 'jed-package',
504
                        'chart.js'                    => 'chart.js-package',
505
                        'network-admin-script'        => 'network-admin',
506
                        'redux'                       => 'redux-package',
507
                        'replacement-variable-editor' => 'replacement-variable-editor-package',
508
                        'search-metadata-previews'    => 'search-metadata-previews-package',
509
                        'social-metadata-forms'       => 'social-metadata-forms-package',
510
                        'styled-components'           => 'styled-components-package',
511
                        'style-guide'                 => 'style-guide-package',
512
                        'yoast-components'            => 'components-new-package',
513
                ];
514

515
                foreach ( $renamed_scripts as $original => $replacement ) {
×
516
                        $scripts[] = [
×
517
                                'name' => $original,
UNCOV
518
                                'src'  => false,
×
519
                                'deps' => [ self::PREFIX . $replacement ],
520
                        ];
521
                }
522

523
                return $scripts;
524
        }
525

526
        /**
527
         * Returns the styles that need to be registered.
528
         *
529
         * @todo Data format is not self-documenting. Needs explanation inline. R.
530
         *
531
         * @return array Styles that need to be registered.
532
         */
533
        protected function styles_to_be_registered() {
534
                $flat_version = $this->flatten_version( WPSEO_VERSION );
535

536
                return [
537
                        [
538
                                'name' => 'admin-css',
539
                                'src'  => 'yst_plugin_tools-' . $flat_version,
540
                                'deps' => [ self::PREFIX . 'toggle-switch' ],
541
                        ],
542
                        [
543
                                'name' => 'toggle-switch',
544
                                'src'  => 'toggle-switch-' . $flat_version,
545
                        ],
546
                        [
547
                                'name' => 'dismissible',
548
                                'src'  => 'wpseo-dismissible-' . $flat_version,
549
                        ],
550
                        [
551
                                'name' => 'notifications',
552
                                'src'  => 'notifications-' . $flat_version,
553
                        ],
554
                        [
555
                                'name' => 'alert',
556
                                'src'  => 'alerts-' . $flat_version,
557
                        ],
558
                        [
559
                                'name' => 'edit-page',
560
                                'src'  => 'edit-page-' . $flat_version,
561
                        ],
562
                        [
563
                                'name' => 'featured-image',
564
                                'src'  => 'featured-image-' . $flat_version,
565
                        ],
566
                        [
567
                                'name' => 'metabox-css',
568
                                'src'  => 'metabox-' . $flat_version,
569
                                'deps' => [
570
                                        self::PREFIX . 'admin-css',
571
                                        self::PREFIX . 'tailwind',
572
                                        'wp-components',
573
                                        self::PREFIX . 'additional-mentions',
574
                                ],
575
                        ],
576
                        [
577
                                'name' => 'additional-mentions',
578
                                'src'  => 'additional-mentions-' . $flat_version,
579
                                'deps' => [
580
                                        self::PREFIX . 'tailwind',
581
                                ],
582
                        ],
583
                        [
584
                                'name' => 'ai-generator',
585
                                'src'  => 'ai-generator-' . $flat_version,
586
                                'deps' => [
587
                                        self::PREFIX . 'tailwind',
588
                                        self::PREFIX . 'introductions',
589
                                ],
590
                        ],
591
                        [
592
                                'name' => 'introductions',
593
                                'src'  => 'introductions-' . $flat_version,
594
                                'deps' => [ self::PREFIX . 'tailwind' ],
595
                        ],
596
                        [
597
                                'name' => 'wp-dashboard',
598
                                'src'  => 'dashboard-' . $flat_version,
599
                        ],
600
                        [
601
                                'name' => 'scoring',
602
                                'src'  => 'yst_seo_score-' . $flat_version,
603
                        ],
604
                        [
605
                                'name' => 'adminbar',
606
                                'src'  => 'adminbar-' . $flat_version,
607
                                'deps' => [
608
                                        'admin-bar',
609
                                ],
610
                        ],
611
                        [
612
                                'name' => 'primary-category',
613
                                'src'  => 'metabox-primary-category-' . $flat_version,
614
                        ],
615
                        [
616
                                'name' => 'admin-global',
617
                                'src'  => 'admin-global-' . $flat_version,
618
                        ],
619
                        [
620
                                'name' => 'extensions',
621
                                'src'  => 'yoast-extensions-' . $flat_version,
622
                                'deps' => [
623
                                        'wp-components',
624
                                ],
625
                        ],
626
                        [
627
                                'name' => 'filter-explanation',
628
                                'src'  => 'filter-explanation-' . $flat_version,
629
                        ],
630
                        [
631
                                'name' => 'monorepo',
632
                                'src'  => 'monorepo-' . $flat_version,
633
                        ],
634
                        [
635
                                'name' => 'structured-data-blocks',
636
                                'src'  => 'structured-data-blocks-' . $flat_version,
637
                                'deps' => [
638
                                        'dashicons',
639
                                        'forms',
640
                                        'wp-edit-blocks',
641
                                ],
642
                        ],
643
                        [
644
                                'name' => 'elementor',
645
                                'src'  => 'elementor-' . $flat_version,
646
                        ],
647
                        [
648
                                'name' => 'tailwind',
649
                                'src'  => 'tailwind-' . $flat_version,
650
                        ],
651
                        [
652
                                'name' => 'new-settings',
653
                                'src'  => 'new-settings-' . $flat_version,
654
                                'deps' => [
655
                                        self::PREFIX . 'tailwind',
656
                                        self::PREFIX . 'additional-mentions',
657
                                ],
658
                        ],
659
                        [
660
                                'name' => 'black-friday-banner',
661
                                'src'  => 'black-friday-banner-' . $flat_version,
662
                                'deps' => [ self::PREFIX . 'tailwind' ],
663
                        ],
664
                        [
665
                                'name' => 'academy',
666
                                'src'  => 'academy-' . $flat_version,
667
                                'deps' => [ self::PREFIX . 'tailwind' ],
668
                        ],
669
                        [
670
                                'name' => 'support',
671
                                'src'  => 'support-' . $flat_version,
672
                                'deps' => [ self::PREFIX . 'tailwind' ],
673
                        ],
674
                        [
675
                                'name' => 'workouts',
676
                                'src'  => 'workouts-' . $flat_version,
677
                                'deps' => [
678
                                        self::PREFIX . 'monorepo',
679
                                ],
680
                        ],
681
                        [
682
                                'name' => 'first-time-configuration',
683
                                'src'  => 'first-time-configuration-' . $flat_version,
684
                                'deps' => [ self::PREFIX . 'tailwind' ],
685
                        ],
686
                        [
687
                                'name' => 'inside-editor',
688
                                'src'  => 'inside-editor-' . $flat_version,
689
                        ],
690
                ];
691
        }
692

693
        /**
694
         * Determines the URL of the asset.
695
         *
696
         * @param WPSEO_Admin_Asset $asset The asset to determine the URL for.
697
         * @param string            $type  The type of asset. Usually JS or CSS.
698
         *
699
         * @return string The URL of the asset.
700
         */
701
        protected function get_url( WPSEO_Admin_Asset $asset, $type ) {
×
702
                $scheme = wp_parse_url( $asset->get_src(), PHP_URL_SCHEME );
×
703
                if ( in_array( $scheme, [ 'http', 'https' ], true ) ) {
×
704
                        return $asset->get_src();
705
                }
706

707
                return $this->asset_location->get_url( $asset, $type );
708
        }
709
}
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