assets
1 year ago
messages
1 year ago
register-user-action.php
1 year ago
register-user.php
1 year ago
register-user.php
77 lines
| 1 | <?php |
| 2 | |
| 3 | namespace JFB_Modules\Actions_V2\Register_User; |
| 4 | |
| 5 | use Jet_Form_Builder\Actions\Manager; |
| 6 | use Jet_Form_Builder\Classes\Tools; |
| 7 | use JFB_Modules\Actions_V2\Interfaces\Action_Integration_Interface; |
| 8 | use JFB_Modules\Actions_V2\Register_User\Messages\Register_User_Messages; |
| 9 | use JFB_Modules\Actions_V2\Register_User\Messages\User_Specific_Messages; |
| 10 | use JFB_Modules\Actions_V2\Traits\Action_Integration_Trait; |
| 11 | |
| 12 | final class Register_User implements Action_Integration_Interface { |
| 13 | |
| 14 | use Action_Integration_Trait; |
| 15 | |
| 16 | public function rep_item_id() { |
| 17 | return 'register-user'; |
| 18 | } |
| 19 | |
| 20 | public function init_hooks() { |
| 21 | add_action( |
| 22 | 'jet-form-builder/editor-assets/after', |
| 23 | array( $this, 'editor_assets' ) |
| 24 | ); |
| 25 | add_filter( |
| 26 | 'jet-form-builder/form-messages/register', |
| 27 | array( $this, 'register_message_types' ) |
| 28 | ); |
| 29 | } |
| 30 | |
| 31 | public function on_install() { |
| 32 | } |
| 33 | |
| 34 | public function register_actions( Manager $manager ) { |
| 35 | $manager->register_action_type( new Register_User_Action() ); |
| 36 | } |
| 37 | |
| 38 | public function register_message_types( array $types ): array { |
| 39 | array_push( |
| 40 | $types, |
| 41 | new User_Specific_Messages(), |
| 42 | new Register_User_Messages() |
| 43 | ); |
| 44 | |
| 45 | return $types; |
| 46 | } |
| 47 | |
| 48 | public function editor_assets() { |
| 49 | $script_asset = require_once $this->get_dir( 'assets/build/editor.asset.php' ); |
| 50 | |
| 51 | array_push( |
| 52 | $script_asset['dependencies'], |
| 53 | 'jet-fb-components', |
| 54 | 'jet-fb-data', |
| 55 | 'jet-fb-actions-v2', |
| 56 | 'jet-fb-blocks-v2-to-actions-v2' |
| 57 | ); |
| 58 | |
| 59 | wp_enqueue_script( |
| 60 | $this->get_handle(), |
| 61 | $this->get_url( 'assets/build/editor.js' ), |
| 62 | $script_asset['dependencies'], |
| 63 | $script_asset['version'], |
| 64 | true |
| 65 | ); |
| 66 | |
| 67 | wp_localize_script( |
| 68 | $this->get_handle(), |
| 69 | 'JetFBRegisterAction', |
| 70 | array( |
| 71 | 'userRoles' => Tools::get_user_roles_for_js(), |
| 72 | 'allUserRoles' => Tools::get_user_roles_for_js( array() ), |
| 73 | ) |
| 74 | ); |
| 75 | } |
| 76 | } |
| 77 |