for-blocks-sanitizer-trait.php
32 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace JFB_Modules\Block_Sanitizer\Traits; |
| 5 | |
| 6 | use Jet_Form_Builder\Blocks\Block_Helper; |
| 7 | |
| 8 | // If this file is called directly, abort. |
| 9 | if ( ! defined( 'WPINC' ) ) { |
| 10 | die; |
| 11 | } |
| 12 | |
| 13 | /** |
| 14 | * @method bool for_blocks |
| 15 | * |
| 16 | * Trait For_Blocks_Sanitizer_Trait |
| 17 | * @package JFB_Modules\Block_Sanitizer\Traits |
| 18 | */ |
| 19 | trait For_Blocks_Sanitizer_Trait { |
| 20 | |
| 21 | public function is_supported( array $parsed_block ): bool { |
| 22 | try { |
| 23 | $name = Block_Helper::resolve_name( $parsed_block ); |
| 24 | } catch ( \Exception $exception ) { |
| 25 | return false; |
| 26 | } |
| 27 | |
| 28 | return in_array( $name, $this->for_blocks(), true ); |
| 29 | } |
| 30 | |
| 31 | } |
| 32 |