PluginProbe ʕ •ᴥ•ʔ
Photo Gallery by FooGallery : Responsive Image Gallery, Masonry Gallery & Carousel / trunk
Photo Gallery by FooGallery : Responsive Image Gallery, Masonry Gallery & Carousel vtrunk
trunk 1.10.3 2.0.24 2.1.34 2.2.44 2.3.3 2.4.32 3.0.6 3.1.11 3.1.12 3.1.13 3.1.20 3.1.25 3.1.26 3.1.26.1 3.1.26.2
foogallery / freemius / templates / checkout / process-redirect.php
foogallery / freemius / templates / checkout Last commit date
frame.php 7 months ago process-redirect.php 7 months ago redirect.php 7 months ago
process-redirect.php
130 lines
1 <?php
2 /**
3 * @package Freemius
4 * @copyright Copyright (c) 2024, Freemius, Inc.
5 * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6 * @since 2.9.0
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * @var array $VARS
15 * @var Freemius $fs
16 */
17 $fs = freemius( $VARS['id'] );
18 $fs_checkout = FS_Checkout_Manager::instance();
19
20 $plugin_id = fs_request_get( 'plugin_id' );
21 if ( ! FS_Plugin::is_valid_id( $plugin_id ) ) {
22 $plugin_id = $fs->get_id();
23 }
24
25 $fs_checkout->verify_checkout_redirect_nonce( $fs );
26
27 wp_enqueue_script( 'jquery' );
28 wp_enqueue_script( 'json2' );
29 fs_enqueue_local_script( 'fs-form', 'jquery.form.js', array( 'jquery' ) );
30
31 $action = fs_request_get( '_fs_checkout_action' );
32 $data = json_decode( fs_request_get_raw( '_fs_checkout_data' ) );
33 ?>
34 <div class="fs-checkout-process-redirect">
35 <div class="fs-checkout-process-redirect__loader">
36 <?php fs_include_template( 'ajax-loader.php' ); ?>
37 </div>
38
39 <div class="fs-checkout-process-redirect__content">
40 <p>
41 <?php echo esc_html( fs_text_inline( 'Processing, please wait and do not close or refresh this window...' ) ); ?>
42 </p>
43 </div>
44 </div>
45
46 <script type="text/javascript">
47 jQuery(function ($) {
48 var $loader = $( '.fs-checkout-process-redirect .fs-ajax-loader' ),
49 action = <?php echo wp_json_encode( $action ); ?>,
50 data = <?php echo wp_json_encode( $data ); ?>;
51
52 $loader.show();
53
54 // This remains compatible with the same filter in /templates/checkout/frame.php.
55 // You can return a promise to make the successive redirection wait until your own processing is completed.
56 // However for most cases, we recommend sending a beacon request {https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon}
57 var processPurchaseEvent = (<?php echo $fs->apply_filters('checkout/purchaseCompleted', 'function (data) {
58 console.log("checkout", "purchaseCompleted");
59 }'); ?>)(data.purchaseData);
60
61 if (typeof Promise !== 'undefined' && processPurchaseEvent instanceof Promise) {
62 processPurchaseEvent.finally(function () {
63 finishProcessing(action, data);
64 });
65 } else {
66 finishProcessing(action, data);
67 }
68
69 function finishProcessing(action, data) {
70 switch ( action ) {
71 case 'install':
72 processInstall( data );
73 break;
74 case 'pending_activation':
75 processPendingActivation( data );
76 break;
77 case 'return_without_sync':
78 goToAccount();
79 break;
80 default:
81 syncLicense( data );
82 break;
83 }
84 }
85
86 function processInstall( data ) {
87 var requestData = {
88 user_id : data.user.id,
89 user_secret_key : data.user.secret_key,
90 user_public_key : data.user.public_key,
91 install_id : data.install.id,
92 install_secret_key: data.install.secret_key,
93 install_public_key: data.install.public_key
94 };
95
96 if ( true === data.auto_install )
97 requestData.auto_install = true;
98
99 // Post data to activation URL.
100 $.form( '<?php echo $fs_checkout->get_install_url( $fs, $plugin_id ); ?>', requestData ).submit();
101 }
102
103 function processPendingActivation( data ) {
104 var requestData = {
105 user_email : data.user_email,
106 support_email_address: data.support_email_address
107 };
108
109 if ( true === data.auto_install )
110 requestData.auto_install = true;
111
112 $.form( '<?php echo $fs_checkout->get_pending_activation_url( $fs, $plugin_id ); ?>', requestData ).submit();
113 }
114
115 function syncLicense(data) {
116 var redirectUrl = new URL( <?php echo wp_json_encode( $fs->_get_sync_license_url( $plugin_id ) ); ?> );
117
118 if (true === data.auto_install) {
119 redirectUrl.searchParams.set( 'auto_install', 'true' );
120 }
121
122 window.location.href = redirectUrl.toString();
123 }
124
125 function goToAccount() {
126 window.location.href = <?php echo wp_json_encode( $fs->get_account_url() ) ?>;
127 }
128 });
129 </script>
130