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

536 lines 16.7 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/requirements/' ) . '">' . esc_html__( 'Documentation', 'shopbuilder' ) . '</a>';
49
50 $links = array_merge( $new_links, $links );
51 $links = array_merge( $new_links, $links );
52
53 if ( ! rtsb()->has_pro() ) {
54 $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>';
55 }
56
57 return $links;
58 }
59
60 /**
61 * Plugin links row.
62 *
63 * @param array $links Links.
64 * @param string $file File.
65 *
66 * @return array
67 */
68 public function plugin_row_meta( $links, $file ) {
69
70 if ( RTSB_ACTIVE_FILE_NAME === $file ) {
71 $report_url = 'https://www.radiustheme.com/contact/';
72 $row_meta['issues'] = sprintf(
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 // Servay
86
87 /***
88 * @param $mimes
89 *
90 * @return mixed
91 */
92 public function deactivation_popup() {
93 global $pagenow;
94 if ( 'plugins.php' !== $pagenow ) {
95 return;
96 }
97
98 $this->dialog_box_style();
99 $this->deactivation_scripts();
100 ?>
101 <div id="deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?>" title="Quick Feedback">
102 <!-- Modal content -->
103 <div class="modal-content">
104 <div id="feedback-form-body-<?php echo esc_attr( $this->textdomain ); ?>">
105 <div class="feedback-input-header">
106 <?php echo esc_html__( 'If you have a moment, please share why you are deactivating ShopBuilder:', 'shopbuilder' ); ?>
107 </div>
108
109 <div class="feedback-input-wrapper">
110 <input id="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-bug_issue_detected" class="feedback-input"
111 type="radio" name="reason_key" value="bug_issue_detected">
112 <label for="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-bug_issue_detected" class="feedback-label">Bug Or Issue detected.</label>
113 </div>
114
115 <div class="feedback-input-wrapper">
116 <input id="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-no_longer_needed" class="feedback-input" type="radio"
117 name="reason_key" value="no_longer_needed">
118 <label for="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-no_longer_needed" class="feedback-label">I no longer
119 need the plugin</label>
120 </div>
121 <div class="feedback-input-wrapper conditional">
122 <input id="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-found_a_better_plugin" class="feedback-input"
123 type="radio" name="reason_key" value="found_a_better_plugin">
124 <label for="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-found_a_better_plugin" class="feedback-label">I found a
125 better plugin</label>
126 <input class="feedback-feedback-text" type="text" name="reason_found_a_better_plugin"
127 placeholder="Please share the plugin name">
128 </div>
129 <div class="feedback-input-wrapper">
130 <input id="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-couldnt_get_the_plugin_to_work" class="feedback-input"
131 type="radio" name="reason_key" value="couldnt_get_the_plugin_to_work">
132 <label for="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-couldnt_get_the_plugin_to_work" class="feedback-label">I
133 couldn't get the plugin to work</label>
134 </div>
135
136 <div class="feedback-input-wrapper">
137 <input id="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-temporary_deactivation" class="feedback-input"
138 type="radio" name="reason_key" value="temporary_deactivation">
139 <label for="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-temporary_deactivation" class="feedback-label">It's a
140 temporary deactivation</label>
141 </div>
142 <span style="color:red;font-size: 13px;"></span>
143 </div>
144 <p style="margin: 10px 0 15px 0;">
145 Please let us know about any issues you are facing with the plugin.
146 How can we improve the plugin?
147 </p>
148 <div class="feedback-text-wrapper-<?php echo esc_attr( $this->textdomain ); ?>">
149 <textarea id="deactivation-feedback-<?php echo esc_attr( $this->textdomain ); ?>" rows="4" cols="40"
150 placeholder=" Write something here. How can we improve the plugin?"></textarea>
151 <span style="display: block;color:red;font-size: 13px;margin-top: 5px;"></span>
152 </div>
153 </div>
154 </div>
155 <?php
156 }
157
158 /***
159 * @param $mimes
160 *
161 * @return mixed
162 */
163 public function dialog_box_style() {
164 ?>
165 <style>
166 /* Add Animation */
167 @-webkit-keyframes animatetop {
168 from {
169 top: -300px;
170 opacity: 0
171 }
172 to {
173 top: 0;
174 opacity: 1
175 }
176 }
177
178 @keyframes animatetop {
179 from {
180 top: -300px;
181 opacity: 0
182 }
183 to {
184 top: 0;
185 opacity: 1
186 }
187 }
188
189 #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> {
190 display: none;
191 }
192
193 .ui-dialog-titlebar-close {
194 display: none;
195 }
196
197 /* The Modal (background) */
198 #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal {
199 display: none; /* Hidden by default */
200 position: fixed; /* Stay in place */
201 z-index: 1; /* Sit on top */
202 padding-top: 100px; /* Location of the box */
203 left: 0;
204 top: 0;
205 width: 100%; /* Full width */
206 height: 100%; /* Full height */
207 overflow: auto; /* Enable scroll if needed */
208 }
209
210 /* Modal Content */
211 #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content {
212 position: relative;
213 margin: auto;
214 padding: 0;
215 }
216
217 /*#deactivation-dialog-*/<?php // echo esc_attr( $this->textdomain ); ?>/* .feedback-label {*/
218 /* font-size: 15px;*/
219 /*}*/
220
221 div#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> p {
222 font-size: 15px;
223 }
224
225 #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content > * {
226 width: 100%;
227 overflow: hidden;
228 }
229
230 #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content textarea {
231 border: 1px solid rgba(0, 0, 0, 0.3);
232 padding: 15px;
233 width: 100%;
234 }
235
236 #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content textarea:focus {
237 border-color: #2271b1;
238 }
239
240 #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content input.feedback-feedback-text {
241 border: 1px solid rgba(0, 0, 0, 0.3);
242 min-width: 250px;
243 }
244
245 /* The Close Button */
246 #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> input[type="radio"] {
247 margin: 0;
248 }
249
250 .ui-dialog-title {
251 font-size: 18px;
252 font-weight: 600;
253 }
254
255 #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-body {
256 padding: 2px 16px;
257 }
258
259 .ui-dialog-buttonset {
260 background-color: #fefefe;
261 padding: 0 17px 25px;
262 display: flex;
263 justify-content: space-between;
264 gap: 10px;
265 }
266
267 .ui-dialog-buttonset button {
268 min-width: 110px;
269 text-align: center;
270 border: 1px solid rgba(0, 0, 0, 0.1);
271 padding: 0 15px;
272 border-radius: 5px;
273 height: 40px;
274 font-size: 15px;
275 font-weight: 600;
276 display: inline-flex;
277 align-items: center;
278 justify-content: center;
279 cursor: pointer;
280 transition: 0.3s all;
281 background: rgba(0, 0, 0, 0.02);
282 margin: 0;
283 }
284
285 .ui-dialog-buttonset button:nth-child(2) {
286 background: transparent;
287 }
288
289 .ui-dialog-buttonset button:hover {
290 background: #2271b1;
291 color: #fff;
292 }
293
294 .ui-dialog[aria-describedby="deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?>"] {
295 background-color: #fefefe;
296 box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
297 z-index: 99;
298 }
299
300 .ui-dialog[aria-describedby="deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?>"] .ui-dialog-title {
301 text-transform: uppercase;
302 font-weight: 700;
303 font-size: 16px;
304 padding-left: 15px;
305 padding-right: 15px;
306 }
307
308 #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> {
309 padding: 30px !important;
310 }
311
312 #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .feedback-input-header {
313 font-weight: 600;
314 font-size: 15px;
315 line-height: 1.4;
316 margin-bottom: 20px;
317 }
318
319 div#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?>,
320 .ui-draggable .ui-dialog-titlebar {
321 padding: 18px 15px;
322 box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
323 text-align: left;
324 }
325
326 div#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content .feedback-input-wrapper {
327 margin-bottom: 8px;
328 display: flex;
329 align-items: center;
330 gap: 8px;
331 /*line-height: 2;*/
332 padding: 0 1px;
333 font-size: 14px;
334 }
335
336 div#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content .feedback-input-wrapper.conditional {
337 flex-wrap: wrap;
338 }
339
340 div#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content .feedback-input-wrapper.conditional .feedback-feedback-text {
341 flex: 0 0 calc(100% - 24px);
342 margin: 5px 0 10px 24px;
343 min-height: 40px;
344 border: 1px solid rgba(0, 0, 0, 0.3);
345 padding: 0 15px;
346 }
347
348 div#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content .feedback-input-wrapper.conditional .feedback-feedback-text:focus {
349 border-color: #2271b1;
350 }
351
352 .ui-widget-overlay.ui-front {
353 position: fixed;
354 top: 0;
355 left: 0;
356 right: 0;
357 bottom: 0;
358 z-index: 999;
359 background-color: rgba(0, 0, 0, 0.5);
360 }
361
362 .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-dialog-buttonset {
363 background-color: #fefefe;
364 box-shadow: none;
365 z-index: 99;
366 padding-left: 30px;
367 padding-right: 30px;
368 }
369
370 .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-dialog-buttonpane,
371 .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-widget-content {
372 border: 0;
373 }
374
375 .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-resizable-handle {
376 display: none !important;
377 }
378
379 .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-dialog-buttonset .ui-button {
380 font-size: 12px;
381 font-weight: 500;
382 line-height: 1.2;
383 padding: 8px 16px;
384 outline: none;
385 border: none;
386 }
387
388 .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-dialog-buttonset .ui-button:first-child {
389 background: #4360ef;
390 color: #fff;
391 }
392
393 .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-dialog-buttonset .ui-button:first-child:hover {
394 background: #1f3edc;
395 }
396
397 .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-dialog-buttonset .ui-button:last-child {
398 background: none;
399 }
400
401 .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-dialog-buttonset .ui-button:last-child:hover {
402 background: #d80e0e;
403 color: #fff;
404 }
405 </style>
406
407 <?php
408 }
409
410 /***
411 * @param $mimes
412 *
413 * @return mixed
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 me with some advice.');
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 me with some advice.');
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 $.ajax({
505 url: 'https://shopbuilderwp.com/wp-json/RadiusTheme/pluginSurvey/v1/Survey/appendToSheet',
506 method: 'GET',
507 dataType: 'json',
508 data: {
509 website: '<?php echo esc_url( home_url() ); ?>',
510 reasons: reasons ? reasons : '',
511 better_plugin: better_plugin,
512 feedback: feedback,
513 wpplugin: 'ShopBuilder',
514 },
515 success: function (response) {
516 },
517 error: function (xhr, status, error) {
518 // Handle the error response
519 console.error('Error', error);
520 },
521 complete: function (xhr, status) {
522 $('#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?>').dialog('close');
523 window.location.href = href;
524 }
525
526 });
527 }
528
529 });
530
531 </script>
532
533 <?php
534 }
535 }
536