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