PluginProbe
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder / 1.4.3
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder v1.4.3
3.6.0 3.5.0 trunk 1.0.10 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.6.1 1.0.7 1.0.8 1.0.9 1.1 1.1.1 1.2 1.3 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5 1.5.1 All 110 releases
buttonizer-multifunctional-button / freemius / templates / checkout.php

checkout.php in Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder 1.4.3, at freemius/templates/checkout.php

321 lines 10.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package Freemius
4 * @copyright Copyright (c) 2015, Freemius, Inc.
5 * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6 * @since 1.0.3
7 */
8
9 /**
10 * Note for WordPress.org Theme/Plugin reviewer:
11 * Freemius is an SDK for plugin and theme developers. Since the core
12 * of the SDK is relevant both for plugins and themes, for obvious reasons,
13 * we only develop and maintain one code base.
14 *
15 * This code (and page) will not run for wp.org themes (only plugins).
16 *
17 * In addition, this page loads an i-frame. We intentionally named it 'frame'
18 * so it will pass the "Theme Check" that is looking for the string "i" . "frame".
19 *
20 * UPDATE:
21 * After ongoing conversations with the WordPress.org TRT we received
22 * an official approval for including i-frames in the theme's WP Admin setting's
23 * page tab (the SDK will never add any i-frames on the sitefront). i-frames
24 * were never against the guidelines, but we wanted to get the team's blessings
25 * before we move forward. For the record, I got the final approval from
26 * Ulrich Pogson (@grapplerulrich), a team lead at the TRT during WordCamp
27 * Europe 2017 (June 16th, 2017).
28 *
29 * If you have any questions or need clarifications, please don't hesitate
30 * pinging me on slack, my username is @svovaf.
31 *
32 * @author Vova Feldman (@svovaf)
33 * @since 1.2.2
34 */
35
36 if ( ! defined( 'ABSPATH' ) ) {
37 exit;
38 }
39
40 wp_enqueue_script( 'jquery' );
41 wp_enqueue_script( 'json2' );
42 fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
43 fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
44 fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
45
46 fs_enqueue_local_style( 'fs_checkout', '/admin/checkout.css' );
47
48 /**
49 * @var array $VARS
50 * @var Freemius $fs
51 */
52 $fs = freemius( $VARS['id'] );
53 $slug = $fs->get_slug();
54
55 $timestamp = time();
56
57 $context_params = array(
58 'plugin_id' => $fs->get_id(),
59 'public_key' => $fs->get_public_key(),
60 'plugin_version' => $fs->get_plugin_version(),
61 'mode' => 'dashboard',
62 'trial' => fs_request_get_bool( 'trial' ),
63 );
64
65 $plan_id = fs_request_get( 'plan_id' );
66 if ( FS_Plugin_Plan::is_valid_id( $plan_id ) ) {
67 $context_params['plan_id'] = $plan_id;
68 }
69
70 $licenses = fs_request_get( 'licenses' );
71 if ( $licenses === strval( intval( $licenses ) ) && $licenses > 0 ) {
72 $context_params['licenses'] = $licenses;
73 }
74
75 $plugin_id = fs_request_get( 'plugin_id' );
76 if ( ! FS_Plugin::is_valid_id( $plugin_id ) ) {
77 $plugin_id = $fs->get_id();
78 }
79
80 if ( $plugin_id == $fs->get_id() ) {
81 $is_premium = $fs->is_premium();
82 } else {
83 // Identify the module code version of the checkout context module.
84 if ( $fs->is_addon_activated( $plugin_id ) ) {
85 $fs_addon = Freemius::get_instance_by_id( $plugin_id );
86 $is_premium = $fs_addon->is_premium();
87 } else {
88 // If add-on isn't activated assume the premium version isn't installed.
89 $is_premium = false;
90 }
91 }
92
93 // Get site context secure params.
94 if ( $fs->is_registered() ) {
95 $site = $fs->get_site();
96
97 if ( $plugin_id != $fs->get_id() ) {
98 if ( $fs->is_addon_activated( $plugin_id ) ) {
99 $fs_addon = Freemius::get_instance_by_id( $plugin_id );
100 $site = $fs_addon->get_site();
101 }
102 }
103
104 $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
105 $site,
106 $timestamp,
107 'checkout'
108 ) );
109 } else {
110 $current_user = Freemius::_get_current_wp_user();
111
112 // Add site and user info to the request, this information
113 // is NOT being stored unless the user complete the purchase
114 // and agrees to the TOS.
115 $context_params = array_merge( $context_params, array(
116 'user_firstname' => $current_user->user_firstname,
117 'user_lastname' => $current_user->user_lastname,
118 'user_email' => $current_user->user_email,
119 'home_url' => home_url(),
120 ) );
121
122 $fs_user = Freemius::_get_user_by_email( $current_user->user_email );
123
124 if ( is_object( $fs_user ) ) {
125 $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
126 $fs_user,
127 $timestamp,
128 'checkout'
129 ) );
130 }
131 }
132
133 if ( $fs->is_payments_sandbox() ) {
134 // Append plugin secure token for sandbox mode authentication.
135 $context_params['sandbox'] = FS_Security::instance()->get_secure_token(
136 $fs->get_plugin(),
137 $timestamp,
138 'checkout'
139 );
140
141 /**
142 * @since 1.1.7.3 Add security timestamp for sandbox even for anonymous user.
143 */
144 if ( empty( $context_params['s_ctx_ts'] ) ) {
145 $context_params['s_ctx_ts'] = $timestamp;
146 }
147 }
148
149 $return_url = $fs->_get_sync_license_url( $plugin_id );
150
151 $query_params = array_merge( $context_params, $_GET, array(
152 // Current plugin version.
153 'plugin_version' => $fs->get_plugin_version(),
154 'sdk_version' => WP_FS__SDK_VERSION,
155 'is_premium' => $is_premium ? 'true' : 'false',
156 'return_url' => $return_url,
157 // Admin CSS URL for style/design competability.
158 // 'wp_admin_css' => get_bloginfo('wpurl') . "/wp-admin/load-styles.php?c=1&load=buttons,wp-admin,dashicons",
159 ) );
160
161 $xdebug_session = fs_request_get( 'XDEBUG_SESSION' );
162 if ( false !== $xdebug_session ) {
163 $query_params['XDEBUG_SESSION'] = $xdebug_session;
164 }
165
166 $view_params = array(
167 'id' => $VARS['id'],
168 'page' => strtolower( $fs->get_text_inline( 'Checkout', 'checkout' ) ) . ' ' . $fs->get_text_inline( 'PCI compliant', 'pci-compliant' ),
169 );
170 fs_require_once_template('secure-https-header.php', $view_params);
171 ?>
172 <div id="fs_checkout" class="wrap fs-section fs-full-size-wrapper">
173 <div id="frame"></div>
174 <script type="text/javascript">
175 // http://stackoverflow.com/questions/4583703/jquery-post-request-not-ajax
176 jQuery(function ($) {
177 $.extend({
178 form: function (url, data, method) {
179 if (method == null) method = 'POST';
180 if (data == null) data = {};
181
182 var form = $('<form>').attr({
183 method: method,
184 action: url
185 }).css({
186 display: 'none'
187 });
188
189 var addData = function (name, data) {
190 if ($.isArray(data)) {
191 for (var i = 0; i < data.length; i++) {
192 var value = data[i];
193 addData(name + '[]', value);
194 }
195 } else if (typeof data === 'object') {
196 for (var key in data) {
197 if (data.hasOwnProperty(key)) {
198 addData(name + '[' + key + ']', data[key]);
199 }
200 }
201 } else if (data != null) {
202 form.append($('<input>').attr({
203 type : 'hidden',
204 name : String(name),
205 value: String(data)
206 }));
207 }
208 };
209
210 for (var key in data) {
211 if (data.hasOwnProperty(key)) {
212 addData(key, data[key]);
213 }
214 }
215
216 return form.appendTo('body');
217 }
218 });
219 });
220
221 (function ($) {
222 $(function () {
223
224 var
225 // Keep track of the i-frame height.
226 frame_height = 800,
227 base_url = '<?php echo FS_CHECKOUT__ADDRESS ?>',
228 // Pass the parent page URL into the i-frame in a meaningful way (this URL could be
229 // passed via query string or hard coded into the child page, it depends on your needs).
230 src = base_url + '/?<?php echo http_build_query( $query_params ) ?>#' + encodeURIComponent(document.location.href),
231 // Append the i-frame into the DOM.
232 frame = $('<i' + 'frame " src="' + src + '" width="100%" height="' + frame_height + 'px" scrolling="no" frameborder="0" style="background: transparent;"><\/i' + 'frame>')
233 .appendTo('#frame');
234
235 FS.PostMessage.init(base_url, [frame[0]]);
236 FS.PostMessage.receiveOnce('height', function (data) {
237 var h = data.height;
238 if (!isNaN(h) && h > 0 && h != frame_height) {
239 frame_height = h;
240 frame.height(frame_height + 'px');
241
242 FS.PostMessage.postScroll(frame[0]);
243 }
244 });
245
246 FS.PostMessage.receiveOnce('install', function (data) {
247 var requestData = {
248 user_id : data.user.id,
249 user_secret_key : data.user.secret_key,
250 user_public_key : data.user.public_key,
251 install_id : data.install.id,
252 install_secret_key: data.install.secret_key,
253 install_public_key: data.install.public_key
254 };
255
256 if (true === data.auto_install)
257 requestData.auto_install = true;
258
259 // Post data to activation URL.
260 $.form('<?php echo fs_nonce_url( $fs->_get_admin_page_url( 'account', array(
261 'fs_action' => $fs->get_unique_affix() . '_activate_new',
262 'plugin_id' => $plugin_id
263 ) ), $fs->get_unique_affix() . '_activate_new' ) ?>', requestData).submit();
264 });
265
266 FS.PostMessage.receiveOnce('pending_activation', function (data) {
267 var requestData = {
268 user_email: data.user_email
269 };
270
271 if (true === data.auto_install)
272 requestData.auto_install = true;
273
274 $.form('<?php echo fs_nonce_url( $fs->_get_admin_page_url( 'account', array(
275 'fs_action' => $fs->get_unique_affix() . '_activate_new',
276 'plugin_id' => $plugin_id,
277 'pending_activation' => true,
278 ) ), $fs->get_unique_affix() . '_activate_new' ) ?>', requestData).submit();
279 });
280
281 FS.PostMessage.receiveOnce('get_context', function () {
282 console.debug('receiveOnce', 'get_context');
283
284 // If the user didn't connect his account with Freemius,
285 // once he accepts the Terms of Service and Privacy Policy,
286 // and then click the purchase button, the context information
287 // of the user will be shared with Freemius in order to complete the
288 // purchase workflow and activate the license for the right user.
289 <?php $install_data = array_merge( $fs->get_opt_in_params(),
290 array(
291 'activation_url' => fs_nonce_url( $fs->_get_admin_page_url( '',
292 array(
293 'fs_action' => $fs->get_unique_affix() . '_activate_new',
294 'plugin_id' => $plugin_id,
295
296 ) ),
297 $fs->get_unique_affix() . '_activate_new' )
298 ) ) ?>
299 FS.PostMessage.post('context', <?php echo json_encode( $install_data ) ?>, frame[0]);
300 });
301
302 FS.PostMessage.receiveOnce('get_dimensions', function (data) {
303 console.debug('receiveOnce', 'get_dimensions');
304
305 FS.PostMessage.post('dimensions', {
306 height : $(document.body).height(),
307 scrollTop: $(document).scrollTop()
308 }, frame[0]);
309 });
310
311 var updateHeight = function () {
312 frame.css('min-height', $(document.body).height() + 'px');
313 };
314
315 $(document).ready(updateHeight);
316
317 $(window).resize(updateHeight);
318 });
319 })(jQuery);
320 </script>
321 </div>