diff --git a/src/AbstractBlock.php b/src/AbstractBlock.php index a5661f2..f78fa72 100644 --- a/src/AbstractBlock.php +++ b/src/AbstractBlock.php @@ -49,14 +49,12 @@ public function renderBlockCallback(array $block): void ob_start(); // TODO: Check for remote file inclusion (WP VIP). - // phpcs:disable WordPressVIPMinimum.Files.IncludingFile.IncludingFile + // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.IncludingFile include apply_filters('acf_gutenblocks/render_block_html', $path, $controller); - // phpcs:enable $html = ob_get_clean(); - // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo apply_filters('acf_gutenblocks/render_block_html_output', $html, $controller); - // phpcs:enable } } diff --git a/src/Block.php b/src/Block.php index be181e2..acef40c 100644 --- a/src/Block.php +++ b/src/Block.php @@ -4,6 +4,8 @@ namespace Itineris\AcfGutenblocks; +use ReflectionClass; + class Block { /** @@ -101,12 +103,11 @@ class Block * Begin block construction! * * @since 0.10 - * @param array $settings The block definitions. */ public function __construct(array $settings) { // Path related definitions. - $reflection = new \ReflectionClass($this); + $reflection = new ReflectionClass($this); $block_path = $reflection->getFileName(); $directory_path = dirname($block_path); $this->name = Util::camelToKebab(basename($block_path, '.php')); @@ -287,11 +288,20 @@ public function getBlockData(): array ]; } + /** + * Callback method to enqueue block assets + * + * @since 0.6.0 + */ + public function enqueueAssets(): void + { + } public function init(): void { $block_data = $this->getBlockData(); $block_data['render_callback'] = [$this, 'renderBlockCallback']; + $block_data['enqueue_assets'] = $this->enqueueAssets(); $fields = $this->getFields(); acf_register_block($block_data); diff --git a/src/Util.php b/src/Util.php index bcbb1bd..f53c004 100644 --- a/src/Util.php +++ b/src/Util.php @@ -13,8 +13,9 @@ public static function camelToKebab(string $string): string public static function sanitizeHtmlClasses(array $classes): string { - return implode(' ', array_map(function ($class): string { - return sanitize_html_class((string) $class); - }, $classes)); + return implode( + ' ', + array_map(fn ($class): string => sanitize_html_class((string) $class), $classes), + ); } }