PluginProbe ʕ •ᴥ•ʔ
Gallery : FooGallery / 3.1.36
Gallery : FooGallery v3.1.36
3.3.2 3.3.3 3.3.0 3.1.31 3.1.32 3.1.34 3.1.36 3.2.0 3.2.6 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 2 months ago process-redirect.php 2 months ago redirect.php 2 months ago
process-redirect.php
129 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 fs_enqueue_local_script( 'fs-form', 'jquery.form.js', array( 'jquery' ) );
29
30 $action = fs_request_get( '_fs_checkout_action' );
31 $data = json_decode( fs_request_get_raw( '_fs_checkout_data' ) );
32 ?>
33 <div class="fs-checkout-process-redirect">
34 <div class="fs-checkout-process-redirect__loader">
35 <?php fs_include_template( 'ajax-loader.php' ); ?>
36 </div>
37
38 <div class="fs-checkout-process-redirect__content">
39 <p>
40 <?php echo esc_html( fs_text_inline( 'Processing, please wait and do not close or refresh this window...' ) ); ?>
41 </p>
42 </div>
43 </div>
44
45 <script type="text/javascript">
46 jQuery(function ($) {
47 var $loader = $( '.fs-checkout-process-redirect .fs-ajax-loader' ),
48 action = <?php echo wp_json_encode( $action ); ?>,
49 data = <?php echo wp_json_encode( $data ); ?>;
50
51 $loader.show();
52
53 // This remains compatible with the same filter in /templates/checkout/frame.php.
54 // You can return a promise to make the successive redirection wait until your own processing is completed.
55 // However for most cases, we recommend sending a beacon request {https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon}
56 var processPurchaseEvent = (<?php echo $fs->apply_filters('checkout/purchaseCompleted', 'function (data) {
57 console.log("checkout", "purchaseCompleted");
58 }'); ?>)(data.purchaseData);
59
60 if (typeof Promise !== 'undefined' && processPurchaseEvent instanceof Promise) {
61 processPurchaseEvent.finally(function () {
62 finishProcessing(action, data);
63 });
64 } else {
65 finishProcessing(action, data);
66 }
67
68 function finishProcessing(action, data) {
69 switch ( action ) {
70 case 'install':
71 processInstall( data );
72 break;
73 case 'pending_activation':
74 processPendingActivation( data );
75 break;
76 case 'return_without_sync':
77 goToAccount();
78 break;
79 default:
80 syncLicense( data );
81 break;
82 }
83 }
84
85 function processInstall( data ) {
86 var requestData = {
87 user_id : data.user.id,
88 user_secret_key : data.user.secret_key,
89 user_public_key : data.user.public_key,
90 install_id : data.install.id,
91 install_secret_key: data.install.secret_key,
92 install_public_key: data.install.public_key
93 };
94
95 if ( true === data.auto_install )
96 requestData.auto_install = true;
97
98 // Post data to activation URL.
99 $.form( '<?php echo $fs_checkout->get_install_url( $fs, $plugin_id ); ?>', requestData ).submit();
100 }
101
102 function processPendingActivation( data ) {
103 var requestData = {
104 user_email : data.user_email,
105 support_email_address: data.support_email_address
106 };
107
108 if ( true === data.auto_install )
109 requestData.auto_install = true;
110
111 $.form( '<?php echo $fs_checkout->get_pending_activation_url( $fs, $plugin_id ); ?>', requestData ).submit();
112 }
113
114 function syncLicense(data) {
115 var redirectUrl = new URL( <?php echo wp_json_encode( $fs->_get_sync_license_url( $plugin_id ) ); ?> );
116
117 if (true === data.auto_install) {
118 redirectUrl.searchParams.set( 'auto_install', 'true' );
119 }
120
121 window.location.href = redirectUrl.toString();
122 }
123
124 function goToAccount() {
125 window.location.href = <?php echo wp_json_encode( $fs->get_account_url() ) ?>;
126 }
127 });
128 </script>
129