PluginProbe
BlockSpare – Gutenberg Blocks, AI Content Generator & Site Builder for News, Magazine & Blogs / 5.0.1
BlockSpare – Gutenberg Blocks, AI Content Generator & Site Builder for News, Magazine & Blogs v5.0.1
5.0.1 4.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.1.2 2.5.0 2.5.3 All 39 releases
← All changes | freemius/templates/checkout.php +15 -323 1.3.4 → 5.0.1 View file →
@@ -1,337 +1,29 @@
1 1 <?php
2 2 /**
3 3 * @package Freemius
4 - * @copyright Copyright (c) 2015, Freemius, Inc.
4 + * @copyright Copyright (c) 2024, Freemius, Inc.
5 5 * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6 - * @since 1.0.3
6 + * @since 2.9.0
7 7 */
8 -
8 + if ( ! defined( 'ABSPATH' ) ) {
9 + exit;
10 + }
9 11 /**
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 12 * @var array $VARS
50 13 * @var Freemius $fs
51 14 */
52 - $fs = freemius( $VARS['id'] );
53 - $slug = $fs->get_slug();
15 + $fs = freemius( $VARS['id'] );
54 16
55 - $timestamp = time();
17 + if ( fs_request_get_bool( 'redirect' ) ) {
18 + fs_require_template( 'checkout/redirect.php', $VARS );
19 + } else if ( fs_request_get_bool( 'process_redirect' ) ) {
20 + fs_require_template( 'checkout/process-redirect.php', $VARS );
21 + } else {
22 + $fs = freemius( $VARS['id'] );
56 23
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 -
83 - $bundle_id = $fs->get_bundle_id();
84 - if ( ! is_null( $bundle_id ) ) {
85 - $context_params['bundle_id'] = $bundle_id;
86 - }
87 - } else {
88 - // Identify the module code version of the checkout context module.
89 - if ( $fs->is_addon_activated( $plugin_id ) ) {
90 - $fs_addon = Freemius::get_instance_by_id( $plugin_id );
91 - $is_premium = $fs_addon->is_premium();
24 + if ( $fs->is_premium() ) {
25 + fs_require_template( 'checkout/frame.php', $VARS );
92 26 } else {
93 - // If add-on isn't activated assume the premium version isn't installed.
94 - $is_premium = false;
27 + fs_require_template( 'checkout/redirect.php', $VARS );
95 28 }
96 29 }
97 -
98 - // Get site context secure params.
99 - if ( $fs->is_registered() ) {
100 - $site = $fs->get_site();
101 -
102 - if ( $plugin_id != $fs->get_id() ) {
103 - if ( $fs->is_addon_activated( $plugin_id ) ) {
104 - $fs_addon = Freemius::get_instance_by_id( $plugin_id );
105 - $addon_site = $fs_addon->get_site();
106 - if ( is_object( $addon_site ) ) {
107 - $site = $addon_site;
108 - }
109 - }
110 - }
111 -
112 - $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
113 - $site,
114 - $timestamp,
115 - 'checkout'
116 - ) );
117 - } else {
118 - $current_user = Freemius::_get_current_wp_user();
119 -
120 - // Add site and user info to the request, this information
121 - // is NOT being stored unless the user complete the purchase
122 - // and agrees to the TOS.
123 - $context_params = array_merge( $context_params, array(
124 - 'user_firstname' => $current_user->user_firstname,
125 - 'user_lastname' => $current_user->user_lastname,
126 - 'user_email' => $current_user->user_email,
127 - 'home_url' => home_url(),
128 - ) );
129 -
130 - $fs_user = Freemius::_get_user_by_email( $current_user->user_email );
131 -
132 - if ( is_object( $fs_user ) && $fs_user->is_verified() ) {
133 - $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
134 - $fs_user,
135 - $timestamp,
136 - 'checkout'
137 - ) );
138 - }
139 - }
140 -
141 - if ( $fs->is_payments_sandbox() ) {
142 - // Append plugin secure token for sandbox mode authentication.
143 - $context_params['sandbox'] = FS_Security::instance()->get_secure_token(
144 - $fs->get_plugin(),
145 - $timestamp,
146 - 'checkout'
147 - );
148 -
149 - /**
150 - * @since 1.1.7.3 Add security timestamp for sandbox even for anonymous user.
151 - */
152 - if ( empty( $context_params['s_ctx_ts'] ) ) {
153 - $context_params['s_ctx_ts'] = $timestamp;
154 - }
155 - }
156 -
157 - $return_url = $fs->_get_sync_license_url( $plugin_id );
158 -
159 - $can_user_install = (
160 - ( $fs->is_plugin() && current_user_can( 'install_plugins' ) ) ||
161 - ( $fs->is_theme() && current_user_can( 'install_themes' ) )
162 - );
163 -
164 - $query_params = array_merge( $context_params, $_GET, array(
165 - // Current plugin version.
166 - 'plugin_version' => $fs->get_plugin_version(),
167 - 'sdk_version' => WP_FS__SDK_VERSION,
168 - 'is_premium' => $is_premium ? 'true' : 'false',
169 - 'can_install' => $can_user_install ? 'true' : 'false',
170 - 'return_url' => $return_url,
171 - ) );
172 -
173 - $xdebug_session = fs_request_get( 'XDEBUG_SESSION' );
174 - if ( false !== $xdebug_session ) {
175 - $query_params['XDEBUG_SESSION'] = $xdebug_session;
176 - }
177 -
178 - $view_params = array(
179 - 'id' => $VARS['id'],
180 - 'page' => strtolower( $fs->get_text_inline( 'Checkout', 'checkout' ) ) . ' ' . $fs->get_text_inline( 'PCI compliant', 'pci-compliant' ),
181 - );
182 - fs_require_once_template('secure-https-header.php', $view_params);
183 -?>
184 - <div id="fs_checkout" class="wrap fs-section fs-full-size-wrapper">
185 - <div id="fs_frame"></div>
186 - <script type="text/javascript">
187 - // http://stackoverflow.com/questions/4583703/jquery-post-request-not-ajax
188 - jQuery(function ($) {
189 - $.extend({
190 - form: function (url, data, method) {
191 - if (method == null) method = 'POST';
192 - if (data == null) data = {};
193 -
194 - var form = $('<form>').attr({
195 - method: method,
196 - action: url
197 - }).css({
198 - display: 'none'
199 - });
200 -
201 - var addData = function (name, data) {
202 - if ($.isArray(data)) {
203 - for (var i = 0; i < data.length; i++) {
204 - var value = data[i];
205 - addData(name + '[]', value);
206 - }
207 - } else if (typeof data === 'object') {
208 - for (var key in data) {
209 - if (data.hasOwnProperty(key)) {
210 - addData(name + '[' + key + ']', data[key]);
211 - }
212 - }
213 - } else if (data != null) {
214 - form.append($('<input>').attr({
215 - type : 'hidden',
216 - name : String(name),
217 - value: String(data)
218 - }));
219 - }
220 - };
221 -
222 - for (var key in data) {
223 - if (data.hasOwnProperty(key)) {
224 - addData(key, data[key]);
225 - }
226 - }
227 -
228 - return form.appendTo('body');
229 - }
230 - });
231 - });
232 -
233 - (function ($) {
234 - $(function () {
235 -
236 - var
237 - // Keep track of the i-frame height.
238 - frame_height = 800,
239 - base_url = '<?php echo FS_CHECKOUT__ADDRESS ?>',
240 - // Pass the parent page URL into the i-frame in a meaningful way (this URL could be
241 - // passed via query string or hard coded into the child page, it depends on your needs).
242 - src = base_url + '/?<?php echo http_build_query( $query_params ) ?>#' + encodeURIComponent(document.location.href),
243 - // Append the i-frame into the DOM.
244 - frame = $('<i' + 'frame " src="' + src + '" width="100%" height="' + frame_height + 'px" scrolling="no" frameborder="0" style="background: transparent; width: 1px; min-width: 100%;"><\/i' + 'frame>')
245 - .appendTo('#fs_frame');
246 -
247 - FS.PostMessage.init(base_url, [frame[0]]);
248 - FS.PostMessage.receiveOnce('height', function (data) {
249 - var h = data.height;
250 - if (!isNaN(h) && h > 0 && h != frame_height) {
251 - frame_height = h;
252 - frame.height(frame_height + 'px');
253 -
254 - FS.PostMessage.postScroll(frame[0]);
255 - }
256 - });
257 -
258 - FS.PostMessage.receiveOnce('install', function (data) {
259 - var requestData = {
260 - user_id : data.user.id,
261 - user_secret_key : data.user.secret_key,
262 - user_public_key : data.user.public_key,
263 - install_id : data.install.id,
264 - install_secret_key: data.install.secret_key,
265 - install_public_key: data.install.public_key
266 - };
267 -
268 - if (true === data.auto_install)
269 - requestData.auto_install = true;
270 -
271 - // Post data to activation URL.
272 - $.form('<?php echo fs_nonce_url( $fs->_get_admin_page_url( 'account', array(
273 - 'fs_action' => $fs->get_unique_affix() . '_activate_new',
274 - 'plugin_id' => $plugin_id
275 - ) ), $fs->get_unique_affix() . '_activate_new' ) ?>', requestData).submit();
276 - });
277 -
278 - FS.PostMessage.receiveOnce('pending_activation', function (data) {
279 - var requestData = {
280 - user_email: data.user_email
281 - };
282 -
283 - if (true === data.auto_install)
284 - requestData.auto_install = true;
285 -
286 - $.form('<?php echo fs_nonce_url( $fs->_get_admin_page_url( 'account', array(
287 - 'fs_action' => $fs->get_unique_affix() . '_activate_new',
288 - 'plugin_id' => $plugin_id,
289 - 'pending_activation' => true,
290 - ) ), $fs->get_unique_affix() . '_activate_new' ) ?>', requestData).submit();
291 - });
292 -
293 - FS.PostMessage.receiveOnce('get_context', function () {
294 - console.debug('receiveOnce', 'get_context');
295 -
296 - // If the user didn't connect his account with Freemius,
297 - // once he accepts the Terms of Service and Privacy Policy,
298 - // and then click the purchase button, the context information
299 - // of the user will be shared with Freemius in order to complete the
300 - // purchase workflow and activate the license for the right user.
301 - <?php $install_data = array_merge( $fs->get_opt_in_params(),
302 - array(
303 - 'activation_url' => fs_nonce_url( $fs->_get_admin_page_url( '',
304 - array(
305 - 'fs_action' => $fs->get_unique_affix() . '_activate_new',
306 - 'plugin_id' => $plugin_id,
307 -
308 - ) ),
309 - $fs->get_unique_affix() . '_activate_new' )
310 - ) ) ?>
311 - FS.PostMessage.post('context', <?php echo json_encode( $install_data ) ?>, frame[0]);
312 - });
313 -
314 - FS.PostMessage.receiveOnce('purchaseCompleted', <?php echo $fs->apply_filters('checkout/purchaseCompleted', 'function (data) {
315 - console.log("checkout", "purchaseCompleted");
316 - }') ?>);
317 -
318 - FS.PostMessage.receiveOnce('get_dimensions', function (data) {
319 - console.debug('receiveOnce', 'get_dimensions');
320 -
321 - FS.PostMessage.post('dimensions', {
322 - height : $(document.body).height(),
323 - scrollTop: $(document).scrollTop()
324 - }, frame[0]);
325 - });
326 -
327 - var updateHeight = function () {
328 - frame.css('min-height', $(document.body).height() + 'px');
329 - };
330 -
331 - $(document).ready(updateHeight);
332 -
333 - $(window).resize(updateHeight);
334 - });
335 - })(jQuery);
336 - </script>
337 - </div>