WordPress.org

Make WordPress Core

Opened 4 months ago

Closed 4 months ago

Last modified 4 months ago

#53752 closed defect (bug) (fixed)

Twenty Ten: Block patterns file causes error in child themes

Reported by: ryelle Owned by: 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 4 months ago.

Download all attachments as: .zip

Change History (9)

@sabernhardt
4 months ago

#1 @sabernhardt
4 months ago

  • Keywords has-patch added

The changeset was [51106]

#2 @sabernhardt
4 months ago

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

#3 @ocean90
4 months ago

#53758 was marked as a duplicate.

#4 @SergeyBiryukov
4 months 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
4 months 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.


4 months ago

#7 @peterwilsoncc
4 months 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
4 months 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.