PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.1
JetFormBuilder — Dynamic Blocks Form Builder v3.6.1
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 / admin / module.php
jetformbuilder / modules / admin Last commit date
assets 1 month ago module.php 1 year ago
module.php
249 lines
1 <?php
2
3
4 namespace JFB_Modules\Admin;
5
6 // If this file is called directly, abort.
7 if ( ! defined( 'WPINC' ) ) {
8 die;
9 }
10
11 use Jet_Form_Builder\Admin\Exceptions\Not_Found_Page_Exception;
12 use Jet_Form_Builder\Admin\Pages\Pages_Manager;
13 use Jet_Form_Builder\Admin\Tabs_Handlers\Options_Handler;
14 use Jet_Form_Builder\Admin\Tabs_Handlers\Tab_Handler_Manager;
15 use Jet_Form_Builder\Classes\Http\Utm_Url;
16 use Jet_Form_Builder\Classes\Tools;
17 use JFB_Components\Module\Base_Module_Dir_It;
18 use JFB_Components\Module\Base_Module_Dir_Trait;
19 use JFB_Components\Module\Base_Module_Handle_It;
20 use JFB_Components\Module\Base_Module_Handle_Trait;
21 use JFB_Components\Module\Base_Module_It;
22 use JFB_Components\Module\Base_Module_Url_It;
23 use JFB_Components\Module\Base_Module_Url_Trait;
24 use JFB_Modules\Post_Type;
25
26 class Module implements
27 Base_Module_It,
28 Base_Module_Url_It,
29 Base_Module_Handle_It,
30 Base_Module_Dir_It {
31
32 use Base_Module_Handle_Trait;
33 use Base_Module_Url_Trait;
34 use Base_Module_Dir_Trait;
35
36 public function rep_item_id() {
37 return 'admin';
38 }
39
40 public function condition(): bool {
41 return true;
42 }
43
44 public function init_hooks() {
45 add_action( 'admin_footer', array( $this, 'add_modal_on_deactivate' ) );
46 add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
47
48 add_filter(
49 'plugin_action_links_' . JET_FORM_BUILDER_PLUGIN_BASE,
50 array( $this, 'modify_plugin_action_links' )
51 );
52 }
53
54 public function remove_hooks() {
55 remove_action( 'admin_footer', array( $this, 'add_modal_on_deactivate' ) );
56 remove_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
57
58 remove_filter(
59 'plugin_action_links_' . JET_FORM_BUILDER_PLUGIN_BASE,
60 array( $this, 'modify_plugin_action_links' )
61 );
62 }
63
64 /**
65 * Called by `register_activation_hook`
66 * inside `jetformbuilder/load.php`
67 *
68 * @return void
69 */
70 public function on_plugin_activate() {
71 /** @var Options_Handler $options */
72 $options_tab = Tab_Handler_Manager::instance()->tab( 'options-tab' );
73
74 $options = $options_tab->get_options();
75 $new_options = array();
76
77 if ( ! isset( $options['disable_next_button'] ) ) {
78 $new_options['disable_next_button'] = false;
79 }
80 if ( ! isset( $options['scroll_on_next'] ) ) {
81 $new_options['scroll_on_next'] = true;
82 }
83 if ( ! isset( $options['auto_focus'] ) ) {
84 $new_options['auto_focus'] = true;
85 }
86
87 if ( ! isset( $options['form_records_access_capability'] ) ) {
88 $new_options['form_records_access_capability'] = 'manage_options';
89 }
90
91 if ( ! $new_options ) {
92 return;
93 }
94
95 $options_tab->update_options(
96 array_merge( $options, $new_options )
97 );
98 }
99
100 public function admin_footer_text( $footer_text ): string {
101 try {
102 Pages_Manager::instance()->get_current();
103 } catch ( Not_Found_Page_Exception $exception ) {
104 $screen = get_current_screen();
105
106 return ( $screen && 'edit-jet-form-builder' === $screen->id )
107 ? $this->get_footer_text()
108 : Tools::to_string( $footer_text );
109 }
110
111 return $this->get_footer_text();
112 }
113
114 private function get_footer_text(): string {
115 return sprintf(
116 /* translators: %s - link to the JetFormBuilder reviews page */
117 __(
118 'Liked <strong>JetFormBuilder</strong>?
119 Please <a href="%1$s" target="_blank">rate it �
120
121
122
123
124 </a>.
125 For troubleshooting, contact <a href="%2$s" target="_blank">Crocoblock support</a>.',
126 'jet-form-builder'
127 ),
128 'https://wordpress.org/support/plugin/jetformbuilder/reviews/?filter=5',
129 'https://support.crocoblock.com/support/home/'
130 );
131 }
132
133 public function modify_plugin_action_links( array $links ): array {
134 if ( jet_form_builder()->addons_manager->is_active() ) {
135 return $links;
136 }
137
138 wp_enqueue_style(
139 $this->get_handle( 'go-pro' ),
140 $this->get_url( 'assets/build/go-pro.css' ),
141 array(),
142 jet_form_builder()->get_version()
143 );
144
145 $utm = new Utm_Url( 'plugin' );
146 $utm->set_medium( 'all_plugins' );
147 $utm->set_campaign( 'go-pro-button' );
148 $utm->set_content( $utm->get_license_and_theme() );
149
150 $url = $utm->add_query( JET_FORM_BUILDER_SITE . '/pricing/' );
151
152 $label = apply_filters(
153 'jet-form-builder/admin/go-pro-link-title',
154 __( 'Go Pro', 'jet-form-builder' )
155 );
156
157 $links['go_pro'] = "<a href=\"{$url}\" target=\"_blank\" class=\"jet-fb-go-pro-link\">{$label}</a>";
158
159 return $links;
160 }
161
162 public function add_modal_on_deactivate() {
163
164 $screen = get_current_screen();
165
166 if ( 'plugins' !== $screen->id ) {
167 return;
168 }
169
170 $options = Tab_Handler_Manager::get_options( 'options-tab' );
171
172 if ( empty( $options['clear_on_uninstall'] ) ) {
173 return;
174 }
175
176 $handle = $this->get_handle( 'deactivate' );
177
178 wp_enqueue_style(
179 $handle,
180 $this->get_url( 'assets/build/deactivate.css' ),
181 array(),
182 jet_form_builder()->get_version()
183 );
184
185 wp_enqueue_script(
186 $handle,
187 $this->get_url( 'assets/build/plugins.js' ),
188 array(),
189 jet_form_builder()->get_version(),
190 true
191 );
192
193 $slug = basename( jet_form_builder()->plugin_dir() );
194
195 wp_localize_script(
196 $handle,
197 'JetFBPluginConfig',
198 array(
199 'slug' => $slug,
200 )
201 );
202
203 // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
204 ob_start();
205 ?>
206 <div style="display:none;" class="jet-form-builder-modal" id="modal-<?php echo esc_attr( $slug ); ?>">
207 <div class="jet-form-builder-modal-bg jet-form-builder-modal-exit"></div>
208 <div class="jet-form-builder-modal-container">
209 <h2 class="mb-unset"><?php echo __( 'Deactivating JetFormBuilder', 'jet-form-builder' ); ?></h2>
210 <hr/>
211 <p class="mt-unset">
212 <?php
213 echo __(
214 'You have the "<b>Clear plugin data after the uninstall</b>" option enabled, which deletes the following when the plugin is removed:',
215 'jet-form-builder'
216 );
217 ?>
218 </p>
219 <ul>
220 <li><?php echo __( 'All forms', 'jet-form-builder' ); ?></li>
221 <li><?php echo __( 'All saved Form Records', 'jet-form-builder' ); ?></li>
222 <li><?php echo __( 'All saved files', 'jet-form-builder' ); ?></li>
223 <li><?php echo __( 'All custom SQL tables', 'jet-form-builder' ); ?></li>
224 <li><?php echo __( 'All global options', 'jet-form-builder' ); ?></li>
225 </ul>
226 <p class="mb-unset">
227 <?php
228 echo __(
229 'If you are sure that you want to delete all this data,
230 click "<b>Continue</b>". If not, click "<b>Cancel</b>".',
231 'jet-form-builder'
232 );
233 ?>
234 </p>
235 <hr/>
236 <div class="jet-form-builder-modal-container-footer">
237 <button type="button"
238 class="button continue"><?php echo __( 'Continue', 'jet-form-builder' ); ?></button>
239 <button type="button"
240 class="button close"><?php echo __( 'Cancel', 'jet-form-builder' ); ?></button>
241 </div>
242 </div>
243 </div>
244 <?php
245 echo ob_get_clean();
246 // phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped
247 }
248 }
249