PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.5.4
JetFormBuilder — Dynamic Blocks Form Builder v3.5.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 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / modules / captcha / admin-tabs / captcha-handler.php
jetformbuilder / modules / captcha / admin-tabs Last commit date
captcha-handler.php 2 years ago
captcha-handler.php
84 lines
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