PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.6
JetFormBuilder — Dynamic Blocks Form Builder v3.6.6
3.6.6.1 3.6.6 3.6.5.4 3.6.5.3 3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 All 134 releases
jetformbuilder / modules / captcha / admin-tabs / captcha-handler.php

captcha-handler.php in JetFormBuilder — Dynamic Blocks Form Builder 3.6.6, at modules/captcha/admin-tabs/captcha-handler.php

84 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 namespace JFB_Modules\Captcha\Admin_Tabs;
5
6 use Jet_Form_Builder\Admin\Tabs_Handlers\Base_Handler;
7 use Jet_Form_Builder\Exceptions\Repository_Exception;
8 use JFB_Modules\Captcha\Abstract_Captcha\Base_Captcha;
9 use JFB_Modules\Captcha\Abstract_Captcha\Captcha_Settings_From_Options;
10 use JFB_Modules\Captcha\Module;
11
12 // If this file is called directly, abort.
13 if ( ! defined( 'WPINC' ) ) {
14 die;
15 }
16
17 class Captcha_Handler extends Base_Handler {
18
19 public function slug() {
20 return 'captcha-tab';
21 }
22
23 /**
24 * @throws Repository_Exception
25 */
26 public function on_get_request() {
27 $options = array();
28
29 /** @var Module $module */
30 $module = jet_form_builder()->module( 'captcha' );
31
32 /** @var Base_Captcha $captcha */
33 foreach ( $module->rep_generate_items() as $captcha ) {
34 if ( ! ( $captcha instanceof Captcha_Settings_From_Options ) ) {
35 continue;
36 }
37 $slug = $captcha->get_id();
38
39 // phpcs:disable WordPress.Security.NonceVerification.Missing
40 if ( ! array_key_exists( $slug, $_POST ) ) {
41 $options[ $slug ] = $captcha->on_load_options();
42 continue;
43 }
44
45 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
46 $options[ $slug ] = $captcha->on_save_options( wp_unslash( $_POST[ $slug ] ) );
47 // phpcs:enable WordPress.Security.NonceVerification.Missing
48 }
49
50 $result = $this->update_options( $options );
51
52 $this->send_response( $result );
53 }
54
55 public function on_load() {
56 return $this->get_captcha_options();
57 }
58
59 public function on_editor_load(): array {
60 return $this->get_captcha_options();
61 }
62
63 /**
64 * @return array
65 * @throws Repository_Exception
66 */
67 protected function get_captcha_options(): array {
68 $options = array();
69
70 /** @var Module $module */
71 $module = jet_form_builder()->module( 'captcha' );
72
73 /** @var Base_Captcha $captcha */
74 foreach ( $module->rep_generate_items() as $captcha ) {
75 if ( ! ( $captcha instanceof Captcha_Settings_From_Options ) ) {
76 continue;
77 }
78 $options[ $captcha->get_id() ] = $captcha->on_load_options();
79 }
80
81 return $options;
82 }
83 }
84