actions-integration
1 year ago
interfaces
2 years ago
repeater-field
1 year ago
text-field
1 year ago
traits
2 years ago
module.php
1 year ago
module.php
75 lines
| 1 | <?php |
| 2 | |
| 3 | namespace JFB_Modules\Blocks_V2; |
| 4 | |
| 5 | use JFB_Components\Module\Base_Module_After_Install_It; |
| 6 | use JFB_Components\Module\Base_Module_Dir_It; |
| 7 | use JFB_Components\Module\Base_Module_Dir_Trait; |
| 8 | use JFB_Components\Module\Base_Module_Handle_It; |
| 9 | use JFB_Components\Module\Base_Module_Handle_Trait; |
| 10 | use JFB_Components\Module\Base_Module_It; |
| 11 | use JFB_Components\Module\Base_Module_Url_It; |
| 12 | use JFB_Components\Module\Base_Module_Url_Trait; |
| 13 | |
| 14 | final class Module implements |
| 15 | Base_Module_It, |
| 16 | Base_Module_Handle_It, |
| 17 | Base_Module_Url_It, |
| 18 | Base_Module_Dir_It, |
| 19 | Base_Module_After_Install_It { |
| 20 | |
| 21 | use Base_Module_Url_Trait; |
| 22 | use Base_Module_Handle_Trait; |
| 23 | use Base_Module_Dir_Trait; |
| 24 | |
| 25 | /** |
| 26 | * @var Actions_Integration\Actions_Integration |
| 27 | */ |
| 28 | private $action_integration; |
| 29 | |
| 30 | public function rep_item_id() { |
| 31 | return 'blocks-v2'; |
| 32 | } |
| 33 | |
| 34 | public function condition(): bool { |
| 35 | return true; |
| 36 | } |
| 37 | |
| 38 | public function on_install() { |
| 39 | $this->action_integration = new Actions_Integration\Actions_Integration(); |
| 40 | } |
| 41 | |
| 42 | public function on_uninstall() { |
| 43 | unset( $this->action_integration ); |
| 44 | } |
| 45 | |
| 46 | public function init_hooks() { |
| 47 | add_filter( 'jet-form-builder/blocks/items', array( $this, 'add_blocks_types' ) ); |
| 48 | |
| 49 | $this->action_integration->init_hooks(); |
| 50 | } |
| 51 | |
| 52 | public function remove_hooks() { |
| 53 | remove_filter( 'jet-form-builder/blocks/items', array( $this, 'add_blocks_types' ) ); |
| 54 | } |
| 55 | |
| 56 | public function add_blocks_types( array $block_types ): array { |
| 57 | array_push( |
| 58 | $block_types, |
| 59 | new Text_Field\Block_Type(), |
| 60 | new Repeater_Field\Block_Type_Row(), |
| 61 | new Repeater_Field\Block_Type() |
| 62 | ); |
| 63 | |
| 64 | return $block_types; |
| 65 | } |
| 66 | |
| 67 | public function get_action_integration() { |
| 68 | return $this->action_integration; |
| 69 | } |
| 70 | |
| 71 | public function set_action_integration( $action_integration ) { |
| 72 | $this->action_integration = $action_integration; |
| 73 | } |
| 74 | } |
| 75 |