PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.2.3
JetFormBuilder — Dynamic Blocks Form Builder v3.2.3
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 / includes / admin / tabs-handlers / base-handler.php
jetformbuilder / includes / admin / tabs-handlers Last commit date
base-handler.php 2 years ago get-response-handler.php 2 years ago mailchimp-handler.php 2 years ago options-handler.php 2 years ago tab-handler-manager.php 2 years ago
base-handler.php
121 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Admin\Tabs_Handlers;
5
6 // If this file is called directly, abort.
7 use JFB_Components\Repository\Repository_Item_Instance_Trait;
8
9 if ( ! defined( 'WPINC' ) ) {
10 die;
11 }
12
13 abstract class Base_Handler implements Repository_Item_Instance_Trait {
14
15 const PREFIX = 'jet_form_builder_settings__';
16
17 abstract public function slug();
18
19 abstract public function on_get_request();
20
21 abstract public function on_load();
22
23 public function after_install() {
24 add_action( "wp_ajax_jet_fb_save_tab__{$this->slug()}", array( $this, 'on_raw_request' ) );
25 add_action( 'jet-fb/admin-pages/before-assets/jfb-settings', array( $this, 'before_assets' ) );
26 }
27
28 public function on_raw_request() {
29 if (
30 empty( $_POST['_nonce'] ) ||
31 ! wp_verify_nonce( sanitize_key( $_POST['_nonce'] ?? '' ), 'jfb-settings' ) ||
32 ! current_user_can( 'manage_options' )
33 ) {
34 $this->send_response( false );
35
36 return;
37 }
38
39 $this->on_get_request();
40 }
41
42 /**
43 * @since 3.1.0
44 *
45 * @return array
46 */
47 public function on_editor_load(): array {
48 return $this->get_options();
49 }
50
51 /**
52 * Define this, if you want to save options
53 * in Tab_Handler_Manager::$_tabs_options.
54 *
55 * Then you can get this data via
56 * $this->get_global_options()
57 *
58 * @return array
59 */
60 public function save_global_default() {
61 return array();
62 }
63
64 public function is_visible( $advanced_options ) {
65 return true;
66 }
67
68 public function get_options( $if_empty = array() ) {
69 $response = get_option( $this->option_name(), false );
70
71 $response = $response
72 ? json_decode( $response, true )
73 : array();
74
75 return array_merge( $if_empty, $response );
76 }
77
78 public function update_options( $options ) {
79 $options = wp_json_encode( $options );
80 $prev_value = get_option( $this->option_name(), false );
81
82 if ( $prev_value === $options ) {
83 return true;
84 }
85
86 return update_option( $this->option_name(), $options );
87 }
88
89 public function before_assets() {
90 }
91
92 public function option_name() {
93 return self::PREFIX . $this->slug();
94 }
95
96 public function get_success_response_data() {
97 return array(
98 'message' => __( 'Saved successfully!', 'jet-form-builder' ),
99 );
100 }
101
102 public function get_failed_response_data() {
103 return array(
104 'message' => __( 'Unsuccessful save.', 'jet-form-builder' ),
105 );
106 }
107
108 public function send_response( $result ) {
109 if ( $result ) {
110 wp_send_json_success( $this->get_success_response_data() );
111 }
112
113 wp_send_json_error( $this->get_failed_response_data() );
114 }
115
116 public function rep_item_id() {
117 return $this->slug();
118 }
119
120 }
121