setup_hooks(); } protected function setup_hooks(){ /** * Action And Filter */ add_action('init', [$this, 'atlantisak_register_block_patterns']); add_action('init', [$this, 'atlantisak_register_block_pattern_categories']); } public function atlantisak_register_block_patterns(){ if(function_exists('register_block_pattern')){ /** * * Cover Pattern * */ $cover_content = $this->atlantisak_get_pattern_content('template-parts/patterns/cover'); // phpcs:ignore WPThemeReview.PluginTerritory.ForbiddenFunctions.editor_blocks_register_block_pattern register_block_pattern( 'atlantisak/cover', [ 'title' => __('Cover', 'atlantisak'), 'description' => __('AtlantisAK Cover Block with image and text', 'atlantisak'), 'categories' => ['cover'], 'content' => $cover_content, ] ); } } public function atlantisak_get_pattern_content($template_path){ ob_start(); get_template_part($template_path); $pattern_content = ob_get_contents(); ob_end_clean(); return $pattern_content; } public function atlantisak_register_block_pattern_categories(){ $pattern_categories = [ 'cover' => __('AtlantisAK Cover', 'atlantisak'), 'carousel' => __('AtlantisAK Carousel', 'atlantisak'), ]; if(! empty($pattern_categories) && is_array($pattern_categories)){ foreach($pattern_categories as $pattern_category => $pattern_category_label){ // phpcs:ignore WPThemeReview.PluginTerritory.ForbiddenFunctions.editor_blocks_register_block_pattern_category register_block_pattern_category( $pattern_category, ['label' => $pattern_category_label] ); } } } }