Skip to content

Commit

Permalink
Issue #46 - support loading of translated template parts
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbingwide committed Dec 7, 2020
1 parent 6ee51be commit 7cdfc70
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions includes/template-part.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* @return string
*/
function fizzie_render_block_core_template_part( $attributes, $content, $block ) {

$content = null;
$template_part_file_path = null;
$postId = null;
Expand Down Expand Up @@ -75,11 +76,19 @@ function fizzie_load_template_part( $attributes ) {
$content = fizzie_load_template_part_by_postId( $postId );
}
if ( !$content && $slug && $theme ) {
$content = fizzie_load_template_part_for_theme( $theme, $slug );
//$content = fizzie_load_template_part_for_theme( $theme, $slug );
}
if ( !$content && $slug ) {
$template_part_file_path = get_stylesheet_directory() . '/block-template-parts/' . $slug . '.html';
$locale = get_locale();

if ( 'en_US' !== $locale) {
$template_part_file_path = get_stylesheet_directory() . "/languages/$locale/block-template-parts/" . $slug . '.html';
} else {
$template_part_file_path = get_stylesheet_directory() . '/block-template-parts/' . $slug . '.html';
}

$content = fizzie_load_template_part_file_by_slug( $slug, $template_part_file_path );
//echo $content;
}

// What's the best way of telling the user that something's gone wrong?
Expand Down

0 comments on commit 7cdfc70

Please sign in to comment.