Make WordPress Core


Ignore:
Timestamp:
06/13/2023 09:51:11 AM (16 months ago)
Author:
spacedmonkey
Message:

Script Loader: Add a check to see in style is registered in wp_maybe_inline_styles.

Add a check in wp_maybe_inline_styles to check that style is registered before processing items in queue. It is possible that developers may have called wp_deregister_style, unregistering style but the style still be in the queue to be processed. Without this check, typing to access the src property would result in a notice error.

Follow on from [55888].

Props spacedmonkey, flixos90, dd32, kebbet.
See #58394.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/script-loader.php

    r55900 r55909  
    28732873    // Build an array of styles that have a path defined.
    28742874    foreach ( $wp_styles->queue as $handle ) {
     2875        if ( ! isset( $wp_styles->registered[ $handle ] ) ) {
     2876            continue;
     2877        }
    28752878        $src  = $wp_styles->registered[ $handle ]->src;
    2876         $path = wp_styles()->get_data( $handle, 'path' );
     2879        $path = $wp_styles->get_data( $handle, 'path' );
    28772880        if ( $path && $src ) {
    28782881            $size = wp_filesize( $path );
Note: See TracChangeset for help on using the changeset viewer.