PluginProbe ʕ •ᴥ•ʔ
Image Widget / 4.2
Image Widget v4.2
trunk 1.0 2.0 2.1 2.2 2.2.1 2.2.2 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.2 3.2.1 3.2.10 3.2.11 3.2.2 3.2.3 3.2.4 3.2.5 3.2.7 3.2.8 3.2.9 3.3 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 4.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1 4.1.1 4.1.2 4.2 4.2.1 4.2.2 4.3 4.3.1 4.4 4.4.1 4.4.11 4.4.12 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9
image-widget / freemius / templates / checkout.php
image-widget / freemius / templates Last commit date
plugin-info 10 years ago account.php 10 years ago add-ons.php 10 years ago admin-notice.php 10 years ago all-admin-notice.php 10 years ago checkout.php 10 years ago connect.php 10 years ago contact.php 10 years ago deactivation-feedback-modal.php 10 years ago debug.php 10 years ago email.php 10 years ago firewall-issues-js.php 10 years ago pending-activation.php 10 years ago plugin-icon.php 10 years ago powered-by.php 10 years ago pricing.php 10 years ago sticky-admin-notice-js.php 10 years ago
checkout.php
242 lines
1 <?php
2 /**
3 * @package Freemius
4 * @copyright Copyright (c) 2015, Freemius, Inc.
5 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6 * @since 1.0.3
7 */
8
9 wp_enqueue_script( 'jquery' );
10 wp_enqueue_script( 'json2' );
11 fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
12 fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
13 fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
14
15 $slug = $VARS['slug'];
16 $fs = freemius( $slug );
17
18 $timestamp = time();
19
20 $context_params = array(
21 'plugin_id' => $fs->get_id(),
22 'plugin_public_key' => $fs->get_public_key(),
23 'plugin_version' => $fs->get_plugin_version(),
24 );
25
26 // Get site context secure params.
27 if ( $fs->is_registered() ) {
28 $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
29 $fs->get_site(),
30 $timestamp,
31 'checkout'
32 ) );
33 } else {
34 $current_user = wp_get_current_user();
35
36 // Add site and user info to the request, this information
37 // is NOT being stored unless the user complete the purchase
38 // and agrees to the TOS.
39 $context_params = array_merge( $context_params, array(
40 'user_firstname' => $current_user->user_firstname,
41 'user_lastname' => $current_user->user_lastname,
42 'user_email' => $current_user->user_email,
43 // 'user_nickname' => $current_user->user_nicename,
44 // 'plugin_slug' => $slug,
45 // 'site_url' => get_site_url(),
46 // 'site_name' => get_bloginfo( 'name' ),
47 // 'platform_version' => get_bloginfo( 'version' ),
48 // 'language' => get_bloginfo( 'language' ),
49 // 'charset' => get_bloginfo( 'charset' ),
50 // 'account_url' => fs_nonce_url( $fs->_get_admin_page_url(
51 // 'account',
52 // array( 'fs_action' => 'sync_user' )
53 // ), 'sync_user' ),
54 ) );
55
56 $fs_user = Freemius::_get_user_by_email( $current_user->user_email );
57
58 if ( is_object( $fs_user ) ) {
59 $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
60 $fs_user,
61 $timestamp,
62 'checkout'
63 ) );
64 }
65 }
66
67 if ( $fs->is_payments_sandbox() ) // Append plugin secure token for sandbox mode authentication.)
68 {
69 $context_params['sandbox'] = FS_Security::instance()->get_secure_token(
70 $fs->get_plugin(),
71 $timestamp,
72 'checkout'
73 );
74 }
75
76 $return_url = fs_nonce_url( $fs->_get_admin_page_url(
77 'account',
78 array(
79 'fs_action' => $slug . '_sync_license',
80 'plugin_id' => isset( $_GET['plugin_id'] ) ? $_GET['plugin_id'] : $fs->get_id()
81 )
82 ), $slug . '_sync_license' );
83
84 $query_params = array_merge( $context_params, $_GET, array(
85 // Current plugin version.
86 'plugin_version' => $fs->get_plugin_version(),
87 'return_url' => $return_url,
88 // Admin CSS URL for style/design competability.
89 // 'wp_admin_css' => get_bloginfo('wpurl') . "/wp-admin/load-styles.php?c=1&load=buttons,wp-admin,dashicons",
90 ) );
91 ?>
92 <div class="fs-secure-notice">
93 <i class="dashicons dashicons-lock"></i>
94 <span><b>Secure HTTPS Checkout</b> - PCI compliant, running via iframe from external domain</span>
95 </div>
96 <div id="fs_contact" class="wrap" style="margin: 40px 0 -65px -20px;">
97 <div id="iframe"></div>
98 <script type="text/javascript">
99 // http://stackoverflow.com/questions/4583703/jquery-post-request-not-ajax
100 jQuery(function ($) {
101 $.extend({
102 form: function (url, data, method) {
103 if (method == null) method = 'POST';
104 if (data == null) data = {};
105
106 var form = $('<form>').attr({
107 method: method,
108 action: url
109 }).css({
110 display: 'none'
111 });
112
113 var addData = function (name, data) {
114 if ($.isArray(data)) {
115 for (var i = 0; i < data.length; i++) {
116 var value = data[i];
117 addData(name + '[]', value);
118 }
119 } else if (typeof data === 'object') {
120 for (var key in data) {
121 if (data.hasOwnProperty(key)) {
122 addData(name + '[' + key + ']', data[key]);
123 }
124 }
125 } else if (data != null) {
126 form.append($('<input>').attr({
127 type : 'hidden',
128 name : String(name),
129 value: String(data)
130 }));
131 }
132 };
133
134 for (var key in data) {
135 if (data.hasOwnProperty(key)) {
136 addData(key, data[key]);
137 }
138 }
139
140 return form.appendTo('body');
141 }
142 });
143 });
144
145 (function ($) {
146 $(function () {
147
148 var
149 // Keep track of the iframe height.
150 iframe_height = 800,
151 base_url = '<?php echo WP_FS__ADDRESS ?>',
152 // Pass the parent page URL into the Iframe in a meaningful way (this URL could be
153 // passed via query string or hard coded into the child page, it depends on your needs).
154 src = base_url + '/checkout/?<?php echo (isset($_REQUEST['XDEBUG_SESSION']) ? 'XDEBUG_SESSION=' . $_REQUEST['XDEBUG_SESSION'] . '&' : '') . http_build_query($query_params) ?>#' + encodeURIComponent(document.location.href),
155
156 // Append the Iframe into the DOM.
157 iframe = $('<iframe " src="' + src + '" width="100%" height="' + iframe_height + 'px" scrolling="no" frameborder="0" style="background: transparent;"><\/iframe>')
158 .appendTo('#iframe');
159
160 FS.PostMessage.init(base_url);
161 FS.PostMessage.receiveOnce('height', function (data) {
162 var h = data.height;
163 if (!isNaN(h) && h > 0 && h != iframe_height) {
164 iframe_height = h;
165 $("#iframe iframe").height(iframe_height + 'px');
166 }
167 });
168
169 FS.PostMessage.receiveOnce('install', function (data) {
170 // Post data to activation URL.
171 $.form('<?php echo fs_nonce_url($fs->_get_admin_page_url('account', array(
172 'fs_action' => $slug . '_activate_new',
173 'plugin_id' => isset($_GET['plugin_id']) ? $_GET['plugin_id'] : $fs->get_id()
174 )), $slug . '_activate_new') ?>', {
175 user_id : data.user.id,
176 user_secret_key : data.user.secret_key,
177 user_public_key : data.user.public_key,
178 install_id : data.install.id,
179 install_secret_key: data.install.secret_key,
180 install_public_key: data.install.public_key
181 }).submit();
182 });
183
184 FS.PostMessage.receiveOnce('pending_activation', function (data) {
185 $.form('<?php echo fs_nonce_url($fs->_get_admin_page_url('account', array(
186 'fs_action' => $slug . '_activate_new',
187 'plugin_id' => fs_request_get('plugin_id', $fs->get_id()),
188 'pending_activation' => true,
189 )), $slug . '_activate_new') ?>', {
190 user_email: data.user_email
191 }).submit();
192 });
193
194 FS.PostMessage.receiveOnce('get_context', function () {
195 console.debug('receiveOnce', 'get_context');
196
197 // If the user didn't connect his account with Freemius,
198 // once he accepts the Terms of Service and Privacy Policy,
199 // and then click the purchase button, the context information
200 // of the user will be shared with Freemius in order to complete the
201 // purchase workflow and activate the license for the right user.
202 <?php $current_user = wp_get_current_user() ?>
203 FS.PostMessage.post('context', {
204 // user_firstname: '<?php //echo $current_user->user_firstname ?>//',
205 // user_lastname: '<?php //echo $current_user->user_lastname ?>//',
206 // user_email: '<?php //echo $current_user->user_email ?>//'
207 plugin_id : '<?php echo $fs->get_id() ?>',
208 plugin_public_key: '<?php echo $fs->get_public_key() ?>',
209 plugin_version : '<?php echo $fs->get_plugin_version() ?>',
210 plugin_slug : '<?php echo $slug ?>',
211 site_name : '<?php echo get_bloginfo('name') ?>',
212 platform_version : '<?php echo get_bloginfo('version') ?>',
213 language : '<?php echo get_bloginfo('language') ?>',
214 charset : '<?php echo get_bloginfo('charset') ?>',
215 return_url : '<?php echo $return_url ?>',
216 account_url : '<?php echo fs_nonce_url($fs->_get_admin_page_url(
217 'account',
218 array('fs_action' => 'sync_user')
219 ), 'sync_user') ?>',
220 activation_url : '<?php echo fs_nonce_url($fs->_get_admin_page_url('',
221 array(
222 'fs_action' => $slug . '_activate_new',
223 'plugin_id' => fs_request_get('plugin_id', $fs->get_id()),
224
225 )),
226 $slug . '_activate_new') ?>'
227 }, iframe[0]);
228 });
229
230 FS.PostMessage.receiveOnce('get_dimensions', function (data) {
231 console.debug('receiveOnce', 'get_dimensions');
232
233 FS.PostMessage.post('dimensions', {
234 height : $(document.body).height(),
235 scrollTop: $(document).scrollTop()
236 }, iframe[0]);
237 });
238 });
239 })(jQuery);
240 </script>
241 </div>
242 <?php fs_require_template( 'powered-by.php' ) ?>