1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
|
<?php /** * @package Freemius * @copyright Copyright (c) 2015, Freemius, Inc. * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 * @since 2.0.0 */
if ( ! defined( 'ABSPATH' ) ) { exit; }
/** * @var array $VARS * @var Freemius $fs * @var FS_Plugin_License $main_license */ $fs = $VARS['freemius']; $slug = $fs->get_slug(); $site = $VARS['site']; $main_license = $VARS['license']; $has_paid_plan = $fs->has_paid_plan(); $is_premium = $fs->is_premium(); $main_user = $fs->get_user(); $blog_id = $site['blog_id'];
$install = $VARS['install']; $is_registered = ! empty( $install ); $license = null; $trial_plan = $fs->get_trial_plan(); $free_text = fs_text_inline( 'Free', 'free', $slug ); ?> <tr class="fs-site-details" data-blog-id="<?php echo $blog_id ?>"<?php if ( $is_registered ) : ?> data-install-id="<?php echo $install->id ?>"<?php endif ?>> <!-- Install ID or Opt-in option --> <td><?php if ( $is_registered ) : ?> <?php echo $install->id ?> <?php else : ?> <?php $action = 'opt_in' ?> <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST"> <input type="hidden" name="fs_action" value="<?php echo $action ?>"> <?php wp_nonce_field( trim( "{$action}:{$blog_id}", ':' ) ) ?> <input type="hidden" name="blog_id" value="<?php echo $blog_id ?>"> <button class="fs-opt-in button button-small"><?php fs_esc_html_echo_inline( 'Opt In', 'opt-in', $slug ) ?></button> </form> <?php endif ?> </td> <!--/ Install ID or Opt-in option -->
<!-- Site URL --> <td class="fs-field-url fs-main-column"><?php echo fs_strip_url_protocol( $site['url'] ) ?></td> <!--/ Site URL -->
<!-- License Activation / Deactivation --> <td><?php if ( $has_paid_plan ) { $view_params = array( 'freemius' => $fs, 'slug' => $slug, 'blog_id' => $blog_id, 'class' => 'button-small', );
$license = null; if ( $is_registered ) { $view_params['install_id'] = $install->id; $view_params['is_localhost'] = $install->is_localhost();
$has_license = FS_Plugin_License::is_valid_id( $install->license_id ); $license = $has_license ? $fs->_get_license_by_id( $install->license_id ) : null; } else { $view_params['is_localhost'] = FS_Site::is_localhost_by_address( $site['url'] ); }
if ( is_object( $license ) ) { $view_params['license'] = $license;
// Show license deactivation button. fs_require_template( 'account/partials/deactivate-license-button.php', $view_params ); } else { if ( is_object( $main_license ) && $main_license->can_activate( $view_params['is_localhost'] ) ) { // Main license is available for activation. $available_license = $main_license; } else { // Try to find any available license for activation. $available_license = $fs->_get_available_premium_license( $view_params['is_localhost'] ); }
if ( is_object( $available_license ) ) { $premium_plan = $fs->_get_plan_by_id( $available_license->plan_id );
$view_params['license'] = $available_license; $view_params['class'] .= ' button-primary'; $view_params['plan'] = $premium_plan;
fs_require_template( 'account/partials/activate-license-button.php', $view_params ); } } } ?></td> <!--/ License Activation / Deactivation -->
<!-- Plan --> <td><?php if ( $is_registered ) : ?> <?php if ( ! $has_paid_plan ) { $plan_title = $free_text; } else { if ( $install->is_trial() ) { if ( $trial_plan->id == $install->trial_plan_id ) { $plan_title = is_string( $trial_plan->name ) ? strtoupper( $trial_plan->title ) : fs_text_inline( 'Trial', 'trial', $slug ); } else { $plan_title = fs_text_inline( 'Trial', 'trial', $slug ); } } else { $plan = $fs->_get_plan_by_id( $install->plan_id ); $plan_title = strtoupper( is_string( $plan->title ) ? $plan->title : strtoupper( $free_text ) ); } } ?> <code><?php echo $plan_title ?></code> <?php endif ?></td> <!--/ Plan -->
<!-- More details button --> <td><?php if ( $is_registered ) : ?> <button class="fs-show-install-details button button-small">More details <i class="dashicons dashicons-arrow-right-alt2"></i> </button><?php endif ?></td> <!--/ More details button --> </tr> <?php if ( $is_registered ) : ?> <!-- More details --> <tr class="fs-install-details" data-install-id="<?php echo $install->id ?>" style="display: none"> <td colspan="5"> <table class="widefat fs-key-value-table"> <tbody> <?php $row_index = 0 ?> <!-- Blog ID --> <tr <?php if ( 1 == $row_index % 2 ) { echo ' class="alternate"'; } ?>> <td> <nobr><?php fs_esc_html_echo_inline( 'Blog ID', 'blog-id', $slug ) ?>:</nobr> </td> <td><code><?php echo $blog_id ?></code></td> <td><?php if ( ! FS_Plugin_License::is_valid_id( $install->license_id ) ) : ?> <!-- Toggle Usage Tracking --> <?php $action = 'toggle_tracking' ?> <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST"> <input type="hidden" name="fs_action" value="<?php echo $action ?>"> <?php wp_nonce_field( trim( "{$action}:{$blog_id}:{$install->id}", ':' ) ) ?> <input type="hidden" name="install_id" value="<?php echo $install->id ?>"> <input type="hidden" name="blog_id" value="<?php echo $blog_id ?>"> <button class="fs-toggle-tracking button button-small<?php if ( $install->is_disconnected ) { echo ' button-primary'; } ?>" data-is-disconnected="<?php echo $install->is_disconnected ? 'true' : 'false' ?>"><?php $install->is_disconnected ? fs_esc_html_echo_inline( 'Opt In', 'opt-in', $slug ) : fs_esc_html_echo_inline( 'Opt Out', 'opt-out', $slug ) ?></button> </form> <!--/ Toggle Usage Tracking --> <?php endif ?></td> </tr> <?php $row_index ++ ?> <!--/ Blog ID -->
<?php if ( $is_registered && $install->user_id != $main_user->id ) : ?> <?php /** * @var FS_User $user */ $user = Freemius::_get_user_by_id( $install->user_id ) ?> <?php if ( is_object( $user ) ) : ?> <!-- User Name --> <tr <?php if ( 1 == $row_index % 2 ) { echo ' class="alternate"'; } ?>> <td> <nobr><?php fs_esc_html_echo_inline( 'Owner Name', 'owner-name', $slug ) ?>:</nobr> </td> <td colspan="2"><code><?php echo htmlspecialchars( $user->get_name() ) ?></code></td> </tr> <?php $row_index ++ ?> <!--/ User Name -->
<!-- User Email --> <tr <?php if ( 1 == $row_index % 2 ) { echo ' class="alternate"'; } ?>> <td> <nobr><?php fs_esc_html_echo_inline( 'Owner Email', 'owner-email', $slug ) ?>:</nobr> </td> <td colspan="2"><code><?php echo htmlspecialchars( $user->email ) ?></code></td> </tr> <?php $row_index ++ ?> <!--/ User Email -->
<!-- User ID --> <tr <?php if ( 1 == $row_index % 2 ) { echo ' class="alternate"'; } ?>> <td> <nobr><?php fs_esc_html_echo_inline( 'Owner ID', 'owner-id', $slug ) ?>:</nobr> </td> <td colspan="2"><code><?php echo $user->id ?></code></td> </tr> <?php $row_index ++ ?> <!--/ User ID --> <?php endif ?> <?php endif ?>
<!-- Public Key --> <tr <?php if ( 1 == $row_index % 2 ) { echo ' class="alternate"'; } ?>> <td> <nobr><?php fs_esc_html_echo_inline( 'Public Key', 'public-key', $slug ) ?>:</nobr> </td> <td colspan="2"><code><?php echo htmlspecialchars( $install->public_key ) ?></code></td> </tr> <?php $row_index ++ ?> <!--/ Public Key -->
<!-- Secret Key --> <tr <?php if ( 1 == $row_index % 2 ) { echo ' class="alternate"'; } ?>> <td> <nobr><?php fs_esc_html_echo_inline( 'Secret Key', 'secret-key', $slug ) ?>:</nobr> </td> <td> <code><?php echo htmlspecialchars( substr( $install->secret_key, 0, 6 ) ) . str_pad( '', 23 * 6, '•' ) . htmlspecialchars( substr( $install->secret_key, - 3 ) ) ?></code> <input type="text" value="<?php echo htmlspecialchars( $install->secret_key ) ?>" style="display: none" readonly/></td> <td><button class="button button-small fs-toggle-visibility"><?php fs_esc_html_echo_x_inline( 'Show', 'verb', 'show', $slug ) ?></button></td> </tr> <?php $row_index ++ ?> <!--/ Secret Key -->
<?php if ( is_object( $license ) ) : ?> <!-- License Key --> <tr <?php if ( 1 == $row_index % 2 ) { echo ' class="alternate"'; } ?>> <td> <nobr><?php fs_esc_html_echo_inline( 'License Key', 'license-key', $slug ) ?>:</nobr> </td> <td> <code><?php echo htmlspecialchars( substr( $license->secret_key, 0, 6 ) ) . str_pad( '', 23 * 6, '•' ) . htmlspecialchars( substr( $license->secret_key, - 3 ) ) ?></code> <input type="text" value="<?php echo htmlspecialchars( $license->secret_key ) ?>" style="display: none" readonly/></td> <td> <button class="button button-small fs-toggle-visibility"><?php fs_esc_html_echo_x_inline( 'Show', 'verb', 'show', $slug ) ?></button> <button class="button button-small activate-license-trigger <?php echo $fs->get_unique_affix() ?>"><?php fs_esc_html_echo_inline( 'Change License', 'change-license', $slug ) ?></button> </td> </tr> <?php $row_index ++ ?> <!--/ License Key -->
<?php if ( ! is_object( $main_license ) || $main_license->id != $license->id ) : ?> <?php $subscription = $fs->_get_subscription( $license->id ) ?> <?php if ( ! $license->is_lifetime() && is_object( $subscription ) ) : ?> <!-- Subscription --> <tr <?php if ( 1 == $row_index % 2 ) { echo ' class="alternate"'; } ?>> <td> <nobr><?php fs_esc_html_echo_inline( 'Subscription', 'subscription', $slug ) ?>:</nobr> </td> <?php $is_active_subscription = $subscription->is_active();
$renews_in_text = fs_text_inline( 'Auto renews in %s', 'renews-in', $slug ); /* translators: %s: Time period (e.g. Expires in "2 months") */ $expires_in_text = fs_text_inline( 'Expires in %s', 'expires-in', $slug ); ?> <td> <code><?php echo $subscription->id ?> - <?php echo ( 12 == $subscription->billing_cycle ? _fs_text_inline( 'Annual', 'annual', $slug ) : _fs_text_inline( 'Monthly', 'monthly', $slug ) ); ?> </code> <?php if ( ! $is_active_subscription && ! $license->is_first_payment_pending() ) : ?> <label class="fs-tag fs-warn"><?php echo esc_html( sprintf( $expires_in_text, human_time_diff( time(), strtotime( $license->expiration ) ) ) ) ?></label> <?php elseif ( $is_active_subscription && ! $subscription->is_first_payment_pending() ) : ?> <label class="fs-tag fs-success"><?php echo esc_html( sprintf( $renews_in_text, human_time_diff( time(), strtotime( $subscription->next_payment ) ) ) ) ?></label> <?php endif ?> </td> <td><?php if ( $is_active_subscription ) : ?> <?php $downgrading_plan_text = fs_text_inline( 'Downgrading your plan', 'downgrading-plan', $slug ); $cancelling_subscription_text = fs_text_inline( 'Cancelling the subscription', 'cancelling-subscription', $slug ); /* translators: %1$s: Either 'Downgrading your plan' or 'Cancelling the subscription' */ $downgrade_x_confirm_text = fs_text_inline( '%1$s will immediately stop all future recurring payments and your %s plan license will expire in %s.', 'downgrade-x-confirm', $slug ); $prices_increase_text = fs_text_inline( 'Please note that we will not be able to grandfather outdated pricing for renewals/new subscriptions after a cancellation. If you choose to renew the subscription manually in the future, after a price increase, which typically occurs once a year, you will be charged the updated price.', 'pricing-increase-warning', $slug ); $after_downgrade_non_blocking_text = fs_text_inline( 'You can still enjoy all %s features but you will not have access to %s security & feature updates, nor support.', 'after-downgrade-non-blocking', $slug ); $after_downgrade_blocking_text = fs_text_inline( 'Once your license expires you can still use the Free version but you will NOT have access to the %s features.', 'after-downgrade-blocking', $slug ); $downgrade_text = fs_text_x_inline( 'Downgrade', 'verb', 'downgrade', $slug );
$human_readable_license_expiration = human_time_diff( time(), strtotime( $license->expiration ) ); $downgrade_confirmation_message = sprintf( $downgrade_x_confirm_text, ( $fs->is_only_premium() ? $cancelling_subscription_text : $downgrading_plan_text ), $plan->title, $human_readable_license_expiration );
$after_downgrade_message = ! $license->is_block_features ? sprintf( $after_downgrade_non_blocking_text, $plan->title, $fs->get_module_label( true ) ) : sprintf( $after_downgrade_blocking_text, $plan->title ); ?> <?php $action = 'downgrade_account' ?> <form id="fs_downgrade" action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST"> <input type="hidden" name="fs_action" value="<?php echo $action ?>"> <?php wp_nonce_field( trim( "{$action}:{$blog_id}", ':' ) ) ?> <input type="hidden" name="blog_id" value="<?php echo $blog_id ?>"> <button class="button button-small" onclick="if (confirm('<?php echo esc_attr( $downgrade_confirmation_message . ' ' . $after_downgrade_message . ' ' . $prices_increase_text ) ?>')) { this.parentNode.submit(); } else { return false; }"><?php echo $downgrade_text ?></button> </form> <?php endif ?></td> </tr> <?php $row_index ++ ?> <?php endif ?> <!--/ Subscription --> <?php endif ?> <?php endif ?>
</tbody> </table> </td> </tr> <!--/ More details --> <?php endif ?>
|