Changeset 53416
- Timestamp:
- 05/20/2022 12:47:45 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 11 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-theme-upgrader.php
r52998 r53416 567 567 } 568 568 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 ) { 571 580 return new WP_Error( 572 581 'incompatible_archive_theme_no_index', 573 582 $this->strings['incompatible_archive'], 574 583 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>' 578 591 ) 579 592 ); -
trunk/src/wp-includes/class-wp-theme.php
r53254 r53416 342 342 $theme_path = $this->theme_root . '/' . $this->stylesheet; 343 343 344 if ( ! file_exists( $theme_path . '/templates/index.html' ) 344 if ( 345 ! file_exists( $theme_path . '/templates/index.html' ) 346 && ! file_exists( $theme_path . '/block-templates/index.html' ) // Deprecated path support since 5.9.0. 345 347 && ! file_exists( $theme_path . '/index.php' ) 346 348 ) { -
trunk/src/wp-includes/theme.php
r53053 r53416 862 862 } 863 863 864 if ( ! file_exists( get_template_directory() . '/templates/index.html' ) 864 if ( 865 ! file_exists( get_template_directory() . '/templates/index.html' ) 866 && ! file_exists( get_template_directory() . '/block-templates/index.html' ) // Deprecated path support since 5.9.0. 865 867 && ! file_exists( get_template_directory() . '/index.php' ) 866 868 ) { -
trunk/tests/phpunit/tests/rest-api/wpRestTemplatesController.php
r52436 r53416 286 286 'post_title' => 'Home Page Template', 287 287 'post_content' => file_get_contents( $theme_root_dir . 'block-theme/templates/page-home.html' ), 288 'post_excerpt' => 'Description of page home template.', 289 ), 290 ), 291 'template: parent theme deprecated path' => array( 292 'theme_dir' => 'themedir1/block-theme-deprecated-path', 293 'template' => 'page-home', 294 'args' => array( 295 'post_name' => 'page-home', 296 'post_title' => 'Home Page Template', 297 'post_content' => file_get_contents( $theme_root_dir . 'block-theme-deprecated-path/block-templates/page-home.html' ), 288 298 'post_excerpt' => 'Description of page home template.', 289 299 ), -
trunk/tests/phpunit/tests/theme/themeDir.php
r53282 r53416 166 166 'Block Theme [0.4.0]', 167 167 'Block Theme [1.0.0] in subdirectory', 168 'Block Theme Deprecated Path', 168 169 'Webfonts theme', 169 170 'Empty `fontFace` in theme.json - no webfonts defined', 170 171 ); 171 172 172 sort( $theme_names ); 173 sort( $expected ); 174 175 $this->assertSame( $expected, $theme_names ); 173 $this->assertSameSets( $expected, $theme_names ); 176 174 } 177 175 -
trunk/tests/phpunit/tests/theme/wpTheme.php
r53253 r53416 310 310 'expected' => true, 311 311 ), 312 'deprecated block theme' => array( 313 'theme_dir' => 'block-theme-deprecated-path', 314 'expected' => true, 315 ), 312 316 ); 313 317 } … … 336 340 public function data_get_file_path() { 337 341 return array( 338 'no theme: no file given' => array(342 'no theme: no file given' => array( 339 343 'theme_dir' => 'nonexistent', 340 344 'file' => '', 341 345 'expected' => '/nonexistent', 342 346 ), 343 'parent theme: no file given' => array(347 'parent theme: no file given' => array( 344 348 'theme_dir' => 'block-theme', 345 349 'file' => '', 346 350 'expected' => '/block-theme', 347 351 ), 348 'child theme: no file given' => array(352 'child theme: no file given' => array( 349 353 'theme_dir' => 'block-theme-child', 350 354 'file' => '', 351 355 'expected' => '/block-theme-child', 352 356 ), 353 'nonexistent theme: file given' => array(357 'nonexistent theme: file given' => array( 354 358 'theme_dir' => 'nonexistent', 355 359 'file' => '/templates/page.html', 356 360 'expected' => '/nonexistent/templates/page.html', 357 361 ), 358 'parent theme: file exists' => array(362 'parent theme: file exists' => array( 359 363 'theme_dir' => 'block-theme', 360 364 'file' => '/templates/page-home.html', 361 365 'expected' => '/block-theme/templates/page-home.html', 362 366 ), 363 'parent theme: file does not exist' => array( 367 'parent theme: deprecated file exists' => array( 368 'theme_dir' => 'block-theme-deprecated-path', 369 'file' => '/block-templates/page-home.html', 370 'expected' => '/block-theme-deprecated-path/block-templates/page-home.html', 371 ), 372 'parent theme: file does not exist' => array( 364 373 'theme_dir' => 'block-theme', 365 374 'file' => '/templates/nonexistent.html', 366 375 'expected' => '/block-theme/templates/nonexistent.html', 367 376 ), 368 'child theme: file exists' => array(377 'child theme: file exists' => array( 369 378 'theme_dir' => 'block-theme-child', 370 379 'file' => '/templates/page-1.html', 371 380 'expected' => '/block-theme-child/templates/page-1.html', 372 381 ), 373 'child theme: file does not exist' => array(382 'child theme: file does not exist' => array( 374 383 'theme_dir' => 'block-theme-child', 375 384 'file' => '/templates/nonexistent.html',
Note: See TracChangeset
for help on using the changeset viewer.