Skip to content

Commit

Permalink
Merge pull request #2528 from kprajapatii/master
Browse files Browse the repository at this point in the history
* Function _inject_theme_attribute_in_block_template_content is deprecated - FIXED
  • Loading branch information
kprajapatii authored Jan 31, 2024
2 parents e310934 + 82b2a15 commit 66cf7dd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
33 changes: 27 additions & 6 deletions includes/class-geodir-block-theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -952,11 +952,10 @@ public static function gutenberg_build_template_result_from_file( $template_file
$template_is_from_theme = 'theme' === $template_file->source;
$theme_name = wp_get_theme()->get( 'TextDomain' );

$template_content = file_get_contents( $template_file->path ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
$template = new \WP_Block_Template();
$template->id = $template_is_from_theme ? $theme_name . '//' . $template_file->slug : self::PLUGIN_SLUG . '//' . $template_file->slug;
$template->theme = $template_is_from_theme ? $theme_name : self::PLUGIN_SLUG;
$template->content = _inject_theme_attribute_in_block_template_content( $template_content );
$template = new \WP_Block_Template();
$template->id = $template_is_from_theme ? $theme_name . '//' . $template_file->slug : self::PLUGIN_SLUG . '//' . $template_file->slug;
$template->theme = $template_is_from_theme ? $theme_name : self::PLUGIN_SLUG;
$template->content = @file_get_contents( $template_file->path ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
$template->source = $template_file->source ? $template_file->source : 'plugin';
$template->slug = $template_file->slug;
$template->type = $template_type;
Expand All @@ -970,6 +969,20 @@ public static function gutenberg_build_template_result_from_file( $template_file
$template->area = 'uncategorized';
}

if ( function_exists( '_inject_theme_attribute_in_template_part_block' ) ) {
$before_block_visitor = '_inject_theme_attribute_in_template_part_block';
$after_block_visitor = null;
$hooked_blocks = get_hooked_blocks();
if ( ! empty( $hooked_blocks ) || has_filter( 'hooked_block_types' ) ) {
$before_block_visitor = make_before_block_visitor( $hooked_blocks, $template );
$after_block_visitor = make_after_block_visitor( $hooked_blocks, $template );
}
$blocks = parse_blocks( $template->content );
$template->content = traverse_and_serialize_blocks( $blocks, $before_block_visitor, $after_block_visitor );
} else if ( function_exists( '_inject_theme_attribute_in_block_template_content' ) ) {
$template->content = _inject_theme_attribute_in_block_template_content( $template->content );
}

return $template;
}

Expand Down Expand Up @@ -1255,7 +1268,15 @@ public static function get_default_wp_template_html( $page, $template_type = 'wp
$content = @file_get_contents( $template_path ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents

if ( $content ) {
$content = _inject_theme_attribute_in_block_template_content( $content );
if ( function_exists( '_inject_theme_attribute_in_template_part_block' ) ) {
$before_block_visitor = '_inject_theme_attribute_in_template_part_block';
$after_block_visitor = null;

$blocks = parse_blocks( $content );
$content = traverse_and_serialize_blocks( $blocks, $before_block_visitor, $after_block_visitor );
} else if ( function_exists( '_inject_theme_attribute_in_block_template_content' ) ) {
$content = _inject_theme_attribute_in_block_template_content( $content );
}
}
}

Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ __WARNING: GDv2 is a significant update over GDv1 and may require manual work, s
= GeoDirectory v2.3.38 - TBD =
* GD > Post Features shows fields label special chars encoded incorrectly - FIXED
* Category icon not generated from FontAweosme icons for some sites - FIXED
* Function _inject_theme_attribute_in_block_template_content is deprecated - FIXED

= GeoDirectory v2.3.37 - 2024-01-25 =
* OSM layer url shows apikey parameter twice for custom style map - FIXED
Expand Down

0 comments on commit 66cf7dd

Please sign in to comment.