This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Move Woo Blocks template directories to latest Gutenberg convention #5464
Merged
sunyatasattva
merged 7 commits into
trunk
from
fix/5343-change-block-templates-directories
Jan 5, 2022
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e7beb86
Align Woo Block template locations with the newest convention
sunyatasattva 2fae89f
Simplify `generate_template_slug_from_path` function
sunyatasattva 2f4749d
Remove old templates
sunyatasattva 8db7484
Change `BlockTemplatesController` constructor to get correct dir names
sunyatasattva 258553f
Update Mini Cart template path
sunyatasattva 82965b7
Switch parent and child theme order
sunyatasattva d5743b4
Fix path in function comment
sunyatasattva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -254,15 +254,12 @@ public static function convert_slug_to_title( $template_slug ) { | |
* Converts template paths into a slug | ||
* | ||
* @param string $path The template's path. | ||
* @param string $directory_name The template's directory name. | ||
* @return string slug | ||
*/ | ||
public static function generate_template_slug_from_path( $path, $directory_name = 'block-templates' ) { | ||
return substr( | ||
$path, | ||
strpos( $path, $directory_name . DIRECTORY_SEPARATOR ) + 1 + strlen( $directory_name ), | ||
-5 | ||
); | ||
public static function generate_template_slug_from_path( $path ) { | ||
$template_extension = '.html'; | ||
|
||
return basename( $path, $template_extension ); | ||
Comment on lines
+259
to
+262
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Much better. 👏 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! It was also necessary, by the way. I didn't simplify it just for the sake of it. But because our dir structure became |
||
} | ||
|
||
/** | ||
|
@@ -298,8 +295,8 @@ public static function get_theme_template_path( $template_slug, $template_type = | |
function( $carry, $item ) use ( $template_filename ) { | ||
$filepath = DIRECTORY_SEPARATOR . $item . DIRECTORY_SEPARATOR . $template_filename; | ||
|
||
$carry[] = get_template_directory() . $filepath; | ||
$carry[] = get_stylesheet_directory() . $filepath; | ||
$carry[] = get_template_directory() . $filepath; | ||
|
||
return $carry; | ||
}, | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not replace
self::TEMPLATES_ROOT_DIR
withBlockTemplateUtils::DIRECTORY_NAMES['TEMPLATES']
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, we can because they have the same value. However, the reason why I added
TEMPLATES_ROOT_DIR
in the first place is because they represent two different things:BlockTemplateUtils::DIRECTORY_NAMES['TEMPLATES']
represents theblock-templates
directory name in themes.BlockTemplatesController::TEMPLATES_ROOT_DIR
represents the root directory of all templates in our own repo. For example, we have email templates.The just happen to be both named
templates
now, so we have the awkward pathtemplates/templates
(which makes me sad :'(). But technically they are separate entities that could also be changed independently at any point.Does that make any sense?