Make WordPress Core

Changeset 60678


Ignore:
Timestamp:
08/26/2025 11:19:47 PM (6 months ago)
Author:
TimothyBlynJacobs
Message:

Media: Fix playlist shortcodes not rendering correctly if the first playlist is broken.

The playlist shortcode has a base set of JavaScript that should only be loaded once. Previously, this JS was only loaded the first time a playlist shortcode was processed. If the first playlist was broken, because the media file was missing for instance, this would break all other playlists on the page.

This commit introduces a new static variable to keep track of whether the necessary JavaScript has been loaded instead.

Props iamadisingh, abcd95, justlevine, jorbin, rollybueno, Guido07111975.
Fixes #63583.

Location:
trunk
Files:
1 added
1 edited

Legend:

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

    r60641 r60678  
    30573057    ++$instance;
    30583058
     3059    static $is_loaded = false;
     3060
    30593061    if ( ! empty( $attr['ids'] ) ) {
    30603062        // 'ids' is explicitly ordered, unless you specify otherwise.
     
    32383240    ob_start();
    32393241
    3240     if ( 1 === $instance ) {
     3242    if ( ! $is_loaded ) {
    32413243        /**
    32423244         * Prints and enqueues playlist scripts, styles, and JavaScript templates.
     
    32483250         */
    32493251        do_action( 'wp_playlist_scripts', $atts['type'], $atts['style'] );
     3252        $is_loaded = true;
    32503253    }
    32513254    ?>
Note: See TracChangeset for help on using the changeset viewer.