PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 1.7.3
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v1.7.3
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 all-admin-notice.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
261 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 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 wp_enqueue_script( 'jquery' );
14 wp_enqueue_script( 'json2' );
15 fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
16 fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
17 fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
18 fs_enqueue_local_style( 'fs_checkout', '/admin/checkout.css' );
19
20 /**
21 * @var array $VARS
22 */
23 $slug = $VARS['slug'];
24 $fs = freemius( $slug );
25
26 $timestamp = time();
27
28 $context_params = array(
29 'plugin_id' => $fs->get_id(),
30 'plugin_version' => $fs->get_plugin_version(),
31 'public_key' => $fs->get_public_key(),
32 'mode' => 'dashboard',
33 'trial' => fs_request_get_bool( 'trial' ),
34 );
35
36 $plan_id = fs_request_get( 'plan_id' );
37 if ( FS_Plugin_Plan::is_valid_id( $plan_id ) ) {
38 $context_params['plan_id'] = $plan_id;
39 }
40
41 $licenses = fs_request_get( 'licenses' );
42 if ( $licenses === strval( intval( $licenses ) ) && $licenses > 0 ) {
43 $context_params['licenses'] = $licenses;
44 }
45
46 $plugin_id = fs_request_get( 'plugin_id' );
47 if ( ! FS_Plugin::is_valid_id( $plugin_id ) ) {
48 $plugin_id = $fs->get_id();
49 }
50
51 // Get site context secure params.
52 if ( $fs->is_registered() ) {
53 $site = $fs->get_site();
54
55 if ( $plugin_id != $fs->get_id() ) {
56 if ( $fs->is_addon_activated( $plugin_id ) ) {
57 $fs_addon = Freemius::get_instance_by_id( $plugin_id );
58 $site = $fs_addon->get_site();
59 }
60 }
61
62 $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
63 $site,
64 $timestamp,
65 'checkout'
66 ) );
67 } else {
68 $current_user = Freemius::_get_current_wp_user();
69
70 // Add site and user info to the request, this information
71 // is NOT being stored unless the user complete the purchase
72 // and agrees to the TOS.
73 $context_params = array_merge( $context_params, array(
74 'user_firstname' => $current_user->user_firstname,
75 'user_lastname' => $current_user->user_lastname,
76 'user_email' => $current_user->user_email,
77 'home_url' => home_url(),
78 ) );
79
80 $fs_user = Freemius::_get_user_by_email( $current_user->user_email );
81
82 if ( is_object( $fs_user ) ) {
83 $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
84 $fs_user,
85 $timestamp,
86 'checkout'
87 ) );
88 }
89 }
90
91 if ( $fs->is_payments_sandbox() ) {
92 // Append plugin secure token for sandbox mode authentication.
93 $context_params['sandbox'] = FS_Security::instance()->get_secure_token(
94 $fs->get_plugin(),
95 $timestamp,
96 'checkout'
97 );
98
99 /**
100 * @since 1.1.7.3 Add security timestamp for sandbox even for anonymous user.
101 */
102 if ( empty( $context_params['s_ctx_ts'] ) ) {
103 $context_params['s_ctx_ts'] = $timestamp;
104 }
105 }
106
107 $return_url = $fs->_get_sync_license_url( $plugin_id );
108
109 $query_params = array_merge( $context_params, $_GET, array(
110 // Current plugin version.
111 'plugin_version' => $fs->get_plugin_version(),
112 'sdk_version' => WP_FS__SDK_VERSION,
113 'return_url' => $return_url,
114 // Admin CSS URL for style/design competability.
115 // 'wp_admin_css' => get_bloginfo('wpurl') . "/wp-admin/load-styles.php?c=1&load=buttons,wp-admin,dashicons",
116 ) );
117
118 $xdebug_session = fs_request_get( 'XDEBUG_SESSION' );
119 if ( false !== $xdebug_session ) {
120 $query_params['XDEBUG_SESSION'] = $xdebug_session;
121 }
122 ?>
123 <div id="fs_checkout" class="wrap fs-full-size-wrapper">
124 <div id="iframe"></div>
125 <script type="text/javascript">
126 // http://stackoverflow.com/questions/4583703/jquery-post-request-not-ajax
127 jQuery(function ($) {
128 $.extend({
129 form: function (url, data, method) {
130 if (method == null) method = 'POST';
131 if (data == null) data = {};
132
133 var form = $('<form>').attr({
134 method: method,
135 action: url
136 }).css({
137 display: 'none'
138 });
139
140 var addData = function (name, data) {
141 if ($.isArray(data)) {
142 for (var i = 0; i < data.length; i++) {
143 var value = data[i];
144 addData(name + '[]', value);
145 }
146 } else if (typeof data === 'object') {
147 for (var key in data) {
148 if (data.hasOwnProperty(key)) {
149 addData(name + '[' + key + ']', data[key]);
150 }
151 }
152 } else if (data != null) {
153 form.append($('<input>').attr({
154 type : 'hidden',
155 name : String(name),
156 value: String(data)
157 }));
158 }
159 };
160
161 for (var key in data) {
162 if (data.hasOwnProperty(key)) {
163 addData(key, data[key]);
164 }
165 }
166
167 return form.appendTo('body');
168 }
169 });
170 });
171
172 (function ($) {
173 $(function () {
174
175 var
176 // Keep track of the iframe height.
177 iframe_height = 800,
178 base_url = '<?php echo FS_CHECKOUT__ADDRESS ?>',
179 // Pass the parent page URL into the Iframe in a meaningful way (this URL could be
180 // passed via query string or hard coded into the child page, it depends on your needs).
181 src = base_url + '/?<?php echo http_build_query( $query_params ) ?>#' + encodeURIComponent(document.location.href),
182
183 // Append the Iframe into the DOM.
184 iframe = $('<iframe " src="' + src + '" width="100%" height="' + iframe_height + 'px" scrolling="no" frameborder="0" style="background: transparent;"><\/iframe>')
185 .appendTo('#iframe');
186
187 FS.PostMessage.init(base_url, [iframe[0]]);
188 FS.PostMessage.receiveOnce('height', function (data) {
189 var h = data.height;
190 if (!isNaN(h) && h > 0 && h != iframe_height) {
191 iframe_height = h;
192 iframe.height(iframe_height + 'px');
193
194 FS.PostMessage.postScroll(iframe[0]);
195 }
196 });
197
198 FS.PostMessage.receiveOnce('install', function (data) {
199 // Post data to activation URL.
200 $.form('<?php echo fs_nonce_url( $fs->_get_admin_page_url( 'account', array(
201 'fs_action' => $slug . '_activate_new',
202 'plugin_id' => $plugin_id
203 ) ), $slug . '_activate_new' ) ?>', {
204 user_id : data.user.id,
205 user_secret_key : data.user.secret_key,
206 user_public_key : data.user.public_key,
207 install_id : data.install.id,
208 install_secret_key: data.install.secret_key,
209 install_public_key: data.install.public_key
210 }).submit();
211 });
212
213 FS.PostMessage.receiveOnce('pending_activation', function (data) {
214 $.form('<?php echo fs_nonce_url( $fs->_get_admin_page_url( 'account', array(
215 'fs_action' => $slug . '_activate_new',
216 'plugin_id' => $plugin_id,
217 'pending_activation' => true,
218 ) ), $slug . '_activate_new' ) ?>', {
219 user_email: data.user_email
220 }).submit();
221 });
222
223 FS.PostMessage.receiveOnce('get_context', function () {
224 console.debug('receiveOnce', 'get_context');
225
226 // If the user didn't connect his account with Freemius,
227 // once he accepts the Terms of Service and Privacy Policy,
228 // and then click the purchase button, the context information
229 // of the user will be shared with Freemius in order to complete the
230 // purchase workflow and activate the license for the right user.
231 <?php $install_data = array_merge( $fs->get_opt_in_params(),
232 array(
233 'activation_url' => fs_nonce_url( $fs->_get_admin_page_url( '',
234 array(
235 'fs_action' => $slug . '_activate_new',
236 'plugin_id' => $plugin_id,
237
238 ) ),
239 $slug . '_activate_new' )
240 ) ) ?>
241 FS.PostMessage.post('context', <?php echo json_encode( $install_data ) ?>, iframe[0]);
242 });
243
244 FS.PostMessage.receiveOnce('get_dimensions', function (data) {
245 FS.PostMessage.post('dimensions', {
246 height : $(document.body).height(),
247 scrollTop: $(document).scrollTop()
248 }, iframe[0]);
249 });
250
251 var updateHeight = function(){
252 iframe.css('min-height', $('#wpwrap').height() + 'px');
253 };
254
255 $(document).ready(updateHeight);
256
257 $(window).resize(updateHeight)
258 });
259 })(jQuery);
260 </script>
261 </div>