- Timestamp:
- 03/15/2024 02:59:10 PM (2 years ago)
- Location:
- branches/6.5
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/wp-includes/class-wp-script-modules.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/6.5
-
branches/6.5/src/wp-includes/class-wp-script-modules.php
r57644 r57844 192 192 array( 193 193 'type' => 'module', 194 'src' => $this->get_ versioned_src( $script_module),194 'src' => $this->get_src( $id ), 195 195 'id' => $id . '-js-module', 196 196 ) … … 213 213 echo sprintf( 214 214 '<link rel="modulepreload" href="%s" id="%s">', 215 esc_url( $this->get_ versioned_src( $script_module) ),215 esc_url( $this->get_src( $id ) ), 216 216 esc_attr( $id . '-js-modulepreload' ) 217 217 ); … … 265 265 $imports = array(); 266 266 foreach ( $this->get_dependencies( array_keys( $this->get_marked_for_enqueue() ) ) as $id => $script_module ) { 267 $imports[ $id ] = $this->get_ versioned_src( $script_module);267 $imports[ $id ] = $this->get_src( $id ); 268 268 } 269 269 return array( 'imports' => $imports ); … … 332 332 * @since 6.5.0 333 333 * 334 * @param array $script_module The script module.334 * @param string $id The script module identifier. 335 335 * @return string The script module src with a version if relevant. 336 336 */ 337 private function get_versioned_src( array $script_module ): string { 338 $args = array(); 337 private function get_src( string $id ): string { 338 if ( ! isset( $this->registered[ $id ] ) ) { 339 return ''; 340 } 341 342 $script_module = $this->registered[ $id ]; 343 $src = $script_module['src']; 344 339 345 if ( false === $script_module['version'] ) { 340 $ args['ver'] = get_bloginfo( 'version');346 $src = add_query_arg( 'ver', get_bloginfo( 'version' ), $src ); 341 347 } elseif ( null !== $script_module['version'] ) { 342 $args['ver'] = $script_module['version']; 343 } 344 if ( $args ) { 345 return add_query_arg( $args, $script_module['src'] ); 346 } 347 return $script_module['src']; 348 $src = add_query_arg( 'ver', $script_module['version'], $src ); 349 } 350 351 /** 352 * Filters the script module source. 353 * 354 * @since 6.5.0 355 * 356 * @param string $src Module source url. 357 * @param string $id Module identifier. 358 */ 359 $src = apply_filters( 'script_module_loader_src', $src, $id ); 360 361 return $src; 348 362 } 349 363 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)