Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Mini Cart Contents: Fix missing custom background #5448

Merged
merged 4 commits into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/BlockTypes/MiniCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,12 @@ protected function get_markup( $attributes ) {
}

$template_part_contents = '';
if ( function_exists( 'gutenberg_get_block_template' ) ) {
$template_part = gutenberg_get_block_template( get_stylesheet() . '//mini-cart', 'wp_template_part' );
if ( $template_part && ! empty( $template_part->content ) ) {
$template_part_contents = do_blocks( $template_part->content );
}
$template_part = BlockTemplateUtils::fse_get_block_template( get_stylesheet() . '//mini-cart', 'wp_template_part' );

if ( $template_part && ! empty( $template_part->content ) ) {
$template_part_contents = do_blocks( $template_part->content );
}

if ( '' === $template_part_contents ) {
$template_part_contents = do_blocks(
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
Expand Down
22 changes: 22 additions & 0 deletions src/Utils/BlockTemplateUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,28 @@ public static function supports_block_templates() {
return true;
}

/**
* Retrieves a single unified template object using its id.
*
* @param string $id Template unique identifier (example: theme_slug//template_slug).
* @param string $template_type Optional. Template type: `'wp_template'` or '`wp_template_part'`.
* Default `'wp_template'`.
*
* @return WP_Block_Template|null Template.
*/
public static function fse_get_block_template( $id, $template_type ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about the fse prefix... 🤔 I would just call it get_block_template like in WP core or wc_get_block_template if we want to make it clear it's WC-specific.

Copy link
Contributor Author

@gigitux gigitux Dec 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it makes sense!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would call it get_block_template as well, we already have BlockTemplateUtils as the prefix.

if ( function_exists( 'get_block_template' ) ) {
return get_block_template( $id, $template_type );
}

if ( function_exists( 'gutenberg_get_block_template' ) ) {
return gutenberg_get_block_template( $id, $template_type );
}

return null;

}

/**
* Checks if we can fallback to the `archive-product` template for a given slug
*
Expand Down