Make WordPress Core

Opened 5 weeks ago

Last modified 4 weeks ago

#65580 new defect (bug)

Incorrect template part slugs when the theme folder name ends with parts

Reported by: yashjawale Owned by:
Priority: normal Milestone: Awaiting Review
Component: Themes Version: trunk
Severity: normal Keywords: has-patch
Cc: Focuses: template, rest-api

Description

The _get_block_templates_files generates template name slugs that include directory names when the theme name ends with parts. As a result, it causes REST API requests to fail and prevents saving the changes.

Reproduction instructions

  1. Create a child theme using WP-CLI
wp scaffold child-theme auto-parts --parent_theme=twentytwentytwo --theme_name="Auto Parts"
  1. Copy the parts directory from the parent theme.
cp -r wp-content/themes/twentytwentytwo/parts wp-content/themes/auto-parts/parts
  1. Go to the Site Editor -> Template Parts
  2. Confirm that template part slugs contain the directory name.

Both the parts with parts/ prefix & without them, fail to save changes in block editor.

Tested with current version of trunk & also present in 7.0.

https://files.catbox.moe/u0t0oe.png


Originally reported at Gutenberg repository in #42679 by @mamaduka

Change History (4)

This ticket was mentioned in PR #12399 on WordPress/wordpress-develop by @yashjawale.


5 weeks ago
#1

  • Keywords has-patch added

Trac ticket: https://core.trac.wordpress.org/ticket/65580

## Use of AI Tools

AI assistance: Yes
Tool(s): OpenCode
Model(s): DeepSeek V4 Flash
Used for: Checking initial implementation, followed by manual testing & verification

This ticket was mentioned in PR #12399 on WordPress/wordpress-develop by @yashjawale.


5 weeks ago
#2

Trac ticket: https://core.trac.wordpress.org/ticket/65580

## Use of AI Tools

AI assistance: Yes
Tool(s): OpenCode
Model(s): DeepSeek V4 Flash
Used for: Checking initial implementation, followed by manual testing & verification

#3 @yashjawale
5 weeks ago

The small change is to use strrpos instead of strpos for determing index for substring.
So we start looking for parts from the end instead.

From my testing the change appears to work correctly, showing correct number & details of template parts & allowing edits in block editor.

https://files.catbox.moe/s2mnbj.png

This ticket was mentioned in Slack in #core by cbravobernal. View the logs.


4 weeks ago

Note: See TracTickets for help on using tickets.