Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#53752 closed defect (bug) (fixed)

Twenty Ten: Block patterns file causes error in child themes

Reported by: ryelle's profile ryelle Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.8.1 Priority: normal
Severity: normal Version: 5.8
Component: Bundled Theme Keywords: has-patch fixed-major
Focuses: Cc:

Description

In Twenty Ten, the block-patterns.php file is loaded using the get_stylesheet_directory path. When there's a child theme of Twenty Ten, this uses the child theme's folder, but it's unlikely that the child theme has this file. This causes a fatal error, for example:

require(): Failed opening required '/wp-content/themes/wordcamp-central-2012/block-patterns.php' in '/wp-content/themes/twentyten/functions.php:743'

Attachments (1)

53752.diff (553 bytes) - added by sabernhardt 3 years ago.

Download all attachments as: .zip

Change History (9)

@sabernhardt
3 years ago

#1 @sabernhardt
3 years ago

  • Keywords has-patch added

The changeset was [51106]

#2 @sabernhardt
3 years ago

Each of the other ten bundled themes uses the template directory:
require get_template_directory() . '/inc/block-patterns.php';

#3 @ocean90
3 years ago

#53758 was marked as a duplicate.

#4 @SergeyBiryukov
3 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 51482:

Twenty Ten: Use correct path for loading block patterns.

By using get_template_directory() instead of get_stylesheet_directory(), we make sure to include the block-patterns.php file from the parent theme.

This avoids a PHP fatal error when using a child theme of Twenty Ten.

Follow-up to [51106].

Props ryelle, sabernhardt, loranrendel.
Fixes #53752.

#5 @SergeyBiryukov
3 years ago

  • Keywords fixed-major added
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening for backporting to the 5.8 branch.

This ticket was mentioned in Slack in #core-themes by peterwilsoncc. View the logs.


3 years ago

#7 @peterwilsoncc
3 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 51487:

Twenty Ten: Use correct path for loading block patterns.

By using get_template_directory() instead of get_stylesheet_directory(), we make sure to include the block-patterns.php file from the parent theme.

This avoids a PHP fatal error when using a child theme of Twenty Ten.

Follow-up to [51106].

Props ryelle, sabernhardt, loranrendel, SergeyBiryukov.
Merges [51482] to the 5.8 branch.
Fixes #53752.

#8 @aristath
3 years ago

Why don't we use get_theme_file_path() for things like this? It will get the path from a child theme or parent theme correctly every time.

Note: See TracTickets for help on using tickets.