PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.2.2
ShopBuilder – WooCommerce Builder For Elementor v3.2.2
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.2.2, at app/Controllers/Admin/PluginRow.php

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