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