From 225f09e52b5f24675990bb3f0a8df2772e93f6e8 Mon Sep 17 00:00:00 2001 From: Simon Mayerhofer Date: Mon, 28 Jun 2021 11:49:57 +0200 Subject: [PATCH] Fix #9 undefined acf function error --- inc/blocks/block-accordion.php | 36 ++++++++++++++++++---------------- inc/blocks/block-button.php | 36 ++++++++++++++++++---------------- 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/inc/blocks/block-accordion.php b/inc/blocks/block-accordion.php index a8c6679..12e17dd 100644 --- a/inc/blocks/block-accordion.php +++ b/inc/blocks/block-accordion.php @@ -13,23 +13,25 @@ public static function get_name(): string { } public static function register_block_type(): void { - acf_register_block_type( - [ - 'name' => self::get_name(), - 'title' => __( 'Accordion', 'foundationpress' ), - 'render_template' => 'template-parts/blocks/' . self::get_name() . '.php', - 'enqueue_style' => get_template_directory_uri() . '/dist/assets/css/blocks/' . self::get_name() . '.css', - 'enqueue_script' => get_template_directory_uri() . '/dist/assets/js/blocks/' . self::get_name() . '.js', - 'category' => 'foundationpress', - 'icon' => 'editor-help', - 'keywords' => [ self::get_name(), 'faq', 'akkordion' ], - 'supports' => [ - 'align' => false, - 'anchor' => true, - 'classNames' => true, - ], - ] - ); + if ( function_exists( 'acf_register_block_type' ) ) { + acf_register_block_type( + [ + 'name' => self::get_name(), + 'title' => __( 'Accordion', 'foundationpress' ), + 'render_template' => 'template-parts/blocks/' . self::get_name() . '.php', + 'enqueue_style' => get_template_directory_uri() . '/dist/assets/css/blocks/' . self::get_name() . '.css', + 'enqueue_script' => get_template_directory_uri() . '/dist/assets/js/blocks/' . self::get_name() . '.js', + 'category' => 'foundationpress', + 'icon' => 'editor-help', + 'keywords' => [ self::get_name(), 'faq', 'akkordion' ], + 'supports' => [ + 'align' => false, + 'anchor' => true, + 'classNames' => true, + ], + ] + ); + } } } diff --git a/inc/blocks/block-button.php b/inc/blocks/block-button.php index 3d38b53..faa68f9 100644 --- a/inc/blocks/block-button.php +++ b/inc/blocks/block-button.php @@ -13,23 +13,25 @@ public static function get_name(): string { } public static function register_block_type(): void { - acf_register_block_type( - [ - 'name' => self::get_name(), - 'title' => __( 'FP Button', 'foundationpress' ), - 'render_template' => 'template-parts/blocks/' . self::get_name() . '.php', - 'enqueue_style' => get_template_directory_uri() . '/dist/assets/css/blocks/' . self::get_name() . '.css', - // 'enqueue_script' => get_template_directory_uri() . '/dist/assets/js/blocks/' . self::get_name() . '.js', - 'category' => 'foundationpress', - 'icon' => 'shield-alt', - 'keywords' => [ self::get_name() ], - 'supports' => [ - 'align' => true, - 'anchor' => true, - 'classNames' => true, - ], - ] - ); + if ( function_exists( 'acf_register_block_type' ) ) { + acf_register_block_type( + [ + 'name' => self::get_name(), + 'title' => __( 'FP Button', 'foundationpress' ), + 'render_template' => 'template-parts/blocks/' . self::get_name() . '.php', + 'enqueue_style' => get_template_directory_uri() . '/dist/assets/css/blocks/' . self::get_name() . '.css', + // 'enqueue_script' => get_template_directory_uri() . '/dist/assets/js/blocks/' . self::get_name() . '.js', + 'category' => 'foundationpress', + 'icon' => 'shield-alt', + 'keywords' => [ self::get_name() ], + 'supports' => [ + 'align' => true, + 'anchor' => true, + 'classNames' => true, + ], + ] + ); + } } }