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

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