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 / connect.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
connect.php
407 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.7
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * @var array $VARS
15 */
16 $slug = $VARS['slug'];
17 $fs = freemius( $slug );
18 $is_pending_activation = $fs->is_pending_activation();
19 $is_premium_only = $fs->is_only_premium();
20 $has_paid_plans = $fs->has_paid_plan();
21 $is_premium_code = $fs->is_premium();
22 $is_freemium = $fs->is_freemium();
23
24 $fs->_enqueue_connect_essentials();
25
26 $current_user = Freemius::_get_current_wp_user();
27
28 $first_name = $current_user->user_firstname;
29 if ( empty( $first_name ) ) {
30 $first_name = $current_user->nickname;
31 }
32
33 $site_url = get_site_url();
34 $protocol_pos = strpos( $site_url, '://' );
35 if ( false !== $protocol_pos ) {
36 $site_url = substr( $site_url, $protocol_pos + 3 );
37 }
38
39 $freemius_site_www = 'https://freemius.com';
40
41 $freemius_site_url = $freemius_site_www . '/' . ($fs->has_paid_plan() ?
42 'wordpress/' :
43 // Insights platform information.
44 'wordpress/usage-tracking/');
45
46 $freemius_site_url .= '?' . http_build_query( array(
47 'id' => $fs->get_id(),
48 'slug' => $slug,
49 ) );
50
51 $freemius_link = '<a href="' . $freemius_site_url . '" target="_blank" tabindex="1">freemius.com</a>';
52
53 $error = fs_request_get( 'error' );
54
55 $require_license_key = $is_premium_only ||
56 ( $is_freemium && $is_premium_code && fs_request_get_bool( 'require_license', true ) );
57
58 if ( $is_pending_activation ) {
59 $require_license_key = false;
60 }
61
62 if ( $require_license_key ) {
63 $fs->_add_license_activation_dialog_box();
64 }
65
66 $fs_user = Freemius::_get_user_by_email( $current_user->user_email );
67 $activate_with_current_user = is_object( $fs_user ) && ! $is_pending_activation;
68 ?>
69 <div id="fs_connect"
70 class="wrap<?php if ( ! $fs->is_enable_anonymous() || $is_pending_activation || $require_license_key ) {
71 echo ' fs-anonymous-disabled';
72 } ?>">
73 <div class="fs-visual">
74 <b class="fs-site-icon"><i class="dashicons dashicons-wordpress"></i></b>
75 <i class="dashicons dashicons-plus fs-first"></i>
76 <?php
77 $vars = array( 'slug' => $slug );
78 fs_require_once_template( 'plugin-icon.php', $vars );
79 ?>
80 <i class="dashicons dashicons-plus fs-second"></i>
81 <img class="fs-connect-logo" width="80" height="80" src="//img.freemius.com/connect-logo.png"/>
82 </div>
83 <div class="fs-content">
84 <?php if ( ! empty( $error ) ) : ?>
85 <p class="fs-error"><?php echo esc_html( $error ) ?></p>
86 <?php endif ?>
87 <p><?php
88 $button_label = 'opt-in-connect';
89
90 if ( $is_pending_activation ) {
91 $button_label = 'resend-activation-email';
92
93 echo $fs->apply_filters( 'pending_activation_message', sprintf(
94 __fs( 'thanks-x', $slug ) . '<br>' .
95 __fs( 'pending-activation-message', $slug ),
96 $first_name,
97 '<b>' . $fs->get_plugin_name() . '</b>',
98 '<b>' . $current_user->user_email . '</b>',
99 __fs( 'complete-the-install', $slug )
100 ) );
101 } else if ( $require_license_key ) {
102 $button_label = 'agree-activate-license';
103
104 echo $fs->apply_filters( 'connect-message_on-premium',
105 sprintf( __fs( 'hey-x', $slug ), $first_name ) . '<br>' .
106 sprintf( __fs( 'thanks-for-purchasing', $slug ), '<b>' . $fs->get_plugin_name() . '</b>' ),
107 $first_name,
108 $fs->get_plugin_name()
109 );
110 } else {
111 $filter = 'connect_message';
112 $default_optin_message = 'connect-message';
113
114 if ( $fs->is_plugin_update() ) {
115 // If Freemius was added on a plugin update, set different
116 // opt-in message.
117 $default_optin_message = 'connect-message_on-update';
118
119 // If user customized the opt-in message on update, use
120 // that message. Otherwise, fallback to regular opt-in
121 // custom message if exist.
122 if ( $fs->has_filter( 'connect_message_on_update' ) ) {
123 $filter = 'connect_message_on_update';
124 }
125 }
126
127 echo $fs->apply_filters( $filter,
128 sprintf( __fs( 'hey-x', $slug ), $first_name ) . '<br>' .
129 sprintf(
130 __fs( $default_optin_message, $slug ),
131 '<b>' . $fs->get_plugin_name() . '</b>',
132 '<b>' . $current_user->user_login . '</b>',
133 '<a href="' . $site_url . '" target="_blank">' . $site_url . '</a>',
134 $freemius_link
135 ),
136 $first_name,
137 $fs->get_plugin_name(),
138 $current_user->user_login,
139 '<a href="' . $site_url . '" target="_blank">' . $site_url . '</a>',
140 $freemius_link
141 );
142 }
143 ?></p>
144 <?php if ( $require_license_key ) : ?>
145 <div class="fs-license-key-container">
146 <input id="fs_license_key" name="fs_key" type="text" required maxlength="32"
147 placeholder="<?php _efs( 'license-key', $slug ) ?>" tabindex="1"/>
148 <i class="dashicons dashicons-admin-network"></i>
149 <a class="show-license-resend-modal show-license-resend-modal-<?php echo $slug; ?>"
150 href="#"><?php _efs( 'cant-find-license-key' ); ?></a>
151 </div>
152 <?php endif ?>
153 </div>
154 <div class="fs-actions">
155 <?php if ( $fs->is_enable_anonymous() && ! $is_pending_activation && ! $require_license_key ) : ?>
156 <a href="<?php echo fs_nonce_url( $fs->_get_admin_page_url( '', array( 'fs_action' => $slug . '_skip_activation' ) ), $slug . '_skip_activation' ) ?>"
157 class="button button-secondary" tabindex="2"><?php _efs( 'skip', $slug ) ?></a>
158 <?php endif ?>
159
160 <?php if ( $activate_with_current_user ) : ?>
161 <form action="" method="POST">
162 <input type="hidden" name="fs_action" value="<?php echo $slug ?>_activate_existing">
163 <?php wp_nonce_field( 'activate_existing_' . $fs->get_public_key() ) ?>
164 <button class="button button-primary" tabindex="1"
165 type="submit"<?php if ( $require_license_key ) {
166 echo ' disabled="disabled"';
167 } ?>><?php _efs( $button_label, $slug ) ?></button>
168 </form>
169 <?php else : ?>
170 <form method="post" action="<?php echo WP_FS__ADDRESS ?>/action/service/user/install/">
171 <?php $params = $fs->get_opt_in_params() ?>
172 <?php foreach ( $params as $name => $value ) : ?>
173 <input type="hidden" name="<?php echo $name ?>" value="<?php echo esc_attr( $value ) ?>">
174 <?php endforeach ?>
175 <button class="button button-primary" tabindex="1"
176 type="submit"<?php if ( $require_license_key ) {
177 echo ' disabled="disabled"';
178 } ?>><?php _efs( $button_label, $slug ) ?></button>
179 </form>
180 <?php endif ?>
181 </div><?php
182
183 // Set core permission list items.
184 $permissions = array(
185 'profile' => array(
186 'icon-class' => 'dashicons dashicons-admin-users',
187 'label' => __fs( 'permissions-profile' ),
188 'desc' => __fs( 'permissions-profile_desc' ),
189 'priority' => 5,
190 ),
191 'site' => array(
192 'icon-class' => 'dashicons dashicons-admin-settings',
193 'label' => __fs( 'permissions-site' ),
194 'desc' => __fs( 'permissions-site_desc' ),
195 'priority' => 10,
196 ),
197 'notices' => array(
198 'icon-class' => 'dashicons dashicons-testimonial',
199 'label' => __fs( 'permissions-admin-notices' ),
200 'desc' => __fs( 'permissions-newsletter_desc' ),
201 'priority' => 13,
202 ),
203 'events' => array(
204 'icon-class' => 'dashicons dashicons-admin-plugins',
205 'label' => __fs( 'permissions-events' ),
206 'desc' => __fs( 'permissions-events_desc' ),
207 'priority' => 20,
208 ),
209 // 'plugins_themes' => array(
210 // 'icon-class' => 'dashicons dashicons-admin-settings',
211 // 'label' => __fs( 'permissions-plugins_themes' ),
212 // 'desc' => __fs( 'permissions-plugins_themes_desc' ),
213 // 'priority' => 30,
214 // ),
215 );
216
217 // Add newsletter permissions if enabled.
218 if ( $fs->is_permission_requested( 'newsletter' ) ) {
219 $permissions['newsletter'] = array(
220 'icon-class' => 'dashicons dashicons-email-alt',
221 'label' => __fs( 'permissions-newsletter' ),
222 'desc' => __fs( 'permissions-newsletter_desc' ),
223 'priority' => 15,
224 );
225 }
226
227 // Allow filtering of the permissions list.
228 $permissions = $fs->apply_filters( 'permission_list', $permissions );
229
230 // Sort by priority.
231 uasort( $permissions, 'fs_sort_by_priority' );
232
233 if ( ! empty( $permissions ) ) : ?>
234 <div class="fs-permissions">
235 <?php if ( $require_license_key ) : ?>
236 <p class="fs-license-sync-disclaimer"><?php printf( __fs( 'license-sync-disclaimer', $slug ), $freemius_link ) ?></p>
237 <?php endif ?>
238 <a class="fs-trigger" href="#" tabindex="1"><?php _efs( 'what-permissions', $slug ) ?></a>
239 <ul><?php
240 foreach ( $permissions as $id => $permission ) : ?>
241 <li id="fs-permission-<?php echo esc_attr( $id ); ?>"
242 class="fs-permission fs-<?php echo esc_attr( $id ); ?>">
243 <i class="<?php echo esc_attr( $permission['icon-class'] ); ?>"></i>
244
245 <div>
246 <span><?php echo esc_html( $permission['label'] ); ?></span>
247
248 <p><?php echo esc_html( $permission['desc'] ); ?></p>
249 </div>
250 </li>
251 <?php endforeach; ?>
252 </ul>
253 </div>
254 <?php endif ?>
255 <?php if ( $is_premium_code && $is_freemium ) : ?>
256 <div class="fs-freemium-licensing">
257 <p>
258 <?php if ( $require_license_key ) : ?>
259 <?php _efs( 'dont-have-license-key', $slug ) ?>
260 <a data-require-license="false" tabindex="1"><?php _efs( 'activate-free-version', $slug ) ?></a>
261 <?php else : ?>
262 <?php _efs( 'have-license-key', $slug ) ?>
263 <a data-require-license="true" tabindex="1"><?php _efs( 'activate-license', $slug ) ?></a>
264 <?php endif ?>
265 </p>
266 </div>
267 <?php endif ?>
268 <div class="fs-terms">
269 <a href="https://freemius.com/privacy/" target="_blank"
270 tabindex="1"><?php _efs( 'privacy-policy', $slug ) ?></a>
271 &nbsp;&nbsp;-&nbsp;&nbsp;
272 <a href="<?php echo $freemius_site_www ?>/terms/" target="_blank" tabindex="1"><?php _efs( 'tos', $slug ) ?></a>
273 </div>
274 </div>
275 <script type="text/javascript">
276 (function ($) {
277 var $primaryCta = $('.fs-actions .button.button-primary'),
278 $form = $('.fs-actions form'),
279 requireLicenseKey = <?php echo $require_license_key ? 'true' : 'false' ?>,
280 hasContextUser = <?php echo $activate_with_current_user ? 'true' : 'false' ?>,
281 $licenseSecret,
282 $licenseKeyInput = $('#fs_license_key');
283
284 $('.fs-actions .button').on('click', function () {
285 // Set loading mode.
286 $(document.body).css({'cursor': 'wait'});
287
288 var $this = $(this);
289 $this.css({'cursor': 'wait'});
290
291 setTimeout(function () {
292 $this.attr('disabled', 'disabled');
293 }, 200);
294 });
295
296 $form.on('submit', function () {
297 /**
298 * @author Vova Feldman (@svovaf)
299 * @since 1.1.9
300 */
301 if (requireLicenseKey) {
302 if (!hasContextUser) {
303 $('.fs-error').remove();
304
305 /**
306 * Use the AJAX opt-in when license key is required to potentially
307 * process the after install failure hook.
308 *
309 * @author Vova Feldman (@svovaf)
310 * @since 1.2.1.5
311 */
312 $.ajax({
313 url : ajaxurl,
314 method : 'POST',
315 data : {
316 action : 'fs_activate_license_<?php echo $slug ?>',
317 slug : '<?php echo $slug ?>',
318 license_key: $licenseKeyInput.val()
319 },
320 success: function (result) {
321 var resultObj = $.parseJSON(result);
322 if (resultObj.success) {
323 // Redirect to the "Account" page and sync the license.
324 window.location.href = resultObj.next_page;
325 } else {
326 // Show error.
327 $('.fs-content').prepend('<p class="fs-error">' + resultObj.error + '</p>');
328
329 // Reset loading mode.
330 $primaryCta.removeClass('fs-loading').css({'cursor': 'auto'});
331 $primaryCta.html(<?php echo json_encode(__fs( $button_label, $slug )) ?>);
332 $primaryCta.prop('disabled', false);
333 $(document.body).css({'cursor': 'auto'});
334 }
335 }
336 });
337
338 return false;
339 }
340 else {
341 if (null == $licenseSecret) {
342 $licenseSecret = $('<input type="hidden" name="license_secret_key" value="" />');
343 $form.append($licenseSecret);
344 }
345
346 // Update secret key if premium only plugin.
347 $licenseSecret.val($licenseKeyInput.val());
348 }
349 }
350
351 return true;
352 });
353
354 $primaryCta.on('click', function () {
355 $(this).addClass('fs-loading');
356 $(this).html(<?php echo json_encode(__fs( $is_pending_activation ? 'sending-email' : 'activating' , $slug )) ?> +'...');
357 });
358
359 $('.fs-permissions .fs-trigger').on('click', function () {
360 $('.fs-permissions').toggleClass('fs-open');
361 });
362
363 if (requireLicenseKey) {
364 /**
365 * Submit license key on enter.
366 *
367 * @author Vova Feldman (@svovaf)
368 * @since 1.1.9
369 */
370 $licenseKeyInput.keypress(function (e) {
371 if (e.which == 13) {
372 if ('' !== $(this).val()) {
373 $primaryCta.click();
374 return false;
375 }
376 }
377 });
378
379 /**
380 * Disable activation button when empty license key.
381 *
382 * @author Vova Feldman (@svovaf)
383 * @since 1.1.9
384 */
385 $licenseKeyInput.on('keyup paste delete cut', function () {
386 setTimeout(function () {
387 if ('' === $licenseKeyInput.val()) {
388 $primaryCta.attr('disabled', 'disabled');
389 } else {
390 $primaryCta.prop('disabled', false);
391 }
392 }, 100);
393 }).focus();
394 }
395
396 /**
397 * Set license mode trigger URL.
398 *
399 * @author Vova Feldman (@svovaf)
400 * @since 1.1.9
401 */
402 var $connectLicenseModeTrigger = $('#fs_connect .fs-freemium-licensing a');
403 if ($connectLicenseModeTrigger.length > 0) {
404 $connectLicenseModeTrigger.attr('href', window.location.href + '&require_license=' + $connectLicenseModeTrigger.attr('data-require-license'))
405 }
406 })(jQuery);
407 </script>