Make WordPress Core

Changeset 56330 for branches/6.3


Ignore:
Timestamp:
08/01/2023 04:22:42 AM (16 months ago)
Author:
isabel_brison
Message:

Editor: fix duplication in templates list.

Excludes parent template when a child template is defined during template retrieval.

Props oandregal, mukesh27, flixos90, bgardner, peterwilsoncc.
Reviewed by peterwilsoncc.
Merges [56329] to the 6.3 branch.
Fixes #57756.

Location:
branches/6.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.3

  • branches/6.3/src/wp-includes/block-template-utils.php

    r56288 r56330  
    361361            }
    362362
     363            /*
     364             * The child theme items (stylesheet) are processed before the parent theme's (template).
     365             * If a child theme defines a template, prevent the parent template from being added to the list as well.
     366             */
     367            if ( isset( $template_files[ $template_slug ] ) ) {
     368                continue;
     369            }
     370
    363371            $new_template_item = array(
    364372                'slug'  => $template_slug,
     
    371379                $candidate = _add_block_template_part_area_info( $new_template_item );
    372380                if ( ! isset( $area ) || ( isset( $area ) && $area === $candidate['area'] ) ) {
    373                     $template_files[] = $candidate;
     381                    $template_files[ $template_slug ] = $candidate;
    374382                }
    375383            }
     
    381389                    ( $post_type && isset( $candidate['postTypes'] ) && in_array( $post_type, $candidate['postTypes'], true ) )
    382390                ) {
    383                     $template_files[] = $candidate;
     391                    $template_files[ $template_slug ] = $candidate;
    384392                }
    385393            }
     
    387395    }
    388396
    389     return $template_files;
     397    return array_values( $template_files );
    390398}
    391399
Note: See TracChangeset for help on using the changeset viewer.