exceptions
1 year ago
interfaces
1 year ago
traits
1 year ago
block-editor-builder.php
1 year ago
builder-create-page.php
1 year ago
builder-update-page.php
1 year ago
no-builder-handler.php
1 year ago
no-builder-handler.php
33 lines
| 1 | <?php |
| 2 | |
| 3 | namespace JFB_Modules\Onboarding\Builders; |
| 4 | |
| 5 | use JFB_Modules\Onboarding\Builders\Exceptions\Use_Form_Exception; |
| 6 | use JFB_Modules\Onboarding\Builders\Interfaces\Builder_Interface; |
| 7 | |
| 8 | class No_Builder_Handler { |
| 9 | |
| 10 | public function init_hooks() { |
| 11 | add_action( 'jet-form-builder/use-form', array( $this, 'check_redirect' ), 999 ); |
| 12 | } |
| 13 | |
| 14 | /** |
| 15 | * Check if some builders used the form correctly |
| 16 | * |
| 17 | * @param Builder_Interface $builder |
| 18 | * |
| 19 | * @return void |
| 20 | * @throws Use_Form_Exception |
| 21 | */ |
| 22 | public function check_redirect( Builder_Interface $builder ) { |
| 23 | if ( $builder->get_redirect_url() ) { |
| 24 | return; |
| 25 | } |
| 26 | |
| 27 | throw new Use_Form_Exception( |
| 28 | esc_html__( 'Something went wrong, check if you chose a builder.', 'jet-form-builder' ) |
| 29 | ); |
| 30 | } |
| 31 | |
| 32 | } |
| 33 |