PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.4.1
JetFormBuilder — Dynamic Blocks Form Builder v3.4.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 2 years ago module.php 2 years ago
module.php
242 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 ( ! $new_options ) {
88 return;
89 }
90
91 $options_tab->update_options(
92 array_merge( $options, $new_options )
93 );
94 }
95
96 public function admin_footer_text( $footer_text ): string {
97 try {
98 Pages_Manager::instance()->get_current();
99 } catch ( Not_Found_Page_Exception $exception ) {
100 $screen = get_current_screen();
101
102 return ( $screen && 'edit-jet-form-builder' === $screen->id )
103 ? $this->get_footer_text()
104 : Tools::to_string( $footer_text );
105 }
106
107 return $this->get_footer_text();
108 }
109
110 private function get_footer_text(): string {
111 return sprintf(
112 /* translators: %s - link to the JetFormBuilder reviews page */
113 __(
114 'Liked <strong>JetFormBuilder</strong>?
115 Please <a href="%1$s" target="_blank">rate it �
116
117
118
119
120 </a>.
121 For troubleshooting, contact <a href="%2$s" target="_blank">Crocoblock support</a>.',
122 'jet-form-builder'
123 ),
124 'https://wordpress.org/support/plugin/jetformbuilder/reviews/?filter=5',
125 'https://support.crocoblock.com/support/home/'
126 );
127 }
128
129 public function modify_plugin_action_links( array $links ): array {
130 if ( jet_form_builder()->addons_manager->is_active() ) {
131 return $links;
132 }
133
134 wp_enqueue_style(
135 $this->get_handle( 'go-pro' ),
136 $this->get_url( 'assets/build/go-pro.css' ),
137 array(),
138 jet_form_builder()->get_version()
139 );
140
141 $utm = new Utm_Url( 'plugin' );
142 $utm->set_medium( 'all_plugins' );
143 $utm->set_campaign( 'go-pro-button' );
144 $utm->set_content( $utm->get_license_and_theme() );
145
146 $url = $utm->add_query( JET_FORM_BUILDER_SITE . '/pricing/' );
147
148 $label = __( 'Go Pro', 'jet-form-builder' );
149
150 $links['go_pro'] = "<a href=\"{$url}\" target=\"_blank\" class=\"jet-fb-go-pro-link\">{$label}</a>";
151
152 return $links;
153 }
154
155 public function add_modal_on_deactivate() {
156
157 $screen = get_current_screen();
158
159 if ( 'plugins' !== $screen->id ) {
160 return;
161 }
162
163 $options = Tab_Handler_Manager::get_options( 'options-tab' );
164
165 if ( empty( $options['clear_on_uninstall'] ) ) {
166 return;
167 }
168
169 $handle = $this->get_handle( 'deactivate' );
170
171 wp_enqueue_style(
172 $handle,
173 $this->get_url( 'assets/build/deactivate.css' ),
174 array(),
175 jet_form_builder()->get_version()
176 );
177
178 wp_enqueue_script(
179 $handle,
180 $this->get_url( 'assets/build/plugins.js' ),
181 array(),
182 jet_form_builder()->get_version(),
183 true
184 );
185
186 $slug = basename( jet_form_builder()->plugin_dir() );
187
188 wp_localize_script(
189 $handle,
190 'JetFBPluginConfig',
191 array(
192 'slug' => $slug,
193 )
194 );
195
196 // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
197 ob_start();
198 ?>
199 <div style="display:none;" class="jet-form-builder-modal" id="modal-<?php echo esc_attr( $slug ); ?>">
200 <div class="jet-form-builder-modal-bg jet-form-builder-modal-exit"></div>
201 <div class="jet-form-builder-modal-container">
202 <h2 class="mb-unset"><?php echo __( 'Deactivating JetFormBuilder', 'jet-form-builder' ); ?></h2>
203 <hr/>
204 <p class="mt-unset">
205 <?php
206 echo __(
207 'You have the "<b>Clear plugin data after the uninstall</b>" option enabled, which deletes the following when the plugin is removed:',
208 'jet-form-builder'
209 );
210 ?>
211 </p>
212 <ul>
213 <li><?php echo __( 'All forms', 'jet-form-builder' ); ?></li>
214 <li><?php echo __( 'All saved Form Records', 'jet-form-builder' ); ?></li>
215 <li><?php echo __( 'All saved files', 'jet-form-builder' ); ?></li>
216 <li><?php echo __( 'All custom SQL tables', 'jet-form-builder' ); ?></li>
217 <li><?php echo __( 'All global options', 'jet-form-builder' ); ?></li>
218 </ul>
219 <p class="mb-unset">
220 <?php
221 echo __(
222 'If you are sure that you want to delete all this data,
223 click "<b>Continue</b>". If not, click "<b>Cancel</b>".',
224 'jet-form-builder'
225 );
226 ?>
227 </p>
228 <hr/>
229 <div class="jet-form-builder-modal-container-footer">
230 <button type="button"
231 class="button continue"><?php echo __( 'Continue', 'jet-form-builder' ); ?></button>
232 <button type="button"
233 class="button close"><?php echo __( 'Cancel', 'jet-form-builder' ); ?></button>
234 </div>
235 </div>
236 </div>
237 <?php
238 echo ob_get_clean();
239 // phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped
240 }
241 }
242