Make WordPress Core


Ignore:
Timestamp:
12/03/2021 03:28:21 PM (3 years ago)
Author:
audrasjb
Message:

Editor: Avoid undefined index notices in the Template Parts Editor.

This changes adds a leading slash when needed in the ?context=edit path to avoid an undefined index notice in the Template Parts Editor.

Follow-up to [52275].

Props kafleg, costdev, mukesh27, Boniu91.
Fixes #54558.

File:
1 edited

Legend:

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

    r52275 r52312  
    468468     */
    469469    $backup_global_post = ! empty( $post ) ? clone $post : $post;
     470
     471    foreach ( $preload_paths as &$path ) {
     472        if ( is_string( $path ) && ! str_starts_with( $path, '/' ) ) {
     473            $path = '/' . $path;
     474            continue;
     475        }
     476
     477        if ( is_array( $path ) && is_string( $path[0] ) && ! str_starts_with( $path[0], '/' ) ) {
     478                $path[0] = '/' . $path[0];
     479        }
     480    }
    470481
    471482    $preload_data = array_reduce(
Note: See TracChangeset for help on using the changeset viewer.