PluginProbe
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder / 3.6.0
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder v3.6.0
3.6.0 3.5.0 trunk 1.0.10 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.6.1 1.0.7 1.0.8 1.0.9 1.1 1.1.1 1.2 1.3 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5 1.5.1 All 110 releases
← All changes | freemius/templates/forms/trial-start.php +181 -178 1.43.6.0 View file →
@@ -1,178 +1,181 @@
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.2.0
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 -
19 - $message_header = sprintf(
20 - fs_text( 'start-trial-prompt-header', $slug ),
21 - '<span class="var-trial_period"></span>',
22 - '<span class="var-plan_title"></span>'
23 - );
24 - $message_content = sprintf(
25 - fs_text( 'start-trial-prompt-message', $slug ),
26 - sprintf(
27 - '<a href="%s" target="_blank">%s</a>',
28 - 'https://freemius.com',
29 - 'freemius.com'
30 - )
31 - );
32 -
33 - $modal_content_html = <<< HTML
34 - <div class="notice notice-error inline"><p></p></div>
35 - <h3>{$message_header}</h3>
36 - <p>{$message_content}</p>
37 -HTML;
38 -
39 - fs_enqueue_local_style( 'dialog-boxes', '/admin/dialog-boxes.css' );
40 -?>
41 -<script type="text/javascript">
42 - (function ($) {
43 - $(document).ready(function () {
44 - var modalContentHtml = <?php echo json_encode( $modal_content_html ); ?>,
45 - modalHtml =
46 - '<div class="fs-modal fs-modal-license-key-resend">'
47 - + ' <div class="fs-modal-dialog">'
48 - + ' <div class="fs-modal-header">'
49 - + ' <h4><?php fs_esc_js_echo( 'start-free-trial', $slug ) ?></h4>'
50 - + ' </div>'
51 - + ' <div class="fs-modal-body">' + modalContentHtml + '</div>'
52 - + ' <div class="fs-modal-footer">'
53 - + ' <button class="button button-secondary button-close">' + <?php fs_json_encode_echo( 'cancel', $slug ) ?> +'</button>'
54 - + ' <button class="button button-primary button-connect">' + <?php fs_json_encode_echo( 'approve-start-trial', $slug ) ?> +'</button>'
55 - + ' </div>'
56 - + ' </div>'
57 - + '</div>',
58 - $modal = $(modalHtml),
59 - moduleSlug = '<?php echo $slug; ?>',
60 - trialData;
61 -
62 - $modal.appendTo($('body'));
63 -
64 - var $errorNotice = $modal.find('.notice-error');
65 -
66 - registerEventHandlers();
67 -
68 - function registerEventHandlers() {
69 - $modal.on('click', '.button-close', function () {
70 - closeModal();
71 - return false;
72 - });
73 -
74 - $modal.on('click', '.button-connect', function (evt) {
75 - evt.preventDefault();
76 -
77 - var $button = $(this);
78 -
79 - $.ajax({
80 - url : ajaxurl,
81 - method : 'POST',
82 - data : {
83 - action : '<?php echo $fs->get_ajax_action( 'start_trial' ) ?>',
84 - security: '<?php echo $fs->get_ajax_security( 'start_trial' ) ?>',
85 - slug : moduleSlug,
86 - trial : trialData
87 - },
88 - beforeSend: function () {
89 - // Disable all buttons during trial activation.
90 - $modal.find('.button').prop('disabled', true);
91 -
92 - $button.text(<?php fs_json_encode_echo( 'starting-trial', $slug ) ?> + '...');
93 -
94 - setLoadingMode();
95 - },
96 - success : function (resultObj) {
97 - if (resultObj.success) {
98 - $button.text(<?php fs_json_encode_echo( 'please-wait', $slug ) ?> + '...');
99 -
100 - // Redirect to the "Account" page and sync the license.
101 - window.location.href = resultObj.data.next_page;
102 - } else {
103 - $button.text(<?php fs_json_encode_echo( 'approve-start-trial', $slug ) ?>);
104 -
105 - resetLoadingMode();
106 - showError(resultObj.error);
107 - }
108 - }
109 - });
110 - });
111 - }
112 -
113 - window.openTrialConfirmationModal = function showModal(data) {
114 - resetModal();
115 -
116 - // Display the dialog box.
117 - $modal.addClass('active');
118 -
119 - trialData = data;
120 -
121 - var $modalBody = $modal.find('.fs-modal-body'),
122 - $var;
123 -
124 - for (var key in data) {
125 - if (data.hasOwnProperty(key)) {
126 - $var = $modalBody.find('.var-' + key);
127 -
128 - if ($var.length > 0)
129 - $var.html(data[key]);
130 - }
131 - }
132 -
133 - $('body').addClass('has-fs-modal');
134 - };
135 -
136 - function closeModal() {
137 - $modal.removeClass('active');
138 -
139 - $('body').removeClass('has-fs-modal');
140 - }
141 -
142 - function resetModal() {
143 - hideError();
144 - }
145 -
146 - function hideError() {
147 - $errorNotice.hide();
148 - }
149 -
150 - function setLoadingMode() {
151 - $modal.find('.button')
152 - // Re-enable all buttons.
153 - .prop('disabled', trialData)
154 - // Stop loading cursor.
155 - .css({'cursor': 'wait'});
156 -
157 - // Stop loading cursor.
158 - $(document.body).css({'cursor': 'wait'});
159 - }
160 -
161 - function resetLoadingMode() {
162 - $modal.find('.button')
163 - // Re-enable all buttons.
164 - .prop('disabled', false)
165 - // Stop loading cursor.
166 - .css({'cursor': 'initial'});
167 -
168 - // Stop loading cursor.
169 - $(document.body).css({'cursor': 'initial'});
170 - }
171 -
172 - function showError(msg) {
173 - $errorNotice.find(' > p').html(msg);
174 - $errorNotice.show();
175 - }
176 - });
177 - })(jQuery);
178 -</script>
1 +<?php
2 + /**
3 + * @package Freemius
4 + * @copyright Copyright (c) 2015, Freemius, Inc.
5 + * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6 + * @since 1.2.0
7 + */
8 +
9 + if ( ! defined( 'ABSPATH' ) ) {
10 + exit;
11 + }
12 +
13 + /**
14 + * @var array $VARS
15 + * @var Freemius $fs
16 + */
17 + $fs = freemius( $VARS['id'] );
18 + $slug = $fs->get_slug();
19 +
20 + $message_header = sprintf(
21 + /* translators: %1$s: Number of trial days; %2$s: Plan name; */
22 + fs_text_inline( 'You are 1-click away from starting your %1$s-day free trial of the %2$s plan.', 'start-trial-prompt-header', $slug ),
23 + '<span class="var-trial_period"></span>',
24 + '<span class="var-plan_title"></span>'
25 + );
26 + $message_content = sprintf(
27 + /* translators: %s: Link to freemius.com */
28 + fs_text_inline( 'For compliance with the WordPress.org guidelines, before we start the trial we ask that you opt in with your user and non-sensitive site information, allowing the %s to periodically send data to %s to check for version updates and to validate your trial.', 'start-trial-prompt-message', $slug ),
29 + $fs->get_module_type(),
30 + sprintf(
31 + '<a href="%s" target="_blank" rel="noopener">%s</a>',
32 + 'https://freemius.com',
33 + 'freemius.com'
34 + )
35 + );
36 +
37 + $modal_content_html = <<< HTML
38 + <div class="notice notice-error inline"><p></p></div>
39 + <h3>{$message_header}</h3>
40 + <p>{$message_content}</p>
41 +HTML;
42 +
43 + fs_enqueue_local_style( 'fs_dialog_boxes', '/admin/dialog-boxes.css' );
44 +?>
45 +<script type="text/javascript">
46 + (function ($) {
47 + $(document).ready(function () {
48 + var modalContentHtml = <?php echo json_encode( $modal_content_html ); ?>,
49 + modalHtml =
50 + '<div class="fs-modal fs-modal-license-key-resend">'
51 + + ' <div class="fs-modal-dialog">'
52 + + ' <div class="fs-modal-header">'
53 + + ' <h4><?php echo esc_js( fs_text_x_inline( 'Start free trial', 'call to action', 'start-free-trial', $slug ) ) ?></h4>'
54 + + ' </div>'
55 + + ' <div class="fs-modal-body">' + modalContentHtml + '</div>'
56 + + ' <div class="fs-modal-footer">'
57 + + ' <button class="button button-secondary button-close">' + <?php fs_json_encode_echo_inline( 'Cancel', 'cancel', $slug ) ?> +'</button>'
58 + + ' <button class="button button-primary button-connect">' + <?php fs_json_encode_echo_inline( 'Approve & Start Trial', 'approve-start-trial', $slug ) ?> +'</button>'
59 + + ' </div>'
60 + + ' </div>'
61 + + '</div>',
62 + $modal = $( modalHtml ),
63 + trialData;
64 +
65 + $modal.appendTo($('body'));
66 +
67 + var $errorNotice = $modal.find('.notice-error');
68 +
69 + registerEventHandlers();
70 +
71 + function registerEventHandlers() {
72 + $modal.on('click', '.button-close', function () {
73 + closeModal();
74 + return false;
75 + });
76 +
77 + $modal.on('click', '.button-connect', function (evt) {
78 + evt.preventDefault();
79 +
80 + var $button = $(this);
81 +
82 + $.ajax({
83 + url : <?php echo Freemius::ajax_url() ?>,
84 + method : 'POST',
85 + data : {
86 + action : '<?php echo $fs->get_ajax_action( 'start_trial' ) ?>',
87 + security : '<?php echo $fs->get_ajax_security( 'start_trial' ) ?>',
88 + module_id: '<?php echo $fs->get_id() ?>',
89 + trial : trialData
90 + },
91 + beforeSend: function () {
92 + // Disable all buttons during trial activation.
93 + $modal.find('.button').prop('disabled', true);
94 +
95 + $button.text(<?php fs_json_encode_echo_inline( 'Starting trial', 'starting-trial', $slug ) ?> + '...');
96 +
97 + setLoadingMode();
98 + },
99 + success : function (resultObj) {
100 + if (resultObj.success) {
101 + $button.text(<?php fs_json_encode_echo_inline( 'Please wait', 'please-wait', $slug ) ?> + '...');
102 +
103 + // Redirect to the "Account" page and sync the license.
104 + window.location.href = resultObj.data.next_page;
105 + } else {
106 + $button.text(<?php fs_json_encode_echo( 'approve-start-trial', $slug ) ?>);
107 +
108 + resetLoadingMode();
109 + showError(resultObj.error);
110 + }
111 + }
112 + });
113 + });
114 + }
115 +
116 + window.openTrialConfirmationModal = function showModal(data) {
117 + resetModal();
118 +
119 + // Display the dialog box.
120 + $modal.addClass('active');
121 +
122 + trialData = data;
123 +
124 + var $modalBody = $modal.find('.fs-modal-body'),
125 + $var;
126 +
127 + for (var key in data) {
128 + if (data.hasOwnProperty(key)) {
129 + $var = $modalBody.find('.var-' + key);
130 +
131 + if ($var.length > 0)
132 + $var.html(data[key]);
133 + }
134 + }
135 +
136 + $('body').addClass('has-fs-modal');
137 + };
138 +
139 + function closeModal() {
140 + $modal.removeClass('active');
141 +
142 + $('body').removeClass('has-fs-modal');
143 + }
144 +
145 + function resetModal() {
146 + hideError();
147 + }
148 +
149 + function hideError() {
150 + $errorNotice.hide();
151 + }
152 +
153 + function setLoadingMode() {
154 + $modal.find('.button')
155 + // Re-enable all buttons.
156 + .prop('disabled', trialData)
157 + // Stop loading cursor.
158 + .css({'cursor': 'wait'});
159 +
160 + // Stop loading cursor.
161 + $(document.body).css({'cursor': 'wait'});
162 + }
163 +
164 + function resetLoadingMode() {
165 + $modal.find('.button')
166 + // Re-enable all buttons.
167 + .prop('disabled', false)
168 + // Stop loading cursor.
169 + .css({'cursor': 'initial'});
170 +
171 + // Stop loading cursor.
172 + $(document.body).css({'cursor': 'initial'});
173 + }
174 +
175 + function showError(msg) {
176 + $errorNotice.find(' > p').html(msg);
177 + $errorNotice.show();
178 + }
179 + });
180 + })(jQuery);
181 +</script>