PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.4.3
JetFormBuilder — Dynamic Blocks Form Builder v3.4.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 / modules / admin / module.php
jetformbuilder / modules / admin Last commit date
assets 2 years ago module.php 1 year ago
module.php
245 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 = apply_filters(
149 'jet-form-builder/admin/go-pro-link-title',
150 __( 'Go Pro', 'jet-form-builder' )
151 );
152
153 $links['go_pro'] = "<a href=\"{$url}\" target=\"_blank\" class=\"jet-fb-go-pro-link\">{$label}</a>";
154
155 return $links;
156 }
157
158 public function add_modal_on_deactivate() {
159
160 $screen = get_current_screen();
161
162 if ( 'plugins' !== $screen->id ) {
163 return;
164 }
165
166 $options = Tab_Handler_Manager::get_options( 'options-tab' );
167
168 if ( empty( $options['clear_on_uninstall'] ) ) {
169 return;
170 }
171
172 $handle = $this->get_handle( 'deactivate' );
173
174 wp_enqueue_style(
175 $handle,
176 $this->get_url( 'assets/build/deactivate.css' ),
177 array(),
178 jet_form_builder()->get_version()
179 );
180
181 wp_enqueue_script(
182 $handle,
183 $this->get_url( 'assets/build/plugins.js' ),
184 array(),
185 jet_form_builder()->get_version(),
186 true
187 );
188
189 $slug = basename( jet_form_builder()->plugin_dir() );
190
191 wp_localize_script(
192 $handle,
193 'JetFBPluginConfig',
194 array(
195 'slug' => $slug,
196 )
197 );
198
199 // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
200 ob_start();
201 ?>
202 <div style="display:none;" class="jet-form-builder-modal" id="modal-<?php echo esc_attr( $slug ); ?>">
203 <div class="jet-form-builder-modal-bg jet-form-builder-modal-exit"></div>
204 <div class="jet-form-builder-modal-container">
205 <h2 class="mb-unset"><?php echo __( 'Deactivating JetFormBuilder', 'jet-form-builder' ); ?></h2>
206 <hr/>
207 <p class="mt-unset">
208 <?php
209 echo __(
210 'You have the "<b>Clear plugin data after the uninstall</b>" option enabled, which deletes the following when the plugin is removed:',
211 'jet-form-builder'
212 );
213 ?>
214 </p>
215 <ul>
216 <li><?php echo __( 'All forms', 'jet-form-builder' ); ?></li>
217 <li><?php echo __( 'All saved Form Records', 'jet-form-builder' ); ?></li>
218 <li><?php echo __( 'All saved files', 'jet-form-builder' ); ?></li>
219 <li><?php echo __( 'All custom SQL tables', 'jet-form-builder' ); ?></li>
220 <li><?php echo __( 'All global options', 'jet-form-builder' ); ?></li>
221 </ul>
222 <p class="mb-unset">
223 <?php
224 echo __(
225 'If you are sure that you want to delete all this data,
226 click "<b>Continue</b>". If not, click "<b>Cancel</b>".',
227 'jet-form-builder'
228 );
229 ?>
230 </p>
231 <hr/>
232 <div class="jet-form-builder-modal-container-footer">
233 <button type="button"
234 class="button continue"><?php echo __( 'Continue', 'jet-form-builder' ); ?></button>
235 <button type="button"
236 class="button close"><?php echo __( 'Cancel', 'jet-form-builder' ); ?></button>
237 </div>
238 </div>
239 </div>
240 <?php
241 echo ob_get_clean();
242 // phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped
243 }
244 }
245