PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 2.0.1
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v2.0.1
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 / forms / optout.php
embedpress / freemius / templates / forms Last commit date
deactivation 9 years ago index.php 9 years ago license-activation.php 9 years ago optout.php 9 years ago resend-key.php 9 years ago trial-start.php 9 years ago
optout.php
223 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.2.1.5
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 $action = $fs->is_tracking_allowed() ?
21 'stop_tracking' :
22 'allow_tracking';
23
24 $plugin_title = "<strong>{$fs->get_plugin()->title}</strong>";
25 $opt_out_button_text = fs_text( 'opt-out', $slug );
26 // @todo Change 'plugin' with module type when migrating with 1.2.2 (themes version).
27 $opt_out_message_appreciation = sprintf( fs_text( 'opt-out-message-appreciation', $slug ), 'plugin' );
28 $opt_out_message_usage_tracking = sprintf( fs_text( 'opt-out-message-usage-tracking', $slug ), $plugin_title );
29 $opt_out_message_clicking_opt_out = sprintf(
30 fs_text( 'opt-out-message-clicking-opt-out', $slug ),
31 $plugin_title,
32 sprintf(
33 '<a href="%s" target="_blank">%s</a>',
34 'https://freemius.com',
35 'freemius.com'
36 )
37 );
38
39 $admin_notice_params = array(
40 'id' => '',
41 'slug' => $fs->get_id(),
42 'type' => 'success',
43 'sticky' => false,
44 'plugin' => $fs->get_plugin()->title,
45 'message' => $opt_out_message_appreciation
46 );
47
48 $admin_notice_html = fs_get_template( 'admin-notice.php', $admin_notice_params );
49
50 $modal_content_html = <<< HTML
51 <h2>{$opt_out_message_appreciation}</h2>
52 <div class="notice notice-error inline opt-out-error-message"><p></p></div>
53 <p>{$opt_out_message_usage_tracking}</p>
54 <p>{$opt_out_message_clicking_opt_out}</p>
55 HTML;
56
57 fs_enqueue_local_style( 'dialog-boxes', '/admin/dialog-boxes.css' );
58 fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
59 ?>
60 <script type="text/javascript">
61 (function( $ ) {
62 $( document ).ready(function() {
63 var modalContentHtml = <?php echo json_encode( $modal_content_html ) ?>,
64 modalHtml =
65 '<div class="fs-modal fs-modal-opt-out">'
66 + ' <div class="fs-modal-dialog">'
67 + ' <div class="fs-modal-header">'
68 + ' <h4><?php echo esc_js($opt_out_button_text) ?></h4>'
69 + ' </div>'
70 + ' <div class="fs-modal-body">'
71 + ' <div class="fs-modal-panel active">' + modalContentHtml + '</div>'
72 + ' </div>'
73 + ' <div class="fs-modal-footer">'
74 + ' <button class="button button-secondary button-opt-out" tabindex="1"><?php echo esc_js($opt_out_button_text) ?></button>'
75 + ' <button class="button button-primary button-close" tabindex="2"><?php fs_esc_js_echo( 'opt-out-cancel', $slug ) ?></button>'
76 + ' </div>'
77 + ' </div>'
78 + '</div>',
79 $modal = $( modalHtml ),
80 $adminNotice = $( <?php echo json_encode( $admin_notice_html ) ?> ),
81 action = '<?php echo $action ?>',
82 $actionLink = $( 'span.opt-in-or-opt-out.<?php echo $slug ?> a' ),
83 $optOutButton = $modal.find( '.button-opt-out' ),
84 $optOutErrorMessage = $modal.find( '.opt-out-error-message' ),
85 pluginSlug = '<?php echo $slug ?>';
86
87 $actionLink.attr( 'data-action', action );
88 $modal.appendTo( $( 'body' ) );
89
90 function registerEventHandlers() {
91 $actionLink.click(function( evt ) {
92 evt.preventDefault();
93
94 if ( 'stop_tracking' == $actionLink.attr( 'data-action' ) ) {
95 showModal();
96 } else {
97 optIn();
98 }
99 });
100
101 $modal.on( 'click', '.button-opt-out', function( evt ) {
102 evt.preventDefault();
103
104 if ( $( this ).hasClass( 'disabled' ) ) {
105 return;
106 }
107
108 disableOptOutButton();
109 optOut();
110 });
111
112 // If the user has clicked outside the window, close the modal.
113 $modal.on( 'click', '.fs-close, .button-close', function() {
114 closeModal();
115 return false;
116 });
117 }
118
119 registerEventHandlers();
120
121 function showModal() {
122 resetModal();
123
124 // Display the dialog box.
125 $modal.addClass( 'active' );
126 $( 'body' ).addClass( 'has-fs-modal' );
127 }
128
129 function closeModal() {
130 $modal.removeClass( 'active' );
131 $( 'body' ).removeClass( 'has-fs-modal' );
132 }
133
134 function resetOptOutButton() {
135 enableOptOutButton();
136 $optOutButton.text( <?php echo json_encode( $opt_out_button_text ) ?> );
137 }
138
139 function resetModal() {
140 hideError();
141 resetOptOutButton();
142 }
143
144 function optIn() {
145 sendRequest();
146 }
147
148 function optOut() {
149 sendRequest();
150 }
151
152 function sendRequest() {
153 $.ajax({
154 url: ajaxurl,
155 method: 'POST',
156 data: {
157 action : ( 'stop_tracking' == action ?
158 '<?php echo $fs->get_ajax_action( 'stop_tracking' ) ?>' :
159 '<?php echo $fs->get_ajax_action( 'allow_tracking' ) ?>'
160 ),
161 security : ( 'stop_tracking' == action ?
162 '<?php echo $fs->get_ajax_security( 'stop_tracking' ) ?>' :
163 '<?php echo $fs->get_ajax_security( 'allow_tracking' ) ?>'
164 ),
165 slug : pluginSlug
166 },
167 beforeSend: function() {
168 if ( 'opt-in' == action ) {
169 $actionLink.text( <?php fs_json_encode_echo( 'opting-in', $slug ) ?> );
170 } else {
171 $optOutButton.text( <?php fs_json_encode_echo( 'opting-out', $slug ) ?> );
172 }
173 },
174 success: function( resultObj ) {
175 if ( resultObj.success ) {
176 if ( 'allow_tracking' == action ) {
177 action = 'stop_tracking';
178 $actionLink.text( <?php fs_json_encode_echo( 'opt-out', $slug ) ?> );
179 showOptInAppreciationMessageAndScrollToTop();
180 } else {
181 action = 'allow_tracking';
182 $actionLink.text( <?php fs_json_encode_echo( 'opt-in', $slug ) ?> );
183 closeModal();
184
185 if ( $adminNotice.length > 0 ) {
186 $adminNotice.remove();
187 }
188 }
189
190 $actionLink.attr( 'data-action', action );
191 } else {
192 showError( resultObj.error );
193 resetOptOutButton();
194 }
195 }
196 });
197 }
198
199 function enableOptOutButton() {
200 $optOutButton.removeClass( 'disabled' );
201 }
202
203 function disableOptOutButton() {
204 $optOutButton.addClass( 'disabled' );
205 }
206
207 function hideError() {
208 $optOutErrorMessage.hide();
209 }
210
211 function showOptInAppreciationMessageAndScrollToTop() {
212 $adminNotice.insertAfter( $( '#wpbody-content' ).find( ' > .wrap > h1' ) );
213 window.scrollTo(0, 0);
214 }
215
216 function showError( msg ) {
217 $optOutErrorMessage.find( ' > p' ).html( msg );
218 $optOutErrorMessage.show();
219 }
220 });
221 })( jQuery );
222 </script>
223