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

Commit

Permalink
Check that functions gutenberg_supports_block_templates and gutenberg…
Browse files Browse the repository at this point in the history
…_get_block_template exist before usages (#5183)
  • Loading branch information
tjcafferkey authored Nov 19, 2021
1 parent d1d9cb8 commit 3b006db
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/BlockTemplatesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ protected function init() {
* @return mixed|\WP_Block_Template|\WP_Error
*/
public function maybe_return_blocks_template( $template, $id, $template_type ) {
if ( ! function_exists( 'gutenberg_get_block_template' ) ) {
return $template;
}
$template_name_parts = explode( '//', $id );
if ( count( $template_name_parts ) < 2 ) {
return $template;
Expand Down Expand Up @@ -132,7 +135,7 @@ public function get_single_block_template( $template, $id, $template_type ) {
* @return array
*/
public function add_block_templates( $query_result, $query, $template_type ) {
if ( ! gutenberg_supports_block_templates() || 'wp_template' !== $template_type ) {
if ( ! function_exists( 'gutenberg_supports_block_templates' ) || ! gutenberg_supports_block_templates() || 'wp_template' !== $template_type ) {
return $query_result;
}

Expand Down

0 comments on commit 3b006db

Please sign in to comment.