PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.2.3
ShopBuilder – WooCommerce Builder For Elementor v3.2.3
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 2.3.0 All 62 releases
shopbuilder / app / Controllers / Admin / PluginRow.php

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

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