PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / trunk
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites vtrunk
4.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.1.2 2.5.0 2.5.3 2.6.1 All 38 releases
← All changes | freemius/templates/forms/optout.php +144 -297 1.3.2trunk View file →
@@ -16,321 +16,168 @@
16 16 */
17 17 $fs = freemius( $VARS['id'] );
18 18 $slug = $fs->get_slug();
19 19
20 - $action = $fs->is_tracking_allowed() ?
21 - 'stop_tracking' :
22 - 'allow_tracking';
23 -
24 20 $reconnect_url = $fs->get_activation_url( array(
25 21 'nonce' => wp_create_nonce( $fs->get_unique_affix() . '_reconnect' ),
26 22 'fs_action' => ( $fs->get_unique_affix() . '_reconnect' ),
27 23 ) );
28 24
29 - $plugin_title = "<strong>{$fs->get_plugin()->title}</strong>";
30 - $opt_out_text = fs_text_x_inline( 'Opt Out', 'verb', 'opt-out', $slug );
31 - $opt_in_text = fs_text_x_inline( 'Opt In', 'verb', 'opt-in', $slug );
25 + $plugin_title = "<strong>" . esc_html( $fs->get_plugin()->title ) . "</strong>";
26 + $opt_out_text = fs_text_x_inline( 'Opt Out', 'verb', 'opt-out', $slug );
32 27
33 - if ( $fs->is_premium() ) {
34 - $opt_in_message_appreciation = fs_text_inline( 'Connectivity to the licensing engine was successfully re-established. Automatic security & feature updates are now available through the WP Admin Dashboard.', 'premium-opt-in-message-appreciation', $slug );
28 + $permission_manager = FS_Permission_Manager::instance( $fs );
35 29
36 - $opt_out_message_subtitle = sprintf( fs_text_inline( 'Warning: Opting out will block automatic updates', 'premium-opt-out-message-appreciation', $slug ), $fs->get_module_type() );
37 - $opt_out_message_usage_tracking = sprintf( fs_text_inline( 'Ongoing connectivity with the licensing engine is essential for receiving automatic security & feature updates of the paid product. To receive these updates, data like your license key, %1$s version, and WordPress version, is periodically sent to the server to check for updates. By opting out, you understand that your site won\'t receive automatic updates for %2$s from within the WP Admin Dashboard. This can put your site at risk, and we highly recommend to keep this connection active. If you do choose to opt-out, you\'ll need to check for %1$s updates and install them manually.', 'premium-opt-out-message-usage-tracking', $slug ), $fs->get_module_type(), $plugin_title );
30 + fs_enqueue_local_style( 'fs_dialog_boxes', '/admin/dialog-boxes.css' );
31 + fs_enqueue_local_style( 'fs_optout', '/admin/optout.css' );
32 + fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
38 33
39 - $primary_cta_label = fs_text_inline( 'I\'d like to keep automatic updates', 'premium-opt-out-cancel', $slug );
40 - } else {
41 - $opt_in_message_appreciation = sprintf( fs_text_inline( 'We appreciate your help in making the %s better by letting us track some usage data.', 'opt-in-message-appreciation', $slug ), $fs->get_module_type() );
34 + if ( ! $permission_manager->is_premium_context() ) {
35 + $optional_permissions = array( $permission_manager->get_extensions_permission( false,
36 + false,
37 + true
38 + ) );
42 39
43 - $opt_out_message_subtitle = $opt_in_message_appreciation;
44 - $opt_out_message_usage_tracking = sprintf( fs_text_inline( "Usage tracking is done in the name of making %s better. Making a better user experience, prioritizing new features, and more good things. We'd really appreciate if you'll reconsider letting us continue with the tracking.", 'opt-out-message-usage-tracking', $slug ), $plugin_title );
45 - $primary_cta_label = fs_text_inline( 'On second thought - I want to continue helping', 'opt-out-cancel', $slug );
46 - }
40 + $permission_groups = array(
41 + array(
42 + 'id' => 'communication',
43 + 'type' => 'required',
44 + 'title' => $fs->get_text_inline( 'Communication', 'communication' ),
45 + 'desc' => '',
46 + 'permissions' => $permission_manager->get_opt_in_required_permissions( true ),
47 + 'is_enabled' => $fs->is_registered(),
48 + 'prompt' => array(
49 + $fs->esc_html_inline( "Sharing your name and email allows us to keep you in the loop about new features and important updates, warn you about security issues before they become public knowledge, and send you special offers.", 'opt-out-message_user' ),
50 + sprintf(
51 + $fs->esc_html_inline( 'By clicking "Opt Out", %s will no longer be able to view your name and email.',
52 + 'opt-out-message-clicking-opt-out' ),
53 + $plugin_title
54 + ),
55 + ),
56 + 'prompt_cancel_label' => $fs->get_text_inline( 'Stay Connected', 'stay-connected' )
57 + ),
58 + array(
59 + 'id' => 'diagnostic',
60 + 'type' => 'required',
61 + 'title' => $fs->get_text_inline( 'Diagnostic Info', 'diagnostic-info' ),
62 + 'desc' => '',
63 + 'permissions' => $permission_manager->get_opt_in_diagnostic_permissions( true ),
64 + 'is_enabled' => $fs->is_tracking_allowed(),
65 + 'prompt' => array(
66 + sprintf(
67 + $fs->esc_html_inline( 'Sharing diagnostic data helps to provide additional functionality that\'s relevant to your website, avoid WordPress or PHP version incompatibilities that can break the website, and recognize which languages & regions the %s should be translated and tailored to.',
68 + 'opt-out-message-clicking-opt-out' ),
69 + $fs->get_module_type()
70 + ),
71 + sprintf(
72 + $fs->esc_html_inline( 'By clicking "Opt Out", diagnostic data will no longer be sent to %s.',
73 + 'opt-out-message-clicking-opt-out' ),
74 + $plugin_title
75 + ),
76 + ),
77 + 'prompt_cancel_label' => $fs->get_text_inline( 'Keep Sharing', 'keep-sharing' )
78 + ),
79 + array(
80 + 'id' => 'extensions',
81 + 'type' => 'optional',
82 + 'title' => $fs->get_text_inline( 'Extensions', 'extensions' ),
83 + 'desc' => '',
84 + 'permissions' => $optional_permissions,
85 + ),
86 + );
87 + } else {
88 + $optional_permissions = $permission_manager->get_license_optional_permissions( false, true );
47 89
48 - $opt_out_message_clicking_opt_out = sprintf(
49 - fs_text_inline( 'By clicking "Opt Out", we will no longer be sending any data from %s to %s.', 'opt-out-message-clicking-opt-out', $slug ),
50 - $plugin_title,
51 - sprintf(
52 - '<a href="%s" target="_blank" rel="noopener">%s</a>',
53 - 'https://freemius.com',
54 - 'freemius.com'
55 - )
56 - );
90 + $permission_groups = array(
91 + array(
92 + 'id' => 'essentials',
93 + 'type' => 'required',
94 + 'title' => $fs->esc_html_inline( 'Required', 'required' ),
95 + 'desc' => sprintf( $fs->esc_html_inline( 'For automatic delivery of security & feature updates, and license management & protection, %s needs to:',
96 + 'license-sync-disclaimer' ),
97 + '<b>' . esc_html( $fs->get_plugin_title() ) . '</b>' ),
98 + 'permissions' => $permission_manager->get_license_required_permissions( true ),
99 + 'is_enabled' => $permission_manager->is_essentials_tracking_allowed(),
100 + 'prompt' => array(
101 + sprintf( $fs->esc_html_inline( 'To ensure that security & feature updates are automatically delivered directly to your WordPress Admin Dashboard while protecting your license from unauthorized abuse, %2$s needs to view the website’s homepage URL, %1$s version, SDK version, and whether the %1$s is active.', 'premium-opt-out-message-usage-tracking' ), $fs->get_module_type(), $plugin_title ),
102 + sprintf( $fs->esc_html_inline( 'By opting out from sharing this information with the updates server, you’ll have to check for new %1$s releases and manually download & install them. Not just a hassle, but missing an update can put your site at risk and cause undue compatibility issues, so we highly recommend keeping these essential permissions on.', 'opt-out-message-clicking-opt-out' ), $fs->get_module_type(), $plugin_title ),
103 + ),
104 + 'prompt_cancel_label' => $fs->get_text_inline( 'Keep automatic updates', 'premium-opt-out-cancel' )
105 + ),
106 + array(
107 + 'id' => 'optional',
108 + 'type' => 'optional',
109 + 'title' => $fs->esc_html_inline( 'Optional', 'optional' ),
110 + 'desc' => sprintf( $fs->esc_html_inline( 'For ongoing compatibility with your website, you can optionally allow %s to:',
111 + 'optional-permissions-disclaimer' ), $plugin_title ),
112 + 'permissions' => $optional_permissions,
113 + ),
114 + );
115 + }
57 116
58 - $admin_notice_params = array(
59 - 'id' => '',
60 - 'slug' => $fs->get_id(),
61 - 'type' => 'success',
62 - 'sticky' => false,
63 - 'plugin' => $fs->get_plugin()->title,
64 - 'message' => $opt_in_message_appreciation
65 - );
117 + $ajax_action = 'toggle_permission_tracking';
66 118
67 - $admin_notice_html = fs_get_template( 'admin-notice.php', $admin_notice_params );
119 + $form_id = "fs_opt_out_{$fs->get_id()}";
120 +?>
121 +<div id="<?php echo esc_attr( $form_id ) ?>"
122 + class="fs-modal fs-modal-opt-out"
123 + data-plugin-id="<?php echo esc_attr( $fs->get_id() ) ?>"
124 + data-action="<?php echo esc_attr( $fs->get_ajax_action( $ajax_action ) ) ?>"
125 + data-security="<?php echo esc_attr( $fs->get_ajax_security( $ajax_action ) ) ?>"
126 + style="display: none">
127 + <div class="fs-modal-dialog">
128 + <div class="fs-modal-header">
129 + <h4><?php echo esc_html( $opt_out_text ) ?></h4>
130 + <a href="!#" class="fs-close"><i class="dashicons dashicons-no" title="Dismiss"></i></a>
131 + </div>
132 + <div class="fs-opt-out-permissions">
133 + <div class="fs-modal-body">
134 + <div class="notice notice-error inline opt-out-error-message"><p></p></div>
135 + <div class="fs-permissions fs-open">
136 + <?php foreach ( $permission_groups as $i => $permission_group ) : ?>
137 + <?php $permission_manager->render_permissions_group( $permission_group ) ?>
138 + <?php if ( $i < count( $permission_groups ) - 1 ) : ?><hr><?php endif ?>
139 + <?php endforeach ?>
140 + </div>
141 + </div>
142 + <div class="fs-modal-footer">
143 + <button class="button button-primary button-close" tabindex="1"><?php echo $fs->esc_html_inline( 'Done', 'done' ) ?></button>
144 + </div>
145 + </div>
146 + <?php foreach ( $permission_groups as $i => $permission_group ) : ?>
147 + <?php if ( ! empty( $permission_group[ 'prompt' ] ) ) : ?>
148 + <div class="fs-<?php echo esc_attr( $permission_group[ 'id' ] ) ?>-opt-out fs-opt-out-disclaimer" data-group-id="<?php echo esc_attr( $permission_group[ 'id' ] ) ?>" style="display: none">
149 + <div class="fs-modal-body">
150 + <div class="fs-modal-panel active">
151 + <div class="notice notice-error inline opt-out-error-message"><p></p></div>
152 + <?php foreach ( $permission_group[ 'prompt' ] as $p ) : ?>
153 + <?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
154 + <p><?php echo $p ?></p>
155 + <?php endforeach ?>
156 + </div>
157 + </div>
158 + <div class="fs-modal-footer">
159 + <a class="fs-opt-out-button" tabindex="2" href="#"><?php echo esc_html( $opt_out_text ) ?></a>
160 + <button class="button button-primary fs-opt-out-cancel-button" tabindex="1"><?php echo esc_html( $permission_group[ 'prompt_cancel_label' ] ) ?></button>
161 + </div>
162 + </div>
163 + <?php endif ?>
164 + <?php endforeach ?>
165 + </div>
166 +</div>
68 167
69 - $modal_content_html = "
70 - <h2" . ( $fs->is_premium() ? ' style="color: red"' : '' ) . ">{$opt_out_message_subtitle}</h2>
71 - <div class=\"notice notice-error inline opt-out-error-message\"><p></p></div>
72 - <p>{$opt_out_message_usage_tracking}</p>
73 - <p>{$opt_out_message_clicking_opt_out}</p>
74 - <label class=\"fs-permission-extensions\"><div class=\"fs-switch fs-small fs-round fs-" . ( $fs->is_extensions_tracking_allowed() ? 'on' : 'off' ) . "\"><div class=\"fs-toggle\"></div></div> " . fs_text_inline( 'Plugins & themes tracking' ) . " <span class=\"fs-switch-feedback success\"></span></label>";
168 +<?php $permission_manager->require_permissions_js( false ) ?>
75 169
76 - fs_enqueue_local_style( 'fs_dialog_boxes', '/admin/dialog-boxes.css' );
77 - fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
78 -?>
79 170 <script type="text/javascript">
80 171 (function( $ ) {
81 172 $( document ).ready(function() {
82 - var modalContentHtml = <?php echo json_encode( $modal_content_html ) ?>,
83 - modalHtml =
84 - '<div class="fs-modal fs-modal-opt-out">'
85 - + ' <div class="fs-modal-dialog">'
86 - + ' <div class="fs-modal-header">'
87 - + ' <h4><?php echo esc_js( $opt_out_text ) ?></h4>'
88 - + ' </div>'
89 - + ' <div class="fs-modal-body">'
90 - + ' <div class="fs-modal-panel active">' + modalContentHtml + '</div>'
91 - + ' </div>'
92 - + ' <div class="fs-modal-footer">'
93 - + ' <button class="button <?php echo $fs->is_premium() ? 'button-primary warn' : 'button-secondary' ?> button-opt-out" tabindex="1"><?php echo esc_js( $opt_out_text ) ?></button>'
94 - + ' <button class="button <?php echo $fs->is_premium() ? 'button-secondary' : 'button-primary' ?> button-close" tabindex="2"><?php echo esc_js( $primary_cta_label ) ?></button>'
95 - + ' </div>'
96 - + ' </div>'
97 - + '</div>',
98 - $modal = $(modalHtml),
99 - $adminNotice = $( <?php echo json_encode( $admin_notice_html ) ?> ),
100 - action = '<?php echo $action ?>',
101 - actionLinkSelector = 'span.opt-in-or-opt-out.<?php echo $slug ?> a',
102 - $optOutButton = $modal.find( '.button-opt-out' ),
103 - $optOutErrorMessage = $modal.find( '.opt-out-error-message' ),
104 - $extensionsTracking = $modal.find( '.fs-permission-extensions' ),
105 - $body = $( 'body' ),
106 - moduleID = '<?php echo $fs->get_id() ?>';
107 -
108 - $modal.data( 'action', action );
109 - $modal.appendTo( $body );
110 -
111 - function registerActionLinkClick() {
112 - $body.on( 'click', actionLinkSelector, function( evt ) {
113 - evt.preventDefault();
114 -
115 - if ( 'stop_tracking' == $modal.data( 'action' ) ) {
116 - showModal();
117 - } else {
118 - optIn();
119 - }
120 -
121 - return false;
122 - });
123 - }
124 -
125 - function registerEventHandlers() {
126 - registerActionLinkClick();
127 -
128 - $modal.on( 'click', '.button-opt-out', function( evt ) {
129 - evt.preventDefault();
130 -
131 - if ( $( this ).hasClass( 'disabled' ) ) {
132 - return;
133 - }
134 -
135 - disableOptOutButton();
136 - optOut();
137 - });
138 -
139 - // If the user has clicked outside the window, close the modal.
140 - $modal.on( 'click', '.fs-close, .button-close', function() {
141 - closeModal();
142 - return false;
143 - });
144 - }
145 -
146 - <?php if ( $fs->is_registered() ) : ?>
147 - registerEventHandlers();
148 - <?php endif ?>
149 -
150 - function showModal() {
151 - resetModal();
152 -
153 - // Display the dialog box.
154 - $modal.addClass( 'active' );
155 - $body.addClass( 'has-fs-modal' );
156 - }
157 -
158 - function closeModal() {
159 - $modal.removeClass( 'active' );
160 - $body.removeClass( 'has-fs-modal' );
161 - }
162 -
163 - function resetOptOutButton() {
164 - enableOptOutButton();
165 - $optOutButton.text( <?php echo json_encode( $opt_out_text ) ?> );
166 - }
167 -
168 - function resetModal() {
169 - hideError();
170 - resetOptOutButton();
171 - }
172 -
173 - function optIn() {
174 - sendRequest();
175 - }
176 -
177 - function optOut() {
178 - sendRequest();
179 - }
180 -
181 - function sendRequest() {
182 - var $actionLink = $( actionLinkSelector );
183 -
184 - $.ajax({
185 - url: ajaxurl,
186 - method: 'POST',
187 - data: {
188 - action : ( 'stop_tracking' == action ?
189 - '<?php echo $fs->get_ajax_action( 'stop_tracking' ) ?>' :
190 - '<?php echo $fs->get_ajax_action( 'allow_tracking' ) ?>'
191 - ),
192 - security : ( 'stop_tracking' == action ?
193 - '<?php echo $fs->get_ajax_security( 'stop_tracking' ) ?>' :
194 - '<?php echo $fs->get_ajax_security( 'allow_tracking' ) ?>'
195 - ),
196 - module_id: moduleID,
197 - _wp_http_referer: '<?php echo $fs->current_page_url() ?>'
198 - },
199 - beforeSend: function() {
200 - if ( 'allow_tracking' == action ) {
201 - $actionLink.text( '<?php fs_esc_js_echo_inline( 'Opting in', 'opting-in', $slug ) ?>...' );
202 - } else {
203 - $optOutButton.text( '<?php fs_esc_js_echo_inline( 'Opting out', 'opting-out', $slug ) ?>...' );
204 - }
205 - },
206 - success: function( resultObj ) {
207 - if ( resultObj.success ) {
208 - if ( 'allow_tracking' == action ) {
209 - action = 'stop_tracking';
210 - $actionLink.text( '<?php echo esc_js( $opt_out_text ) ?>' );
211 - showOptInAppreciationMessageAndScrollToTop();
212 - } else {
213 - action = 'allow_tracking';
214 - $actionLink.text( '<?php echo esc_js( $opt_in_text ) ?>' );
215 - closeModal();
216 -
217 - if ( $adminNotice.length > 0 ) {
218 - $adminNotice.remove();
219 - }
220 - }
221 -
222 - $modal.data( 'action', action );
223 - } else {
224 - showError( resultObj.error );
225 - resetOptOutButton();
226 - }
227 - }
228 - });
229 - }
230 -
231 - var isUpdatingPermission = false;
232 - $extensionsTracking.on('click', function() {
233 - if (isUpdatingPermission) {
234 - return false;
235 - }
236 -
237 - isUpdatingPermission = true;
238 -
239 - var $switch = $extensionsTracking.find( '.fs-switch' ),
240 - $switchFeedback = $extensionsTracking.find( '.fs-switch-feedback' );
241 -
242 - $switch
243 - .toggleClass( 'fs-on' )
244 - .toggleClass( 'fs-off' );
245 -
246 - $switchFeedback.html( '<i class="fs-ajax-spinner"></i>' );
247 -
248 - $.ajax({
249 - url: ajaxurl,
250 - method: 'POST',
251 - data: {
252 - action : '<?php echo $fs->get_ajax_action( 'update_tracking_permission' ) ?>',
253 - security : '<?php echo $fs->get_ajax_security( 'update_tracking_permission' ) ?>',
254 - module_id : moduleID,
255 - _wp_http_referer: '<?php echo $fs->current_page_url() ?>',
256 - permission: 'extensions',
257 - is_enabled: $switch.hasClass('fs-on')
258 - },
259 - success: function( resultObj ) {
260 - if ( resultObj.success ) {
261 - $switchFeedback.html( '<i class="dashicons dashicons-yes"></i> <?php echo esc_js( fs_text_inline( 'Saved', 'saved', $slug ) ) ?>' )
262 - } else {
263 - $switch
264 - .toggleClass( 'fs-on' )
265 - .toggleClass( 'fs-off' );
266 - }
267 -
268 - isUpdatingPermission = false;
269 - }
270 - });
271 - });
272 -
273 - function enableOptOutButton() {
274 - $optOutButton.removeClass( 'disabled' );
275 - }
276 -
277 - function disableOptOutButton() {
278 - $optOutButton.addClass( 'disabled' );
279 - }
280 -
281 - function hideError() {
282 - $optOutErrorMessage.hide();
283 - }
284 -
285 - function showOptInAppreciationMessageAndScrollToTop() {
286 - $adminNotice.insertAfter( $( '#wpbody-content' ).find( ' > .wrap > h1' ) );
287 - window.scrollTo(0, 0);
288 - }
289 -
290 - function showError( msg ) {
291 - $optOutErrorMessage.find( ' > p' ).html( msg );
292 - $optOutErrorMessage.show();
293 - }
294 -
295 - <?php if ( $fs->is_theme() ) : ?>
296 - /**
297 - * Add opt-in/out button to the active theme's buttons collection
298 - * in the theme's extended details overlay.
299 - *
300 - * @author Vova Feldman (@svovaf)
301 - * @since 1.2.2.7
302 - */
303 - $('.theme-overlay').contentChange(function () {
304 - if (0 === $('.theme-overlay.active').length) {
305 - // Add opt-in/out button only to the currently active theme.
306 - return;
307 - }
308 -
309 - if ($('#fs_theme_opt_in_out').length > 0){
310 - // Button already there.
311 - return;
312 - }
313 -
314 - var label = (('stop_tracking' == action) ?
315 - '<?php echo esc_js( $opt_out_text ) ?>' :
316 - '<?php echo esc_js( $opt_in_text ) ?>'),
317 - href = (('stop_tracking' != action) ?
318 - '<?php echo ( $fs->is_registered() ? '' : esc_js( $reconnect_url ) ) ?>' :
319 - '');
320 -
321 - var $actionLink = $('<a id="fs_theme_opt_in_out" href="' + encodeURI(href) + '" class="button">' + label + '</a>');
322 -
323 - actionLinkSelector = '#fs_theme_opt_in_out';
324 -
325 - $modal.data( 'action', action );
326 -
327 - $('.theme-wrap .theme-actions .active-theme').append($actionLink);
328 -
329 - if ('' === href) {
330 - registerActionLinkClick();
331 - }
332 - });
333 - <?php endif ?>
173 + FS.OptOut(
174 + <?php echo wp_json_encode( $fs->get_id() ) ?>,
175 + <?php echo wp_json_encode( $slug ) ?>,
176 + <?php echo wp_json_encode( $fs->get_module_type() ) ?>,
177 + <?php echo $fs->is_registered( true ) ? 'true' : 'false' ?>,
178 + <?php echo $fs->is_tracking_allowed() ? 'true' : 'false' ?>,
179 + <?php echo wp_json_encode( $reconnect_url ) ?>
180 + );
334 181 });
335 182 })( jQuery );
336 183 </script>