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

Yoast / wordpress-seo / 99afd0130cdf4290568c91bf34c67d11326f83d2

09 Sep 2025 08:26AM UTC coverage: 53.206% (+0.4%) from 52.846%
99afd0130cdf4290568c91bf34c67d11326f83d2

push

github

YoastBot
Bump version to 25.9 on free

8344 of 15215 branches covered (54.84%)

Branch coverage included in aggregate %.

31641 of 59937 relevant lines covered (52.79%)

39836.33 hits per line

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

16.28
/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
         * @return void
58
         */
59
        public function enqueue_script( $script ) {
4✔
60
                wp_enqueue_script( $this->prefix . $script );
4✔
61
        }
62

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

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

83
        /**
84
         * Registers scripts based on it's parameters.
85
         *
86
         * @param WPSEO_Admin_Asset $script The script to register.
87
         *
88
         * @return void
89
         */
90
        public function register_script( WPSEO_Admin_Asset $script ) {
8✔
91
                $url  = $script->get_src() ? $this->get_url( $script, WPSEO_Admin_Asset::TYPE_JS ) : false;
8✔
92
                $args = [
8✔
93
                        'in_footer' => $script->is_in_footer(),
8✔
94
                ];
8✔
95

96
                if ( $script->get_strategy() !== '' ) {
8✔
97
                        $args['strategy'] = $script->get_strategy();
×
98
                }
99

100
                wp_register_script(
8✔
101
                        $this->prefix . $script->get_name(),
8✔
102
                        $url,
8✔
103
                        $script->get_deps(),
8✔
104
                        $script->get_version(),
8✔
105
                        $args
8✔
106
                );
8✔
107

108
                if ( in_array( 'wp-i18n', $script->get_deps(), true ) ) {
8✔
109
                        wp_set_script_translations( $this->prefix . $script->get_name(), 'wordpress-seo' );
×
110
                }
111
        }
112

113
        /**
114
         * Registers styles based on it's parameters.
115
         *
116
         * @param WPSEO_Admin_Asset $style The style to register.
117
         *
118
         * @return void
119
         */
120
        public function register_style( WPSEO_Admin_Asset $style ) {
8✔
121
                wp_register_style(
8✔
122
                        $this->prefix . $style->get_name(),
8✔
123
                        $this->get_url( $style, WPSEO_Admin_Asset::TYPE_CSS ),
8✔
124
                        $style->get_deps(),
8✔
125
                        $style->get_version(),
8✔
126
                        $style->get_media()
8✔
127
                );
8✔
128
        }
129

130
        /**
131
         * Calls the functions that register scripts and styles with the scripts and styles to be registered as arguments.
132
         *
133
         * @return void
134
         */
135
        public function register_assets() {
4✔
136
                $this->register_scripts( $this->scripts_to_be_registered() );
4✔
137
                $this->register_styles( $this->styles_to_be_registered() );
4✔
138
        }
139

140
        /**
141
         * Registers all the scripts passed to it.
142
         *
143
         * @param array $scripts The scripts passed to it.
144
         *
145
         * @return void
146
         */
147
        public function register_scripts( $scripts ) {
4✔
148
                foreach ( $scripts as $script ) {
4✔
149
                        $script = new WPSEO_Admin_Asset( $script );
4✔
150
                        $this->register_script( $script );
4✔
151
                }
152
        }
153

154
        /**
155
         * Registers all the styles it receives.
156
         *
157
         * @param array $styles Styles that need to be registered.
158
         *
159
         * @return void
160
         */
161
        public function register_styles( $styles ) {
4✔
162
                foreach ( $styles as $style ) {
4✔
163
                        $style = new WPSEO_Admin_Asset( $style );
4✔
164
                        $this->register_style( $style );
4✔
165
                }
166
        }
167

168
        /**
169
         * Localizes the script.
170
         *
171
         * @param string $handle      The script handle.
172
         * @param string $object_name The object name.
173
         * @param array  $data        The l10n data.
174
         *
175
         * @return void
176
         */
177
        public function localize_script( $handle, $object_name, $data ) {
×
178
                wp_localize_script( $this->prefix . $handle, $object_name, $data );
×
179
        }
180

181
        /**
182
         * Adds an inline script.
183
         *
184
         * @param string $handle   The script handle.
185
         * @param string $data     The l10n data.
186
         * @param string $position Optional. Whether to add the inline script before the handle or after.
187
         *
188
         * @return void
189
         */
190
        public function add_inline_script( $handle, $data, $position = 'after' ) {
×
191
                wp_add_inline_script( $this->prefix . $handle, $data, $position );
×
192
        }
193

194
        /**
195
         * A list of styles that shouldn't be registered but are needed in other locations in the plugin.
196
         *
197
         * @return array
198
         */
199
        public function special_styles() {
×
200
                $flat_version = $this->flatten_version( WPSEO_VERSION );
×
201
                $asset_args   = [
×
202
                        'name' => 'inside-editor',
×
203
                        'src'  => 'inside-editor-' . $flat_version,
×
204
                ];
×
205

206
                return [ 'inside-editor' => new WPSEO_Admin_Asset( $asset_args ) ];
×
207
        }
208

209
        /**
210
         * Flattens a version number for use in a filename.
211
         *
212
         * @param string $version The original version number.
213
         *
214
         * @return string The flattened version number.
215
         */
216
        public function flatten_version( $version ) {
24✔
217
                $parts = explode( '.', $version );
24✔
218

219
                if ( count( $parts ) === 2 && preg_match( '/^\d+$/', $parts[1] ) === 1 ) {
24✔
220
                        $parts[] = '0';
8✔
221
                }
222

223
                return implode( '', $parts );
24✔
224
        }
225

226
        /**
227
         * Creates a default location object for use in the admin asset manager.
228
         *
229
         * @return WPSEO_Admin_Asset_Location The location to use in the asset manager.
230
         */
231
        public static function create_default_location() {
×
232
                if ( defined( 'YOAST_SEO_DEV_SERVER' ) && YOAST_SEO_DEV_SERVER ) {
×
233
                        $url = defined( 'YOAST_SEO_DEV_SERVER_URL' ) ? YOAST_SEO_DEV_SERVER_URL : WPSEO_Admin_Asset_Dev_Server_Location::DEFAULT_URL;
×
234

235
                        return new WPSEO_Admin_Asset_Dev_Server_Location( $url );
×
236
                }
237

238
                return new WPSEO_Admin_Asset_SEO_Location( WPSEO_FILE, false );
×
239
        }
240

241
        /**
242
         * Checks if the given script is enqueued.
243
         *
244
         * @param string $script The script to check.
245
         *
246
         * @return bool True when the script is enqueued.
247
         */
248
        public function is_script_enqueued( $script ) {
×
249
                return wp_script_is( $this->prefix . $script );
×
250
        }
251

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

328
                $plugin_scripts   = $this->load_generated_asset_file(
×
329
                        [
×
330
                                'asset_file'      => __DIR__ . '/../src/generated/assets/plugin.php',
×
331
                                'ext_length'      => 3,
×
332
                                'additional_deps' => $additional_dependencies,
×
333
                                'header_scripts'  => $header_scripts,
×
334
                        ]
×
335
                );
×
336
                $external_scripts = $this->load_generated_asset_file(
×
337
                        [
×
338
                                'asset_file'      => __DIR__ . '/../src/generated/assets/externals.php',
×
339
                                'ext_length'      => 3,
×
340
                                'suffix'          => '-package',
×
341
                                'base_dir'        => 'externals/',
×
342
                                'additional_deps' => $additional_dependencies,
×
343
                                'header_scripts'  => $header_scripts,
×
344
                        ]
×
345
                );
×
346
                $language_scripts = $this->load_generated_asset_file(
×
347
                        [
×
348
                                'asset_file'      => __DIR__ . '/../src/generated/assets/languages.php',
×
349
                                'ext_length'      => 3,
×
350
                                'suffix'          => '-language',
×
351
                                'base_dir'        => 'languages/',
×
352
                                'additional_deps' => $additional_dependencies,
×
353
                                'header_scripts'  => $header_scripts,
×
354
                        ]
×
355
                );
×
356
                $renamed_scripts  = $this->load_renamed_scripts();
×
357

358
                $scripts = array_merge(
×
359
                        $plugin_scripts,
×
360
                        $external_scripts,
×
361
                        $language_scripts,
×
362
                        $renamed_scripts
×
363
                );
×
364

365
                $scripts['installation-success'] = [
×
366
                        'name'    => 'installation-success',
×
367
                        'src'     => 'installation-success.js',
×
368
                        'deps'    => [
×
369
                                'wp-a11y',
×
370
                                'wp-dom-ready',
×
371
                                'wp-components',
×
372
                                'wp-element',
×
373
                                'wp-i18n',
×
374
                                self::PREFIX . 'components-new-package',
×
375
                                self::PREFIX . 'externals-components',
×
376
                        ],
×
377
                        'version' => $scripts['installation-success']['version'],
×
378
                ];
×
379

380
                $scripts['post-edit-classic'] = [
×
381
                        'name'      => 'post-edit-classic',
×
382
                        'src'       => $scripts['post-edit']['src'],
×
383
                        'deps'      => array_map(
×
384
                                static function ( $dep ) {
×
385
                                        if ( $dep === self::PREFIX . 'block-editor' ) {
×
386
                                                return self::PREFIX . 'classic-editor';
387
                                        }
388
                                        return $dep;
×
389
                                },
×
390
                                $scripts['post-edit']['deps']
×
391
                        ),
×
392
                        'in_footer' => ! in_array( 'post-edit-classic', $header_scripts, true ),
×
393
                        'version'   => $scripts['post-edit']['version'],
×
394
                ];
×
395

396
                $scripts['workouts'] = [
×
397
                        'name'    => 'workouts',
×
398
                        'src'     => 'workouts.js',
×
399
                        'deps'    => [
×
400
                                'clipboard',
×
401
                                'lodash',
×
402
                                'wp-api-fetch',
×
403
                                'wp-a11y',
×
404
                                'wp-components',
×
405
                                'wp-compose',
×
406
                                'wp-data',
×
407
                                'wp-dom-ready',
×
408
                                'wp-element',
×
409
                                'wp-i18n',
×
410
                                self::PREFIX . 'externals-components',
×
411
                                self::PREFIX . 'externals-contexts',
×
412
                                self::PREFIX . 'externals-redux',
×
413
                                self::PREFIX . 'analysis',
×
414
                                self::PREFIX . 'components-new-package',
×
415
                        ],
×
416
                        'version' => $scripts['workouts']['version'],
×
417
                ];
×
418

419
                // Add the current language to every script that requires the analysis package.
420
                foreach ( $scripts as $name => $script ) {
×
421
                        if ( substr( $name, -8 ) === 'language' ) {
×
422
                                continue;
423
                        }
424
                        if ( in_array( self::PREFIX . 'analysis-package', $script['deps'], true ) ) {
×
425
                                $scripts[ $name ]['deps'][] = self::PREFIX . YoastSEO()->helpers->language->get_researcher_language() . '-language';
426
                        }
427
                }
428

429
                return $scripts;
430
        }
431

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

472
                        $deps = $data['dependencies'];
×
473
                        if ( isset( $args['additional_deps'][ $name ] ) ) {
×
474
                                $deps = array_merge( $deps, $args['additional_deps'][ $name ] );
475
                        }
476

477
                        $scripts[ $name ] = [
×
478
                                'name'      => $name,
×
479
                                'src'       => $args['base_dir'] . $file,
×
480
                                'deps'      => $deps,
×
481
                                'in_footer' => ! in_array( $name, $args['header_scripts'], true ),
×
482
                                'version'   => $data['version'],
×
483
                        ];
×
484
                }
485

486
                return $scripts;
487
        }
488

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

525
                foreach ( $renamed_scripts as $original => $replacement ) {
×
526
                        $scripts[] = [
×
527
                                'name' => $original,
×
528
                                'src'  => false,
×
529
                                'deps' => [ self::PREFIX . $replacement ],
×
530
                        ];
×
531
                }
532

533
                return $scripts;
534
        }
535

536
        /**
537
         * Returns the styles that need to be registered.
538
         *
539
         * @todo Data format is not self-documenting. Needs explanation inline. R.
540
         *
541
         * @return array Styles that need to be registered.
542
         */
543
        protected function styles_to_be_registered() {
544
                $flat_version = $this->flatten_version( WPSEO_VERSION );
545

546
                return [
547
                        [
548
                                'name' => 'admin-css',
549
                                'src'  => 'yst_plugin_tools-' . $flat_version,
550
                                'deps' => [ self::PREFIX . 'toggle-switch' ],
551
                        ],
552
                        [
553
                                'name' => 'toggle-switch',
554
                                'src'  => 'toggle-switch-' . $flat_version,
555
                        ],
556
                        [
557
                                'name' => 'dismissible',
558
                                'src'  => 'wpseo-dismissible-' . $flat_version,
559
                        ],
560
                        [
561
                                'name' => 'notifications',
562
                                'src'  => 'notifications-' . $flat_version,
563
                        ],
564
                        [
565
                                'name' => 'alert',
566
                                'src'  => 'alerts-' . $flat_version,
567
                        ],
568
                        [
569
                                'name' => 'edit-page',
570
                                'src'  => 'edit-page-' . $flat_version,
571
                        ],
572
                        [
573
                                'name' => 'featured-image',
574
                                'src'  => 'featured-image-' . $flat_version,
575
                        ],
576
                        [
577
                                'name' => 'metabox-css',
578
                                'src'  => 'metabox-' . $flat_version,
579
                                'deps' => [
580
                                        self::PREFIX . 'admin-css',
581
                                        self::PREFIX . 'tailwind',
582
                                        'wp-components',
583
                                ],
584
                        ],
585
                        [
586
                                'name' => 'block-editor',
587
                                'src'  => 'block-editor-' . $flat_version,
588
                        ],
589
                        [
590
                                'name' => 'ai-generator',
591
                                'src'  => 'ai-generator-' . $flat_version,
592
                                'deps' => [
593
                                        self::PREFIX . 'ai-frontend',
594
                                        self::PREFIX . 'tailwind',
595
                                        self::PREFIX . 'introductions',
596
                                ],
597
                        ],
598
                        [
599
                                'name' => 'ai-fix-assessments',
600
                                'src'  => 'ai-fix-assessments-' . $flat_version,
601
                        ],
602
                        [
603
                                'name' => 'ai-frontend',
604
                                'src'  => 'ai-frontend-' . $flat_version,
605
                        ],
606
                        [
607
                                'name' => 'introductions',
608
                                'src'  => 'introductions-' . $flat_version,
609
                                'deps' => [ self::PREFIX . 'tailwind' ],
610
                        ],
611
                        [
612
                                'name' => 'wp-dashboard',
613
                                'src'  => 'dashboard-' . $flat_version,
614
                        ],
615
                        [
616
                                'name' => 'scoring',
617
                                'src'  => 'yst_seo_score-' . $flat_version,
618
                        ],
619
                        [
620
                                'name' => 'adminbar',
621
                                'src'  => 'adminbar-' . $flat_version,
622
                                'deps' => [
623
                                        'admin-bar',
624
                                ],
625
                        ],
626
                        [
627
                                'name' => 'primary-category',
628
                                'src'  => 'metabox-primary-category-' . $flat_version,
629
                        ],
630
                        [
631
                                'name' => 'admin-global',
632
                                'src'  => 'admin-global-' . $flat_version,
633
                                'deps' => [ self::PREFIX . 'tailwind' ],
634
                        ],
635
                        [
636
                                'name' => 'filter-explanation',
637
                                'src'  => 'filter-explanation-' . $flat_version,
638
                        ],
639
                        [
640
                                'name' => 'monorepo',
641
                                'src'  => 'monorepo-' . $flat_version,
642
                        ],
643
                        [
644
                                'name' => 'structured-data-blocks',
645
                                'src'  => 'structured-data-blocks-' . $flat_version,
646
                                'deps' => [
647
                                        'dashicons',
648
                                        'forms',
649
                                        'wp-edit-blocks',
650
                                ],
651
                        ],
652
                        [
653
                                'name' => 'elementor',
654
                                'src'  => 'elementor-' . $flat_version,
655
                        ],
656
                        [
657
                                'name' => 'tailwind',
658
                                'src'  => 'tailwind-' . $flat_version,
659
                                // Note: The RTL suffix is not added here.
660
                                // Tailwind and our UI library provide styling that should be standalone compatible with RTL.
661
                                // To make it easier we should use the logical properties and values when possible.
662
                                // If there are exceptions, we can use the Tailwind modifier, e.g. `rtl:yst-space-x-reverse`.
663
                                'rtl'  => false,
664
                        ],
665
                        [
666
                                'name' => 'new-settings',
667
                                'src'  => 'new-settings-' . $flat_version,
668
                                'deps' => [ self::PREFIX . 'tailwind' ],
669
                        ],
670
                        [
671
                                'name' => 'redirects',
672
                                'src'  => 'redirects-' . $flat_version,
673
                                'deps' => [ self::PREFIX . 'tailwind' ],
674
                        ],
675
                        [
676
                                'name' => 'black-friday-banner',
677
                                'src'  => 'black-friday-banner-' . $flat_version,
678
                                'deps' => [ self::PREFIX . 'tailwind' ],
679
                        ],
680
                        [
681
                                'name' => 'academy',
682
                                'src'  => 'academy-' . $flat_version,
683
                                'deps' => [ self::PREFIX . 'tailwind' ],
684
                        ],
685
                        [
686
                                'name' => 'general-page',
687
                                'src'  => 'general-page-' . $flat_version,
688
                                'deps' => [ self::PREFIX . 'tailwind' ],
689
                        ],
690
                        [
691
                                'name' => 'support',
692
                                'src'  => 'support-' . $flat_version,
693
                                'deps' => [ self::PREFIX . 'tailwind' ],
694
                        ],
695
                        [
696
                                'name' => 'workouts',
697
                                'src'  => 'workouts-' . $flat_version,
698
                                'deps' => [
699
                                        self::PREFIX . 'monorepo',
700
                                ],
701
                        ],
702
                        [
703
                                'name' => 'first-time-configuration',
704
                                'src'  => 'first-time-configuration-' . $flat_version,
705
                                'deps' => [ self::PREFIX . 'tailwind' ],
706
                        ],
707
                        [
708
                                'name' => 'inside-editor',
709
                                'src'  => 'inside-editor-' . $flat_version,
710
                        ],
711
                        [
712
                                'name' => 'plans',
713
                                'src'  => 'plans-' . $flat_version,
714
                                'deps' => [ self::PREFIX . 'tailwind' ],
715
                        ],
716
                ];
717
        }
718

719
        /**
720
         * Determines the URL of the asset.
721
         *
722
         * @param WPSEO_Admin_Asset $asset The asset to determine the URL for.
723
         * @param string            $type  The type of asset. Usually JS or CSS.
724
         *
725
         * @return string The URL of the asset.
726
         */
727
        protected function get_url( WPSEO_Admin_Asset $asset, $type ) {
×
728
                $scheme = wp_parse_url( $asset->get_src(), PHP_URL_SCHEME );
×
729
                if ( in_array( $scheme, [ 'http', 'https' ], true ) ) {
×
730
                        return $asset->get_src();
731
                }
732

733
                return $this->asset_location->get_url( $asset, $type );
734
        }
735
}
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