api
1 year ago
assets
1 year ago
rest-api
1 year ago
get-response-action.php
1 year ago
get-response-tab-handler.php
1 year ago
get-response.php
1 year ago
get-response.php
75 lines
| 1 | <?php |
| 2 | |
| 3 | namespace JFB_Modules\Actions_V2\Get_Response; |
| 4 | |
| 5 | use Jet_Form_Builder\Actions\Manager; |
| 6 | use Jet_Form_Builder\Admin\Tabs_Handlers\Base_Handler; |
| 7 | use Jet_Form_Builder\Admin\Tabs_Handlers\Tab_Handler_Manager; |
| 8 | use JFB_Modules\Actions_V2\Get_Response\Rest_Api\Get_Response\Get_Response_Route; |
| 9 | use JFB_Modules\Actions_V2\Interfaces\Action_Integration_Interface; |
| 10 | use JFB_Modules\Actions_V2\Traits\Action_Integration_Trait; |
| 11 | |
| 12 | final class Get_Response implements Action_Integration_Interface { |
| 13 | |
| 14 | use Action_Integration_Trait; |
| 15 | |
| 16 | public function rep_item_id() { |
| 17 | return 'get-response'; |
| 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_action( |
| 26 | 'rest_api_init', |
| 27 | array( $this, 'rest_api_init' ) |
| 28 | ); |
| 29 | } |
| 30 | |
| 31 | public function on_install() { |
| 32 | // install tab handler for Settings page |
| 33 | Tab_Handler_Manager::instance()->install( new Get_Response_Tab_Handler() ); |
| 34 | } |
| 35 | |
| 36 | public function register_actions( Manager $manager ) { |
| 37 | $manager->register_action_type( new Get_Response_Action() ); |
| 38 | } |
| 39 | |
| 40 | public function editor_assets() { |
| 41 | $script_asset = require_once $this->get_dir( 'assets/build/editor.asset.php' ); |
| 42 | |
| 43 | array_push( |
| 44 | $script_asset['dependencies'], |
| 45 | 'jet-fb-components', |
| 46 | 'jet-fb-data', |
| 47 | 'jet-fb-actions-v2', |
| 48 | 'jet-fb-blocks-v2-to-actions-v2' |
| 49 | ); |
| 50 | |
| 51 | wp_enqueue_script( |
| 52 | $this->get_handle(), |
| 53 | $this->get_url( 'assets/build/editor.js' ), |
| 54 | $script_asset['dependencies'], |
| 55 | $script_asset['version'], |
| 56 | true |
| 57 | ); |
| 58 | } |
| 59 | |
| 60 | public function rest_api_init() { |
| 61 | $route = new Get_Response_Route(); |
| 62 | $route->register(); |
| 63 | |
| 64 | register_setting( |
| 65 | trim( Base_Handler::PREFIX, '_' ), |
| 66 | Base_Handler::PREFIX . 'get-response-tab', |
| 67 | array( |
| 68 | 'type' => 'string', |
| 69 | 'show_in_rest' => true, |
| 70 | 'default' => '{}', |
| 71 | ) |
| 72 | ); |
| 73 | } |
| 74 | } |
| 75 |