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

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