PluginProbe
Pixelavo – Server Side Tracking & Pixel + AI Ads Tools / 1.1.3
Pixelavo – Server Side Tracking & Pixel + AI Ads Tools v1.1.3
1.5.5 1.5.4 trunk 1.0.0 1.0.1 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 All 47 releases
pixelavo / admin / class-trial.php

class-trial.php in Pixelavo – Server Side Tracking & Pixel + AI Ads Tools 1.1.3, at admin/class-trial.php

719 lines 27.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Version: beta-1.0.1
4 */
5
6 // If this file is accessed directly, exit.
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit;
9 }
10
11 /**
12 * Class.
13 */
14 if ( ! class_exists( 'Pixelavo_Trial' ) ) {
15 final class Pixelavo_Trial {
16
17 /**
18 * Prefix.
19 */
20 public $prefix;
21
22 /**
23 * Pro file.
24 */
25 public $pro_file;
26
27 /**
28 * Data center.
29 */
30 public $data_center;
31
32 /**
33 * Initial page.
34 */
35 public $initial_page;
36
37 /**
38 * Screen ids.
39 */
40 public $screen_ids;
41
42 /**
43 * Instance.
44 */
45 public static $_instance = null;
46
47 /**
48 * Get instance.
49 */
50 public static function get_instance() {
51 if ( is_null( self::$_instance ) ) {
52 self::$_instance = new self();
53 }
54
55 return self::$_instance;
56 }
57
58 /**
59 * Constructor.
60 */
61 public function __construct() {
62 $this->includes();
63
64 $this->prefix = 'pixelavo';
65 $this->pro_file = 'pixelavo-pro/pixelavo-pro.php';
66 $this->data_center = 'https://feed.hasthemes.com/pixelavo/tw/';
67 $this->initial_page = admin_url( 'admin.php?page=pixelavo' );
68 $this->screen_ids = array('toplevel_page_pixelavo');
69
70 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
71 add_action( 'admin_init', [ $this, 'run_offer' ], 999999 );
72 }
73
74 /**
75 * Includes.
76 */
77 public function includes() {
78 if ( ! function_exists( 'is_plugin_active' ) || ! function_exists( 'get_plugins' ) || ! function_exists( 'get_plugin_data' ) ) {
79 require_once ABSPATH . 'wp-admin/includes/plugin.php';
80 }
81 }
82
83 /**
84 * Enqueue scripts.
85 */
86 public function enqueue_scripts() {
87 if ( ! $this->is_plugin_screen() ) {
88 return;
89 }
90
91 add_thickbox();
92 }
93
94 /**
95 * Run offer.
96 */
97 public function run_offer() {
98 if ( $this->is_pro_installed() || ! $this->is_capable_user() ) {
99 return;
100 }
101
102 $this->set_offer();
103 $this->show_offer();
104 }
105
106 /**
107 * Is pro installed.
108 */
109 public function is_pro_installed() {
110 $plugins = get_plugins();
111 $result = ( isset( $plugins[ $this->pro_file ] ) ? true : false );
112
113 if ( $result ) {
114 update_option( $this->prefix . '_htiop', 'no' );
115 update_option( $this->prefix . '_htiop_bar', 'no' );
116 update_option( $this->prefix . '_htiop_popup', 'no' );
117 update_option( $this->prefix . '_htiop_redirect', 'no' );
118 }
119
120 return $result;
121 }
122
123 /**
124 * Is capable user.
125 */
126 public function is_capable_user() {
127 $result = false;
128
129 if ( current_user_can( 'manage_options' ) ) {
130 $result = true;
131 }
132
133 return $result;
134 }
135
136 /**
137 * Is show offer bar.
138 */
139 public function is_show_offer_bar() {
140 $result = get_option( $this->prefix . '_htiop_bar' );
141 $result = 'yes' === $result ? true : false;
142
143 return $result;
144 }
145
146 /**
147 * Is show offer popup.
148 */
149 public function is_show_offer_popup() {
150 $result = get_option( $this->prefix . '_htiop_popup' );
151 $result = 'yes' === $result ? true : false;
152
153 return $result;
154 }
155
156 /**
157 * Is plugin screen.
158 */
159 public function is_plugin_screen() {
160 $screen = get_current_screen();
161 $id = isset( $screen->id ) ? $screen->id : "";
162 $result = in_array($id, $this->screen_ids) ? true : false;
163
164 return $result;
165 }
166
167 /**
168 * Is valid JSON.
169 */
170 public function is_valid_json( $json = '' ) {
171 if ( is_string( $json ) && ! empty( $json ) ) {
172 @json_decode( $json );
173 return ( json_last_error() === JSON_ERROR_NONE );
174 }
175
176 return false;
177 }
178
179 /**
180 * Set offer data.
181 */
182 public function set_offer_data() {
183 $setted = get_option( $this->prefix . '_htiop_data' );
184 $setted = 'yes' === $setted ? true : false;
185
186 if ( $setted ) {
187 return;
188 }
189
190 $ex_data = get_transient( $this->prefix . '_htiop_data' );
191 $ex_data = $this->is_valid_json( $ex_data ) ? json_decode( $ex_data, true ) : $ex_data;
192
193 if ( is_array( $ex_data ) && ! empty( $ex_data ) ) {
194 return;
195 }
196
197 $response = wp_remote_get( $this->data_center, [ 'timeout' => 120, 'headers' => [ 'Countme' => 1 ] ] );
198 $code = wp_remote_retrieve_response_code( $response );
199
200 if ( 200 !== $code ) {
201 return;
202 }
203
204 $body = wp_remote_retrieve_body( $response );
205 $body = $this->is_valid_json( $body ) ? json_decode( $body, true ) : $body;
206
207 if ( ! is_array( $body ) || empty( $body ) ) {
208 return;
209 }
210
211 $data = ( ( isset( $body['data'] ) && is_array( $body['data'] ) ) ? $body['data'] : [] );
212
213 if ( empty( $data ) ) {
214 return;
215 }
216
217 $timer = isset( $body['timer'] ) ? absint( $body['timer'] ) : 0;
218 $expiry = isset( $body['expiry'] ) ? absint( $body['expiry'] ) : 0;
219
220 $setted = set_transient( $this->prefix . '_htiop_data', wp_json_encode( $data ), $expiry );
221
222 if ( $setted ) {
223 update_option( $this->prefix . '_htiop_timer', $timer + current_time( 'U', true ) );
224 update_option( $this->prefix . '_htiop_data', 'yes' );
225 }
226 }
227
228 /**
229 * Get offer data.
230 */
231 public function get_offer_data( $type = '' ) {
232 $data = get_transient( $this->prefix . '_htiop_data' );
233 $data = $this->is_valid_json( $data ) ? json_decode( $data, true ) : $data;
234
235 if ( ! is_array( $data ) || empty( $data ) ) {
236 return;
237 }
238
239 $bar = ( ( isset( $data['bar'] ) && is_array( $data['bar'] ) ) ? $data['bar'] : [] );
240 $barnt = ( ( isset( $data['barnt'] ) && is_array( $data['barnt'] ) ) ? $data['barnt'] : [] );
241 $popup = ( ( isset( $data['popup'] ) && is_array( $data['popup'] ) ) ? $data['popup'] : [] );
242
243 if ( empty( $bar ) && empty( $popup ) ) {
244 return;
245 }
246
247 if ( ! empty( $bar ) && 'bar' === $type ) {
248 return $bar;
249 }
250
251 if ( ! empty( $barnt ) && 'barnt' === $type ) {
252 return $barnt;
253 }
254
255 if ( ! empty( $popup ) && 'popup' === $type ) {
256 return $popup;
257 }
258
259 return $data;
260 }
261
262 /**
263 * Get offer expiry.
264 */
265 public function get_offer_expiry() {
266 $expiry = get_option( '_transient_timeout_' . $this->prefix . '_htiop_data' );
267 $expiry = ( ( false !== $expiry ) ? absint( $expiry ) : -1 );
268
269 if ( -1 < $expiry ) {
270 $expiry = ( $expiry - current_time( 'U', true ) );
271 $expiry = ( 0 < $expiry ? $expiry * 1000 : 0 );
272
273 if ( ! $expiry ) {
274 update_option( $this->prefix . '_htiop_bar', 'no' );
275 update_option( $this->prefix . '_htiop_popup', 'no' );
276 }
277 }
278
279 return $expiry;
280 }
281
282 /**
283 * Get timer expiry.
284 */
285 public function get_timer_expiry() {
286 $offer = $this->get_offer_expiry();
287 $expiry = 0;
288
289 if ( $offer ) {
290 $timer = get_option( $this->prefix . '_htiop_timer', 0 );
291 $timer = ( isset( $timer ) ? absint( $timer ) : 0 );
292
293 $current = current_time( 'U', true );
294
295 if ( $timer > $current ) {
296 $expiry = ( $timer - $current );
297 $expiry = ( 0 < $expiry ? $expiry * 1000 : 0 );
298 }
299
300 if ( ( 0 < $offer ) && ( $offer < $expiry ) ) {
301 $expiry = $offer;
302 }
303 }
304
305 return $expiry;
306 }
307
308 /**
309 * Set offer.
310 */
311 public function set_offer() {
312 if ( $this->is_pro_installed() ) {
313 return;
314 }
315
316 $active = get_option( $this->prefix . '_htiop', 'yes' );
317 $active = 'yes' === $active ? true : false;
318
319 if ( $active ) {
320 update_option( $this->prefix . '_htiop', 'no' );
321 update_option( $this->prefix . '_htiop_bar', 'yes' );
322 update_option( $this->prefix . '_htiop_popup', 'yes' );
323 update_option( $this->prefix . '_htiop_redirect', 'yes' );
324
325 $this->start_redirect();
326 }
327 }
328
329 /**
330 * Show offer.
331 */
332 public function show_offer() {
333 if ( $this->is_pro_installed() ) {
334 return;
335 }
336
337 $bar = $this->is_show_offer_bar();
338 $popup = $this->is_show_offer_popup();
339
340 if ( $bar || $popup ) {
341 $this->set_offer_data();
342
343 add_action( 'admin_print_scripts', [ $this, 'header_script' ], 999999 );
344 add_action( 'admin_print_footer_scripts', [ $this, 'footer_script' ], 999999 );
345 }
346
347 if ( $bar ) {
348 add_action( 'admin_notices', [ $this, 'show_offer_bar' ], 999999 );
349 }
350
351 if ( $popup ) {
352 add_action( 'admin_footer', [ $this, 'show_offer_popup' ], 999999 );
353 add_action( 'admin_footer', [ $this, 'dismiss_redirect' ], 999999 );
354 }
355 }
356
357 /**
358 * Show offer bar.
359 */
360 public function show_offer_bar() {
361 if ( ! $this->is_plugin_screen() ) {
362 return;
363 }
364
365 $timer = $this->get_timer_expiry();
366 $data = $timer ? $this->get_offer_data( 'bar' ) : $this->get_offer_data( 'barnt' );
367
368 if ( ! is_array( $data ) || empty( $data ) ) {
369 return;
370 }
371
372 $style = isset( $data['style'] ) ? $data['style'] : '';
373 $content = isset( $data['content'] ) ? $data['content'] : '';
374
375 if ( empty( $content ) ) {
376 return;
377 }
378
379 if ( ! empty( $style ) ) { ?><style type="text/css"><?php echo esc_html( $style ); ?></style><?php }
380 echo wp_kses_post( $content );
381 }
382
383 /**
384 * Show offer popup.
385 */
386 public function show_offer_popup() {
387 if ( ! $this->is_plugin_screen() ) {
388 return;
389 }
390
391 $data = $this->get_offer_data( 'popup' );
392
393 if ( ! is_array( $data ) || empty( $data ) ) {
394 return;
395 }
396
397 $style = isset( $data['style'] ) ? $data['style'] : '';
398 $content = isset( $data['content'] ) ? $data['content'] : '';
399
400 if ( empty( $content ) ) {
401 return;
402 }
403
404 update_option( $this->prefix . '_htiop_popup', 'no' );
405 ?>
406 <div id="htiop-popup-inner" class="htiop-popup-inner">
407 <div class="htiop-popup-wrap">
408 <div class="htiop-popup-base">
409 <div class="htiop-popup-close">
410 <span class="dashicons dashicons-no-alt"></span>
411 </div>
412 <?php
413 if ( ! empty( $style ) ) { ?><style type="text/css"><?php echo esc_html( $style ); ?></style><?php }
414 echo wp_kses_post( $content );
415 ?>
416 </div>
417 </div>
418 </div>
419 <?php
420 }
421
422 /**
423 * Header script.
424 */
425 public function header_script() {
426 if ( ! $this->is_plugin_screen() ) {
427 return;
428 }
429 ?>
430 <style>body.htiop-popup-open{overflow:hidden!important}#TB_window.htiop-popup-window #TB_title,#htiop-popup-inner{display:none!important;width:0!important;height:0!important;opacity:0!important;visibility:hidden!important;overflow:hidden!important}#TB_overlay{-webkit-transition:.5s ease-out!important;-moz-transition:.5s ease-out!important;transition:.5s ease-out!important;opacity:0!important}#TB_overlay.htiop-popup-overlay{background:#0b0b0b!important;opacity:.9!important}#TB_window.htiop-popup-window,#TB_window.htiop-popup-window #TB_ajaxContent{background-color:transparent!important;padding:0!important;margin:0!important}#TB_window #TB_ajaxContent{-webkit-transition:opacity .5s!important;-moz-transition:opacity .5s!important;transition:opacity .5s!important;opacity:0!important}#TB_window.htiop-popup-window{width:100%!important;height:100%!important;top:0!important;left:0!important;overflow:hidden auto!important;-webkit-box-shadow:none!important;-moz-box-shadow:none!important;box-shadow:none!important}#TB_window.htiop-popup-window #TB_ajaxContent{border:none!important;border-radius:0!important;width:auto!important;height:auto!important;text-align:unset!important;line-height:unset!important;overflow:hidden!important;opacity:1!important}#TB_window.htiop-popup-window #TB_ajaxContent,#TB_window.htiop-popup-window #TB_ajaxContent *,#TB_window.htiop-popup-window #TB_ajaxContent ::after,#TB_window.htiop-popup-window #TB_ajaxContent ::before{-webkit-box-sizing:border-box!important;-moz-box-sizing:border-box!important;box-sizing:border-box!important}#TB_window.htiop-popup-window #TB_ajaxContent p{padding:unset!important}#TB_window.htiop-popup-window #TB_ajaxContent .htiop-popup-base{position:relative!important}#TB_window.htiop-popup-window #TB_ajaxContent .htiop-popup-close{position:absolute!important;width:44px!important;height:44px!important;top:0!important;right:0!important;cursor:pointer!important;text-align:center!important}#TB_window.htiop-popup-window #TB_ajaxContent .htiop-popup-close .dashicons{display:inline-block!important;width:44px!important;height:44px!important;font-size:24px!important;line-height:44px!important;color:#333!important;opacity:.65!important}#TB_window.htiop-popup-window #TB_ajaxContent .htiop-popup-close:hover .dashicons{opacity:1!important}#TB_window.htiop-popup-window #TB_ajaxContent .htiop-popup-wrap{display:flex!important;flex-wrap:wrap!important;align-items:center!important;justify-content:center!important;min-height:100vh!important;padding:15px!important;margin:0!important}
431
432 /* Custom CSS */
433 #wpbody .htiop-bar-notice{
434 margin-bottom: 0 !important;
435 }
436 </style>
437 <?php
438 }
439
440 /**
441 * Footer script.
442 */
443 public function footer_script() {
444 if ( ! $this->is_plugin_screen() ) {
445 return;
446 }
447
448 $timerExpiry = $this->get_timer_expiry();
449 ?>
450 <script type="text/javascript">const htiopTimerExpiry = <?php echo esc_js( $timerExpiry ); ?>;</script>
451 <script type="text/javascript">!function(t){"use strict";t(document).ready(function(t){let e;!function e(){let o=t("#htiop-popup-inner"),i=o?.find(".htiop-popup-close");if(!o?.length)return;let n=setTimeout(function(){tb_show("","#TB_inline?&inlineId=htiop-popup-inner"),t("body").addClass("htiop-popup-open"),t("#TB_overlay").addClass("htiop-popup-overlay"),t("#TB_window").addClass("htiop-popup-window"),t("#TB_title").remove(),clearTimeout(n)},1e3);i.on("click",function(e){e.preventDefault(),tb_remove(),t("body").removeClass("htiop-popup-open")})}(),function e(){let o=t(".htiop-timer"),i=parseFloat(htiopTimerExpiry||0);if(!o?.length||1>i)return;let n=o?.find(".htiop-timer-days"),$=o?.find(".htiop-timer-hours"),p=o?.find(".htiop-timer-minutes"),l=o?.find(".htiop-timer-seconds"),c=setInterval(function(){let t=Math?.floor(i/864e5),e=Math?.floor(i%864e5/36e5),o=Math?.floor(i%36e5/6e4),r=Math?.floor(i%6e4/1e3);n?.text(("0"+t)?.slice(-2)),$?.text(("0"+e)?.slice(-2)),p?.text(("0"+o)?.slice(-2)),l?.text(("0"+r)?.slice(-2)),(i-=1e3)<0&&clearInterval(c)},1e3)}(),e=t(".htiop-copy"),e?.length&&e.on("click",function(e){e.preventDefault();let o=t(this),i=o.data("content"),n=o.data("copied-text"),$=o.text(),p=t('<input style="position: absolute; left: -5000px;">');try{o.append(p),p.val(i).select(),document.execCommand("copy"),p.remove(),o.text(n);let l=setTimeout(function(){o.text($),clearTimeout(l)},1e3)}catch(c){}})})}(jQuery);</script>
452 <?php
453 }
454
455 /**
456 * Header script raw.
457 */
458 public function header_script_raw() {
459 ?>
460 <style>
461 body.htiop-popup-open {
462 overflow: hidden !important;
463 }
464 #htiop-popup-inner {
465 display: none !important;
466 width: 0 !important;
467 height: 0 !important;
468 opacity: 0 !important;
469 visibility: hidden !important;
470 overflow: hidden !important;
471 }
472 #TB_overlay {
473 -webkit-transition: all 0.5s ease-out !important;
474 -moz-transition: all 0.5s ease-out !important;
475 transition: all 0.5s ease-out !important;
476 opacity: 0 !important;
477 }
478 #TB_overlay.htiop-popup-overlay {
479 background: #0b0b0b !important;
480 opacity: 0.9 !important;
481 }
482 #TB_window #TB_ajaxContent {
483 -webkit-transition: opacity 0.5s !important;
484 -moz-transition: opacity 0.5s !important;
485 transition: opacity 0.5s !important;
486 opacity: 0 !important;
487 }
488 #TB_window.htiop-popup-window {
489 background-color: transparent !important;
490 width: 100% !important;
491 height: 100% !important;
492 top: 0 !important;
493 left: 0 !important;
494 padding: 0 !important;
495 margin: 0 !important;
496 overflow: hidden auto !important;
497 -webkit-box-shadow: none !important;
498 -moz-box-shadow: none !important;
499 box-shadow: none !important;
500 }
501 #TB_window.htiop-popup-window #TB_title {
502 display: none !important;
503 width: 0 !important;
504 height: 0 !important;
505 opacity: 0 !important;
506 visibility: hidden !important;
507 overflow: hidden !important;
508 }
509 #TB_window.htiop-popup-window #TB_ajaxContent {
510 background-color: transparent !important;
511 border: none !important;
512 border-radius: 0 !important;
513 width: auto !important;
514 height: auto !important;
515 padding: 0 !important;
516 margin: 0 !important;
517 text-align: unset !important;
518 line-height: unset !important;
519 overflow: hidden !important;
520 opacity: 1 !important;
521 }
522 #TB_window.htiop-popup-window #TB_ajaxContent,
523 #TB_window.htiop-popup-window #TB_ajaxContent *,
524 #TB_window.htiop-popup-window #TB_ajaxContent *::before,
525 #TB_window.htiop-popup-window #TB_ajaxContent *::after {
526 -webkit-box-sizing: border-box !important;
527 -moz-box-sizing: border-box !important;
528 box-sizing: border-box !important;
529 }
530 #TB_window.htiop-popup-window #TB_ajaxContent p {
531 padding: unset !important;
532 }
533 #TB_window.htiop-popup-window #TB_ajaxContent .htiop-popup-base {
534 position: relative !important;
535 }
536 #TB_window.htiop-popup-window #TB_ajaxContent .htiop-popup-close {
537 position: absolute !important;
538 width: 44px !important;
539 height: 44px !important;
540 top: 0 !important;
541 right: 0 !important;
542 cursor: pointer !important;
543 text-align: center !important;
544 }
545 #TB_window.htiop-popup-window #TB_ajaxContent .htiop-popup-close .dashicons {
546 display: inline-block !important;
547 width: 44px !important;
548 height: 44px !important;
549 font-size: 24px !important;
550 line-height: 44px !important;
551 color: #333 !important;
552 opacity: 0.65 !important
553 }
554 #TB_window.htiop-popup-window #TB_ajaxContent .htiop-popup-close:hover .dashicons {
555 opacity: 1 !important
556 }
557 #TB_window.htiop-popup-window #TB_ajaxContent .htiop-popup-wrap {
558 display: flex !important;
559 flex-wrap: wrap !important;
560 align-items: center !important;
561 justify-content: center !important;
562 min-height: 100vh !important;
563 padding: 15px !important;
564 margin: 0 !important;
565 }
566 </style>
567 <?php
568 }
569
570 /**
571 * Footer script raw.
572 */
573 public function footer_script_raw() {
574 if ( ! $this->is_plugin_screen() ) {
575 return;
576 }
577
578 $timerExpiry = $this->get_timer_expiry();
579 ?>
580 <script type="text/javascript">const htiopTimerExpiry = <?php echo esc_js( $timerExpiry ); ?>;</script>
581 <script type="text/javascript">
582 (function ($) {
583 "use strict";
584
585 $(document).ready(function ($) {
586 /**
587 * Activate popup.
588 */
589 function activatePopup() {
590 let $popup = $('#htiop-popup-inner');
591 let $close = $popup?.find('.htiop-popup-close');
592
593 if (!$popup?.length) {
594 return;
595 }
596
597 let timeout = setTimeout(function () {
598 tb_show( '', '#TB_inline?&inlineId=htiop-popup-inner' );
599
600 $( 'body' ).addClass( 'htiop-popup-open' );
601 $( '#TB_overlay' ).addClass( 'htiop-popup-overlay' );
602 $( '#TB_window' ).addClass( 'htiop-popup-window' );
603 $( '#TB_title' ).remove();
604
605 clearTimeout(timeout);
606 }, 1000);
607
608 $close.on( 'click', function ( e ) {
609 e.preventDefault();
610
611 tb_remove();
612
613 $( 'body' ).removeClass( 'htiop-popup-open' );
614 });
615 }
616
617 /**
618 * Activate timer.
619 */
620 function activateTimer() {
621 let $timer = $('.htiop-timer');
622 let timeout = parseFloat(htiopTimerExpiry || 0);
623
624 if (!$timer?.length || 1 > timeout) {
625 return;
626 }
627
628 let $days = $timer?.find('.htiop-timer-days');
629 let $hours = $timer?.find('.htiop-timer-hours');
630 let $minutes = $timer?.find('.htiop-timer-minutes');
631 let $seconds = $timer?.find('.htiop-timer-seconds');
632
633 let interval = setInterval(function () {
634 let days = Math?.floor(timeout / (1000 * 60 * 60 * 24));
635 let hours = Math?.floor((timeout % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
636 let minutes = Math?.floor((timeout % (1000 * 60 * 60)) / (1000 * 60));
637 let seconds = Math?.floor((timeout % (1000 * 60)) / 1000);
638
639 $days?.text(("0" + days)?.slice(-2));
640 $hours?.text(("0" + hours)?.slice(-2));
641 $minutes?.text(("0" + minutes)?.slice(-2));
642 $seconds?.text(("0" + seconds)?.slice(-2));
643
644 timeout = timeout - 1000;
645
646 if (timeout < 0) {
647 clearInterval(interval);
648 }
649 }, 1000);
650 }
651
652 /**
653 * Activate copy.
654 */
655 function activateCopy() {
656 let $button = $('.htiop-copy');
657
658 if (!$button?.length) {
659 return;
660 }
661
662 $button.on("click", function (e) {
663 e.preventDefault();
664
665 let $this = $(this);
666 let content = $this.data("content");
667 let copied = $this.data("copied-text");
668 let text = $this.text();
669 let $temp = $('<input style="position: absolute; left: -5000px;">');
670
671 try {
672 $this.append($temp);
673 $temp.val(content).select();
674 document.execCommand('copy');
675 $temp.remove();
676 $this.text(copied);
677
678 let timeout = setTimeout(function () {
679 $this.text(text);
680 clearTimeout(timeout);
681 }, 1000);
682 } catch (e) {}
683 });
684 }
685
686 activatePopup();
687 activateTimer();
688 activateCopy();
689 });
690 })(jQuery);
691 </script>
692 <?php
693 }
694
695 /**
696 * Start redirect.
697 */
698 public function start_redirect() {
699 $redirect = get_option( $this->prefix . '_htiop_redirect' );
700 $redirect = 'yes' === $redirect ? true : false;
701
702 if ( $redirect ) {
703 wp_safe_redirect( $this->initial_page );
704 exit();
705 }
706 }
707
708 /**
709 * Dismiss redirect.
710 */
711 public function dismiss_redirect() {
712 update_option( $this->prefix . '_htiop_redirect', 'no' );
713 }
714
715 }
716
717 // Create instance.
718 Pixelavo_Trial::get_instance();
719 }