Block.php
38 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCartBlocks\Blocks\Divider; |
| 4 | |
| 5 | /** |
| 6 | * Logout Button Block. |
| 7 | */ |
| 8 | class Block { |
| 9 | /** |
| 10 | * Optional directory to .json block data files. |
| 11 | * |
| 12 | * @var string |
| 13 | */ |
| 14 | protected $directory = ''; |
| 15 | |
| 16 | /** |
| 17 | * Register the block for dynamic output |
| 18 | * |
| 19 | * @return void |
| 20 | */ |
| 21 | public function register() { |
| 22 | register_block_type_from_metadata( |
| 23 | $this->getDir(), |
| 24 | ); |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Get the called class directory path |
| 29 | * |
| 30 | * @return string |
| 31 | */ |
| 32 | public function getDir() { |
| 33 | $reflector = new \ReflectionClass( $this ); |
| 34 | $fn = $reflector->getFileName(); |
| 35 | return dirname( $fn ); |
| 36 | } |
| 37 | } |
| 38 |