PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.1.5
ShopBuilder – WooCommerce Builder For Elementor v3.1.5
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
shopbuilder / app / Controllers / Admin / PluginRow.php

PluginRow.php in ShopBuilder – WooCommerce Builder For Elementor 3.1.5, at app/Controllers/Admin/PluginRow.php

533 lines 16.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace RadiusTheme\SB\Controllers\Admin;
4
5 use RadiusTheme\SB\Traits\SingletonTrait;
6
7 // Do not allow directly accessing this file.
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit( 'This script cannot be accessed directly.' );
10 }
11
12 /**
13 * Settings Page.
14 */
15 class PluginRow {
16 /**
17 * Singleton Trait.
18 */
19 use SingletonTrait;
20
21 /**
22 * Template builder post type
23 *
24 * @var string
25 */
26 public string $textdomain = 'shopbuilder';
27
28 /**
29 * Construct function
30 */
31 private function __construct() {
32 // Plugins Setting Page.
33 add_filter( 'plugin_action_links_' . plugin_basename( RTSB_FILE ), [ $this, 'plugins_setting_links' ] );
34 add_filter( 'plugin_row_meta', [ $this, 'plugin_row_meta' ], 10, 2 );
35 add_action( 'admin_footer', [ $this, 'deactivation_popup' ], 99 );
36 }
37
38 /**
39 * @param array $links default plugin action link.
40 *
41 * @return array [array] plugin action link
42 */
43 public function plugins_setting_links( $links ) {
44 $new_links = [];
45 $demo_url = 'https://shopbuilderwp.com/';
46 $new_links[] = '<a href="' . admin_url( 'admin.php?page=rtsb-settings' ) . '">' . esc_html__( 'Settings', 'shopbuilder' ) . '</a>';
47 $new_links[] = '<a target="_blank" href="' . esc_url( $demo_url ) . '">' . esc_html__( 'Demo', 'shopbuilder' ) . '</a>';
48 $new_links[] = '<a target="_blank" href="' . esc_url( 'https://shopbuilderwp.com/docs/' ) . '">' . esc_html__( 'Documentation', 'shopbuilder' ) . '</a>';
49
50 $links = array_merge( $new_links, $links );
51
52 if ( ! rtsb()->has_pro() ) {
53 $links['shopbuilder_pro'] = '<a href="' . esc_url( rtsb()->pro_version_link() ) . '" target="_blank" style="color: #39b54a; font-weight: bold;">' . esc_html__( 'Go Pro', 'shopbuilder' ) . '</a>';
54 }
55
56 return $links;
57 }
58
59 /**
60 * Plugin links row.
61 *
62 * @param array $links Links.
63 * @param string $file File.
64 *
65 * @return array
66 */
67 public function plugin_row_meta( $links, $file ) {
68
69 if ( RTSB_ACTIVE_FILE_NAME === $file ) {
70 $report_url = 'https://www.radiustheme.com/contact/';
71 $row_meta['issues'] = sprintf(
72 /* translators: %1$s: Report URL, %2$s: Facing issue?, %3$s: Please open a support ticket. */
73 '%2$s <a target="_blank" href="%1$s"><span style="color: red">%3$s</span></a>',
74 esc_url( $report_url ),
75 esc_html__( 'Facing issue?', 'shopbuilder' ),
76 esc_html__( 'Please open a support ticket.', 'shopbuilder' )
77 );
78
79 return array_merge( $links, $row_meta );
80 }
81
82 return (array) $links;
83 }
84
85 /***
86 * @return mixed
87 */
88 public function deactivation_popup() {
89 global $pagenow;
90 if ( 'plugins.php' !== $pagenow ) {
91 return;
92 }
93
94 $this->dialog_box_style();
95 $this->deactivation_scripts();
96 ?>
97 <div id="deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?>" title="Quick Feedback">
98 <!-- Modal content -->
99 <div class="modal-content">
100 <div id="feedback-form-body-<?php echo esc_attr( $this->textdomain ); ?>">
101 <div class="feedback-input-header">
102 <?php echo esc_html__( 'If you have a moment, please share why you are deactivating ShopBuilder:', 'shopbuilder' ); ?>
103 </div>
104
105 <div class="feedback-input-wrapper">
106 <input id="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-bug_issue_detected" class="feedback-input"
107 type="radio" name="reason_key" value="bug_issue_detected">
108 <label for="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-bug_issue_detected" class="feedback-label">Bug Or Issue detected.</label>
109 </div>
110
111 <div class="feedback-input-wrapper">
112 <input id="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-no_longer_needed" class="feedback-input" type="radio"
113 name="reason_key" value="no_longer_needed">
114 <label for="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-no_longer_needed" class="feedback-label">I no longer
115 need the plugin</label>
116 </div>
117 <div class="feedback-input-wrapper conditional">
118 <input id="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-found_a_better_plugin" class="feedback-input"
119 type="radio" name="reason_key" value="found_a_better_plugin">
120 <label for="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-found_a_better_plugin" class="feedback-label">I found a
121 better plugin</label>
122 <input class="feedback-feedback-text" type="text" name="reason_found_a_better_plugin"
123 placeholder="Please share the plugin name">
124 </div>
125 <div class="feedback-input-wrapper">
126 <input id="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-couldnt_get_the_plugin_to_work" class="feedback-input"
127 type="radio" name="reason_key" value="couldnt_get_the_plugin_to_work">
128 <label for="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-couldnt_get_the_plugin_to_work" class="feedback-label">I
129 couldn't get the plugin to work</label>
130 </div>
131
132 <div class="feedback-input-wrapper">
133 <input id="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-temporary_deactivation" class="feedback-input"
134 type="radio" name="reason_key" value="temporary_deactivation">
135 <label for="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-temporary_deactivation" class="feedback-label">It's a
136 temporary deactivation</label>
137 </div>
138 <span style="color:red;font-size: 13px;"></span>
139 </div>
140 <p style="margin: 10px 0 15px 0;">
141 Please let us know about any issues you are facing with the plugin.
142 How can we improve the plugin?
143 </p>
144 <div class="feedback-text-wrapper-<?php echo esc_attr( $this->textdomain ); ?>">
145 <textarea id="deactivation-feedback-<?php echo esc_attr( $this->textdomain ); ?>" rows="4" cols="40"
146 placeholder=" Write something here. How can we improve the plugin?"></textarea>
147 <span style="display: block;color:red;font-size: 13px;margin-top: 5px;"></span>
148 </div>
149 </div>
150 </div>
151 <?php
152 }
153
154 /***
155 * @return mixed
156 */
157 public function dialog_box_style() {
158 ?>
159 <style>
160 /* Add Animation */
161 @-webkit-keyframes animatetop {
162 from {
163 top: -300px;
164 opacity: 0
165 }
166 to {
167 top: 0;
168 opacity: 1
169 }
170 }
171
172 @keyframes animatetop {
173 from {
174 top: -300px;
175 opacity: 0
176 }
177 to {
178 top: 0;
179 opacity: 1
180 }
181 }
182
183 #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> {
184 display: none;
185 }
186
187 .ui-dialog-titlebar-close {
188 display: none;
189 }
190
191 /* The Modal (background) */
192 #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal {
193 display: none; /* Hidden by default */
194 position: fixed; /* Stay in place */
195 z-index: 1; /* Sit on top */
196 padding-top: 100px; /* Location of the box */
197 left: 0;
198 top: 0;
199 width: 100%; /* Full width */
200 height: 100%; /* Full height */
201 overflow: auto; /* Enable scroll if needed */
202 }
203
204 /* Modal Content */
205 #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content {
206 position: relative;
207 margin: auto;
208 padding: 0;
209 }
210
211 div#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> p {
212 font-size: 15px;
213 }
214
215 #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content > * {
216 width: 100%;
217 overflow: hidden;
218 }
219
220 #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content textarea {
221 border: 1px solid rgba(0, 0, 0, 0.3);
222 padding: 15px;
223 width: 100%;
224 }
225
226 #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content textarea:focus {
227 border-color: #2271b1;
228 }
229
230 #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content input.feedback-feedback-text {
231 border: 1px solid rgba(0, 0, 0, 0.3);
232 min-width: 250px;
233 }
234
235 /* The Close Button */
236 #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> input[type="radio"] {
237 margin: 0;
238 }
239
240 .ui-dialog-title {
241 font-size: 18px;
242 font-weight: 600;
243 }
244
245 #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-body {
246 padding: 2px 16px;
247 }
248
249 .ui-dialog-buttonset {
250 background-color: #fefefe;
251 padding: 0 17px 25px;
252 display: flex;
253 justify-content: space-between;
254 gap: 10px;
255 }
256
257 .ui-dialog-buttonset button {
258 min-width: 110px;
259 text-align: center;
260 border: 1px solid rgba(0, 0, 0, 0.1);
261 padding: 0 15px;
262 border-radius: 5px;
263 height: 40px;
264 font-size: 15px;
265 font-weight: 600;
266 display: inline-flex;
267 align-items: center;
268 justify-content: center;
269 cursor: pointer;
270 transition: 0.3s all;
271 background: rgba(0, 0, 0, 0.02);
272 margin: 0;
273 }
274
275 .ui-dialog-buttonset button:nth-child(2) {
276 background: transparent;
277 }
278
279 .ui-dialog-buttonset button:hover {
280 background: #2271b1;
281 color: #fff;
282 }
283
284 .ui-dialog[aria-describedby="deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?>"] {
285 background-color: #fefefe;
286 box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
287 z-index: 99;
288 }
289
290 .ui-dialog[aria-describedby="deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?>"] .ui-dialog-title {
291 text-transform: uppercase;
292 font-weight: 700;
293 font-size: 16px;
294 padding-left: 15px;
295 padding-right: 15px;
296 }
297
298 #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> {
299 padding: 30px !important;
300 }
301
302 #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .feedback-input-header {
303 font-weight: 600;
304 font-size: 15px;
305 line-height: 1.4;
306 margin-bottom: 20px;
307 }
308
309 div#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?>,
310 .ui-draggable .ui-dialog-titlebar {
311 padding: 18px 15px;
312 box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
313 text-align: left;
314 }
315
316 div#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content .feedback-input-wrapper {
317 margin-bottom: 8px;
318 display: flex;
319 align-items: center;
320 gap: 8px;
321 /*line-height: 2;*/
322 padding: 0 1px;
323 font-size: 14px;
324 }
325
326 div#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content .feedback-input-wrapper.conditional {
327 flex-wrap: wrap;
328 }
329
330 div#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content .feedback-input-wrapper.conditional .feedback-feedback-text {
331 flex: 0 0 calc(100% - 24px);
332 margin: 5px 0 10px 24px;
333 min-height: 40px;
334 border: 1px solid rgba(0, 0, 0, 0.3);
335 padding: 0 15px;
336 }
337
338 div#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content .feedback-input-wrapper.conditional .feedback-feedback-text:focus {
339 border-color: #2271b1;
340 }
341
342 .ui-widget-overlay.ui-front {
343 position: fixed;
344 top: 0;
345 left: 0;
346 right: 0;
347 bottom: 0;
348 z-index: 999;
349 background-color: rgba(0, 0, 0, 0.5);
350 }
351
352 .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-dialog-buttonset {
353 background-color: #fefefe;
354 box-shadow: none;
355 z-index: 99;
356 padding-left: 30px;
357 padding-right: 30px;
358 }
359
360 .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-dialog-buttonpane,
361 .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-widget-content {
362 border: 0;
363 }
364
365 .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-resizable-handle {
366 display: none !important;
367 }
368
369 .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-dialog-buttonset .ui-button {
370 font-size: 12px;
371 font-weight: 500;
372 line-height: 1.2;
373 padding: 8px 16px;
374 outline: none;
375 border: none;
376 }
377
378 .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-dialog-buttonset .ui-button:first-child {
379 background: #4360ef;
380 color: #fff;
381 }
382
383 .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-dialog-buttonset .ui-button:first-child:hover {
384 background: #1f3edc;
385 }
386
387 .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-dialog-buttonset .ui-button:last-child {
388 background: none;
389 }
390
391 .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-dialog-buttonset .ui-button:last-child:hover {
392 background: #d80e0e;
393 color: #fff;
394 }
395 </style>
396
397 <?php
398 }
399
400 /***
401 * @return void
402 */
403 public function deactivation_scripts() {
404 wp_enqueue_script( 'jquery-ui-dialog' );
405 ?>
406 <script>
407 jQuery(document).ready(function ($) {
408
409 // Open the deactivation dialog when the 'Deactivate' link is clicked
410 $('.deactivate #deactivate-shopbuilder').on('click', function (e) {
411 e.preventDefault();
412 var href = $('.deactivate #deactivate-shopbuilder').attr('href');
413 $('#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content input[name="reason_found_a_better_plugin"]').hide();
414 var dialogbox = $('#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?>').dialog({
415 modal: true,
416 width: 550,
417 show: {
418 effect: "fadeIn",
419 duration: 400
420 },
421 hide: {
422 effect: "fadeOut",
423 duration: 100
424 },
425
426 buttons: {
427 Submit: function () {
428 submitFeedback();
429 },
430 Cancel: function () {
431 $(this).dialog('close');
432 window.location.href = href;
433 }
434 }
435 });
436
437
438 // Close the dialog when clicking outside of it
439 dialogbox.on('change', 'input[type="radio"]', function (event) {
440 var reasons = $('#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> input[type="radio"]:checked').val();
441 if( 'found_a_better_plugin' === reasons ){
442 $('#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content input[name="reason_found_a_better_plugin"]').show();
443 } else {
444 $('#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content input[name="reason_found_a_better_plugin"]').hide();
445 }
446 });
447
448 // Close the dialog when clicking outside of it
449 $(document).on('click', '.ui-widget-overlay.ui-front', function (event) {
450 if ($(event.target).closest(dialogbox.parent()).length === 0) {
451 dialogbox.dialog('close');
452 }
453 });
454
455 // Customize the button text
456 $('.ui-dialog-buttonpane button:contains("Submit")').text('Submit & Deactivate');
457 $('.ui-dialog-buttonpane button:contains("Cancel")').text('Skip & Deactivate');
458 });
459
460 // Submit the feedback
461 function submitFeedback() {
462 var href = $('.deactivate #deactivate-shopbuilder').attr('href');
463 var reasons = $('#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> input[type="radio"]:checked').val();
464 var feedback = $('#deactivation-feedback-<?php echo esc_attr( $this->textdomain ); ?>').val();
465 var better_plugin = $('#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content input[name="reason_found_a_better_plugin"]').val();
466 // Perform AJAX request to submit feedback
467 if (!reasons && !feedback && !better_plugin) {
468 // Define flag variables
469 $('#feedback-form-body-<?php echo esc_attr( $this->textdomain ); ?> span').text('Choose The Reason');
470 $('.feedback-text-wrapper-<?php echo esc_attr( $this->textdomain ); ?> span').text('Please provide more details regarding the issue so we can address it in future updates.');
471 return;
472 }
473
474 if (!reasons ) {
475 // Define flag variables
476 $('#feedback-form-body-<?php echo esc_attr( $this->textdomain ); ?> span').text('Choose The Reason');
477 $('.feedback-text-wrapper-<?php echo esc_attr( $this->textdomain ); ?> span').text('Please provide more details regarding the issue so we can address it in future updates.');
478 return;
479 }
480
481 if ( 'bug_issue_detected' === reasons && !feedback ) {
482 // Define flag variables
483 $('.feedback-text-wrapper-<?php echo esc_attr( $this->textdomain ); ?> span').text('Please provide more details regarding the issue so we can address it in future updates.');
484 return;
485 }
486
487 if ('temporary_deactivation' === reasons || ! feedback ) {
488 window.location.href = href;
489 return;
490 }
491
492 if ( ! feedback.length > 0 ) {
493 window.location.href = href;
494 return;
495 }
496 var websiteUrl = '<?php echo esc_url( home_url() ); ?>';
497 if ( ! websiteUrl.length > 0 ) {
498 window.location.href = href;
499 return;
500 }
501 $.ajax({
502 url: 'https://shopbuilderwp.com/wp-json/RadiusTheme/pluginSurvey/v1/Survey/appendToSheet',
503 method: 'GET',
504 dataType: 'json',
505 data: {
506 website: websiteUrl,
507 reasons: reasons ? reasons : '',
508 better_plugin: better_plugin,
509 feedback: feedback,
510 wpplugin: 'ShopBuilder',
511 },
512 success: function (response) {
513 },
514 error: function (xhr, status, error) {
515 // Handle the error response
516 console.error('Error', error);
517 },
518 complete: function (xhr, status) {
519 $('#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?>').dialog('close');
520 window.location.href = href;
521 }
522
523 });
524 }
525
526 });
527
528 </script>
529
530 <?php
531 }
532 }
533