PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 2.0.1
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v2.0.1
4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.14 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.0 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.10 4.4.11 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5.0 4.5.1
embedpress / freemius / templates / checkout.php
embedpress / freemius / templates Last commit date
debug 9 years ago forms 9 years ago plugin-info 9 years ago account.php 9 years ago add-ons.php 9 years ago add-trial-to-pricing.php 9 years ago admin-notice.php 9 years ago ajax-loader.php 9 years ago all-admin-notice.php 9 years ago auto-installation.php 9 years ago billing.php 9 years ago checkout-legacy.php 9 years ago checkout.php 9 years ago connect.php 9 years ago contact.php 9 years ago debug.php 9 years ago email.php 9 years ago firewall-issues-js.php 9 years ago index.php 9 years ago plugin-icon.php 9 years ago powered-by.php 9 years ago pricing.php 9 years ago sticky-admin-notice-js.php 9 years ago
checkout.php
306 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 /**
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 * since theme admin settings/options are now only allowed in the customizer.
17 *
18 * In addition, this page loads an i-frame. We intentionally named it 'frame'
19 * so it will pass the "Theme Check" that is looking for the string "i" . "frame".
20 *
21 * If you have any questions or need clarifications, please don't hesitate
22 * pinging me on slack, my username is @svovaf.
23 *
24 * @author Vova Feldman (@svovaf)
25 * @since 1.2.2
26 */
27
28 if ( ! defined( 'ABSPATH' ) ) {
29 exit;
30 }
31
32 wp_enqueue_script( 'jquery' );
33 wp_enqueue_script( 'json2' );
34 fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
35 fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
36 fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
37 fs_enqueue_local_style( 'fs_checkout', '/admin/checkout.css' );
38
39 /**
40 * @var array $VARS
41 * @var Freemius $fs
42 */
43 $slug = $VARS['slug'];
44 $fs = freemius( $slug );
45
46 $timestamp = time();
47
48 $context_params = array(
49 'plugin_id' => $fs->get_id(),
50 'plugin_version' => $fs->get_plugin_version(),
51 'public_key' => $fs->get_public_key(),
52 'mode' => 'dashboard',
53 'trial' => fs_request_get_bool( 'trial' ),
54 );
55
56 $plan_id = fs_request_get( 'plan_id' );
57 if ( FS_Plugin_Plan::is_valid_id( $plan_id ) ) {
58 $context_params['plan_id'] = $plan_id;
59 }
60
61 $licenses = fs_request_get( 'licenses' );
62 if ( $licenses === strval( intval( $licenses ) ) && $licenses > 0 ) {
63 $context_params['licenses'] = $licenses;
64 }
65
66 $plugin_id = fs_request_get( 'plugin_id' );
67 if ( ! FS_Plugin::is_valid_id( $plugin_id ) ) {
68 $plugin_id = $fs->get_id();
69 }
70
71 if ( $plugin_id == $fs->get_id() ) {
72 $is_premium = $fs->is_premium();
73 }else {
74 // Identify the module code version of the checkout context module.
75 if ( $fs->is_addon_activated( $plugin_id ) ) {
76 $fs_addon = Freemius::get_instance_by_id( $plugin_id );
77 $is_premium = $fs_addon->is_premium();
78 } else {
79 // If add-on isn't activated assume the premium version isn't installed.
80 $is_premium = false;
81 }
82 }
83
84 // Get site context secure params.
85 if ( $fs->is_registered() ) {
86 $site = $fs->get_site();
87
88 if ( $plugin_id != $fs->get_id() ) {
89 if ( $fs->is_addon_activated( $plugin_id ) ) {
90 $fs_addon = Freemius::get_instance_by_id( $plugin_id );
91 $site = $fs_addon->get_site();
92 }
93 }
94
95 $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
96 $site,
97 $timestamp,
98 'checkout'
99 ) );
100 } else {
101 $current_user = Freemius::_get_current_wp_user();
102
103 // Add site and user info to the request, this information
104 // is NOT being stored unless the user complete the purchase
105 // and agrees to the TOS.
106 $context_params = array_merge( $context_params, array(
107 'user_firstname' => $current_user->user_firstname,
108 'user_lastname' => $current_user->user_lastname,
109 'user_email' => $current_user->user_email,
110 'home_url' => home_url(),
111 ) );
112
113 $fs_user = Freemius::_get_user_by_email( $current_user->user_email );
114
115 if ( is_object( $fs_user ) ) {
116 $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
117 $fs_user,
118 $timestamp,
119 'checkout'
120 ) );
121 }
122 }
123
124 if ( $fs->is_payments_sandbox() ) {
125 // Append plugin secure token for sandbox mode authentication.
126 $context_params['sandbox'] = FS_Security::instance()->get_secure_token(
127 $fs->get_plugin(),
128 $timestamp,
129 'checkout'
130 );
131
132 /**
133 * @since 1.1.7.3 Add security timestamp for sandbox even for anonymous user.
134 */
135 if ( empty( $context_params['s_ctx_ts'] ) ) {
136 $context_params['s_ctx_ts'] = $timestamp;
137 }
138 }
139
140 $return_url = $fs->_get_sync_license_url( $plugin_id );
141
142 $query_params = array_merge( $context_params, $_GET, array(
143 // Current plugin version.
144 'plugin_version' => $fs->get_plugin_version(),
145 'sdk_version' => WP_FS__SDK_VERSION,
146 'is_premium' => $is_premium ? 'true' : 'false',
147 'return_url' => $return_url,
148 // Admin CSS URL for style/design competability.
149 // 'wp_admin_css' => get_bloginfo('wpurl') . "/wp-admin/load-styles.php?c=1&load=buttons,wp-admin,dashicons",
150 ) );
151
152 $xdebug_session = fs_request_get( 'XDEBUG_SESSION' );
153 if ( false !== $xdebug_session ) {
154 $query_params['XDEBUG_SESSION'] = $xdebug_session;
155 }
156 ?>
157 <div id="fs_checkout" class="wrap fs-full-size-wrapper">
158 <div id="iframe"></div>
159 <script type="text/javascript">
160 // http://stackoverflow.com/questions/4583703/jquery-post-request-not-ajax
161 jQuery(function ($) {
162 $.extend({
163 form: function (url, data, method) {
164 if (method == null) method = 'POST';
165 if (data == null) data = {};
166
167 var form = $('<form>').attr({
168 method: method,
169 action: url
170 }).css({
171 display: 'none'
172 });
173
174 var addData = function (name, data) {
175 if ($.isArray(data)) {
176 for (var i = 0; i < data.length; i++) {
177 var value = data[i];
178 addData(name + '[]', value);
179 }
180 } else if (typeof data === 'object') {
181 for (var key in data) {
182 if (data.hasOwnProperty(key)) {
183 addData(name + '[' + key + ']', data[key]);
184 }
185 }
186 } else if (data != null) {
187 form.append($('<input>').attr({
188 type : 'hidden',
189 name : String(name),
190 value: String(data)
191 }));
192 }
193 };
194
195 for (var key in data) {
196 if (data.hasOwnProperty(key)) {
197 addData(key, data[key]);
198 }
199 }
200
201 return form.appendTo('body');
202 }
203 });
204 });
205
206 (function ($) {
207 $(function () {
208
209 var
210 // Keep track of the iframe height.
211 iframe_height = 800,
212 base_url = '<?php echo FS_CHECKOUT__ADDRESS ?>',
213 // Pass the parent page URL into the Iframe in a meaningful way (this URL could be
214 // passed via query string or hard coded into the child page, it depends on your needs).
215 src = base_url + '/?<?php echo http_build_query( $query_params ) ?>#' + encodeURIComponent(document.location.href),
216 // Append the Iframe into the DOM.
217 iframe = $('<iframe " src="' + src + '" width="100%" height="' + iframe_height + 'px" scrolling="no" frameborder="0" style="background: transparent;"><\/iframe>')
218 .appendTo('#iframe');
219
220 FS.PostMessage.init(base_url, [iframe[0]]);
221 FS.PostMessage.receiveOnce('height', function (data) {
222 var h = data.height;
223 if (!isNaN(h) && h > 0 && h != iframe_height) {
224 iframe_height = h;
225 iframe.height(iframe_height + 'px');
226
227 FS.PostMessage.postScroll(iframe[0]);
228 }
229 });
230
231 FS.PostMessage.receiveOnce('install', function (data) {
232 var requestData = {
233 user_id : data.user.id,
234 user_secret_key : data.user.secret_key,
235 user_public_key : data.user.public_key,
236 install_id : data.install.id,
237 install_secret_key: data.install.secret_key,
238 install_public_key: data.install.public_key
239 };
240
241 if (true === data.auto_install)
242 requestData.auto_install = true;
243
244 // Post data to activation URL.
245 $.form('<?php echo fs_nonce_url( $fs->_get_admin_page_url( 'account', array(
246 'fs_action' => $slug . '_activate_new',
247 'plugin_id' => $plugin_id
248 ) ), $slug . '_activate_new' ) ?>', requestData).submit();
249 });
250
251 FS.PostMessage.receiveOnce('pending_activation', function (data) {
252 var requestData = {
253 user_email: data.user_email
254 };
255
256 if (true === data.auto_install)
257 requestData.auto_install = true;
258
259 $.form('<?php echo fs_nonce_url( $fs->_get_admin_page_url( 'account', array(
260 'fs_action' => $slug . '_activate_new',
261 'plugin_id' => $plugin_id,
262 'pending_activation' => true,
263 ) ), $slug . '_activate_new' ) ?>', requestData).submit();
264 });
265
266 FS.PostMessage.receiveOnce('get_context', function () {
267 console.debug('receiveOnce', 'get_context');
268
269 // If the user didn't connect his account with Freemius,
270 // once he accepts the Terms of Service and Privacy Policy,
271 // and then click the purchase button, the context information
272 // of the user will be shared with Freemius in order to complete the
273 // purchase workflow and activate the license for the right user.
274 <?php $install_data = array_merge( $fs->get_opt_in_params(),
275 array(
276 'activation_url' => fs_nonce_url( $fs->_get_admin_page_url( '',
277 array(
278 'fs_action' => $slug . '_activate_new',
279 'plugin_id' => $plugin_id,
280
281 ) ),
282 $slug . '_activate_new' )
283 ) ) ?>
284 FS.PostMessage.post('context', <?php echo json_encode( $install_data ) ?>, iframe[0]);
285 });
286
287 FS.PostMessage.receiveOnce('get_dimensions', function (data) {
288 console.debug('receiveOnce', 'get_dimensions');
289
290 FS.PostMessage.post('dimensions', {
291 height : $(document.body).height(),
292 scrollTop: $(document).scrollTop()
293 }, iframe[0]);
294 });
295
296 var updateHeight = function () {
297 iframe.css('min-height', $('#wpwrap').height() + 'px');
298 };
299
300 $(document).ready(updateHeight);
301
302 $(window).resize(updateHeight);
303 });
304 })(jQuery);
305 </script>
306 </div>