assets
6 days ago
call-hook
1 month ago
call-webhook
1 month ago
get-response
1 month ago
insert-post
6 days ago
insert-term
1 month ago
interfaces
1 year ago
mailchimp
1 month ago
redirect-to-page
1 month ago
register-user
1 month ago
send-email
1 month ago
traits
1 year ago
update-user
2 weeks ago
.eslintrc.js
1 year ago
module.php
1 year ago
module.php
133 lines
| 1 | <?php |
| 2 | |
| 3 | namespace JFB_Modules\Actions_V2; |
| 4 | |
| 5 | use Jet_Form_Builder\Actions\Manager; |
| 6 | use JFB_Components\Module\Base_Module_After_Install_It; |
| 7 | use JFB_Components\Module\Base_Module_Dir_It; |
| 8 | use JFB_Components\Module\Base_Module_Dir_Trait; |
| 9 | use JFB_Components\Module\Base_Module_Handle_It; |
| 10 | use JFB_Components\Module\Base_Module_Handle_Trait; |
| 11 | use JFB_Components\Module\Base_Module_It; |
| 12 | use JFB_Components\Module\Base_Module_Url_It; |
| 13 | use JFB_Components\Module\Base_Module_Url_Trait; |
| 14 | use JFB_Components\Repository\Interfaces\Repository_Pattern_Interface; |
| 15 | use JFB_Components\Repository\Repository_Pattern_Trait; |
| 16 | use JFB_Modules\Actions_V2\Interfaces\Action_Integration_Interface; |
| 17 | |
| 18 | final class Module implements |
| 19 | Base_Module_It, |
| 20 | Base_Module_Handle_It, |
| 21 | Base_Module_Url_It, |
| 22 | Base_Module_Dir_It, |
| 23 | Base_Module_After_Install_It, |
| 24 | Repository_Pattern_Interface { |
| 25 | |
| 26 | use Base_Module_Url_Trait; |
| 27 | use Base_Module_Handle_Trait; |
| 28 | use Base_Module_Dir_Trait; |
| 29 | use Repository_Pattern_Trait; |
| 30 | |
| 31 | public function rep_item_id() { |
| 32 | return 'actions-v2'; |
| 33 | } |
| 34 | |
| 35 | public function rep_instances(): array { |
| 36 | return array( |
| 37 | new Send_Email\Send_Email(), |
| 38 | new Insert_Post\Insert_Post(), |
| 39 | new Insert_Term\Insert_Term(), |
| 40 | new Register_User\Register_User(), |
| 41 | new Update_User\Update_User(), |
| 42 | new Redirect_To_Page\Redirect_To_Page(), |
| 43 | new Call_Hook\Call_Hook(), |
| 44 | new Call_Webhook\Call_Webhook(), |
| 45 | new Mailchimp\Mailchimp(), |
| 46 | new Get_Response\Get_Response(), |
| 47 | ); |
| 48 | } |
| 49 | |
| 50 | public function on_install() { |
| 51 | $this->rep_install(); |
| 52 | |
| 53 | /** @var Action_Integration_Interface $integration_item */ |
| 54 | foreach ( $this->rep_generate_items() as $integration_item ) { |
| 55 | $integration_item->on_install(); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | public function on_uninstall() { |
| 60 | $this->rep_clear(); |
| 61 | } |
| 62 | |
| 63 | public function condition(): bool { |
| 64 | return true; |
| 65 | } |
| 66 | |
| 67 | public function init_hooks() { |
| 68 | add_action( 'jet-form-builder/actions/register', array( $this, 'register_actions' ) ); |
| 69 | |
| 70 | add_action( |
| 71 | 'enqueue_block_editor_assets', |
| 72 | array( $this, 'register_assets' ), |
| 73 | -9 |
| 74 | ); |
| 75 | add_action( |
| 76 | 'wp_enqueue_scripts', |
| 77 | array( $this, 'register_assets' ), |
| 78 | -9 |
| 79 | ); |
| 80 | |
| 81 | /** @var Action_Integration_Interface $integration_item */ |
| 82 | foreach ( $this->rep_generate_items() as $integration_item ) { |
| 83 | $integration_item->init_hooks(); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | |
| 88 | public function remove_hooks() { |
| 89 | remove_action( 'jet-form-builder/actions/register', array( $this, 'register_actions' ) ); |
| 90 | |
| 91 | remove_action( |
| 92 | 'enqueue_block_editor_assets', |
| 93 | array( $this, 'register_assets' ), |
| 94 | -9 |
| 95 | ); |
| 96 | remove_action( |
| 97 | 'wp_enqueue_scripts', |
| 98 | array( $this, 'register_assets' ), |
| 99 | -9 |
| 100 | ); |
| 101 | } |
| 102 | |
| 103 | |
| 104 | public function register_actions( Manager $manager ) { |
| 105 | /** @var Action_Integration_Interface $integration_item */ |
| 106 | foreach ( $this->rep_generate_items() as $integration_item ) { |
| 107 | $integration_item->register_actions( $manager ); |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | public function register_assets() { |
| 112 | $script_asset = require_once $this->get_dir( 'assets/build/editor.asset.php' ); |
| 113 | |
| 114 | if ( true === $script_asset ) { |
| 115 | return; |
| 116 | } |
| 117 | |
| 118 | array_push( |
| 119 | $script_asset['dependencies'], |
| 120 | 'jet-fb-components', |
| 121 | 'jet-fb-data' |
| 122 | ); |
| 123 | |
| 124 | wp_register_script( |
| 125 | $this->get_handle(), |
| 126 | $this->get_url( 'assets/build/editor.js' ), |
| 127 | $script_asset['dependencies'], |
| 128 | $script_asset['version'], |
| 129 | true |
| 130 | ); |
| 131 | } |
| 132 | } |
| 133 |