Make WordPress Core


Ignore:
Timestamp:
05/20/2022 12:59:55 AM (3 years ago)
Author:
peterwilsoncc
Message:

Themes: Accept valid block themes.

Updates theme validation to accept block themes. This replaces the requirement for an index.php with a requirement for either an index.php, /templates/index.html or the deprecated /block-templates/index.html.

Validation is updated for theme uploads, within WP_Theme::__construct and validate_current_theme().

A block theme using the deprecated file structure is now included in the unit tests.

Props peterwilsoncc, sergeybiryukov, hellofromtonya, costdev, azaozz, gziolo, FlorianBrinkmann, Boniu91, aristath, poena, audrasjb.
Merges [53416] to the 6.0 branch.
Fixes #55682.

Location:
branches/6.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.0

  • branches/6.0/src/wp-admin/includes/class-theme-upgrader.php

    r52998 r53417  
    567567        }
    568568
    569         // If it's not a child theme, it must have at least an index.php to be legit.
    570         if ( empty( $info['Template'] ) && ! file_exists( $working_directory . 'index.php' ) ) {
     569        /*
     570         * Parent themes must contain an index file:
     571         * - classic themes require /index.php
     572         * - block themes require /templates/index.html or block-templates/index.html (deprecated 5.9.0).
     573         */
     574        if (
     575            empty( $info['Template'] ) &&
     576            ! file_exists( $working_directory . 'index.php' ) &&
     577            ! file_exists( $working_directory . 'templates/index.html' ) &&
     578            ! file_exists( $working_directory . 'block-templates/index.html' )
     579        ) {
    571580            return new WP_Error(
    572581                'incompatible_archive_theme_no_index',
    573582                $this->strings['incompatible_archive'],
    574583                sprintf(
    575                     /* translators: %s: index.php */
    576                     __( 'The theme is missing the %s file.' ),
    577                     '<code>index.php</code>'
     584                    /* translators: 1: templates/index.html, 2: index.php, 3: Documentation URL, 4: Template, 5: style.css */
     585                    __( 'Template is missing. Standalone themes need to have a %1$s or %2$s template file. <a href="%3$s">Child themes</a> need to have a %4$s header in the %5$s stylesheet.' ),
     586                    '<code>templates/index.html</code>',
     587                    '<code>index.php</code>',
     588                    __( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ),
     589                    '<code>Template</code>',
     590                    '<code>style.css</code>'
    578591                )
    579592            );
Note: See TracChangeset for help on using the changeset viewer.