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