PluginProbe ʕ •ᴥ•ʔ
Auto Post Cleaner / 3.10.2
Auto Post Cleaner v3.10.2
3.12.0 3.13.1 3.2.4 3.2.5 3.3.0 3.3.10 3.3.11 3.3.8 3.4.2 3.5.3 3.6.0 3.7.0 3.7.1 3.7.2 3.7.3 3.7.5 3.7.6 3.8.0 3.9.0 3.9.4 3.9.6 3.9.7 trunk 3.0.0 3.1.0 3.10.1 3.10.2 3.11.4
delete-old-posts-programmatically / freemius / templates / account / partials / addon.php
delete-old-posts-programmatically / freemius / templates / account / partials Last commit date
activate-license-button.php 5 years ago addon.php 2 years ago deactivate-license-button.php 5 years ago disconnect-button.php 3 years ago index.php 5 years ago site.php 3 years ago
addon.php
452 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 /**
8 * @var array $VARS
9 * @var Freemius $fs
10 */
11 $fs = $VARS['parent_fs'];
12 $addon_id = $VARS['addon_id'];
13 $odd = $VARS['odd'];
14 $slug = $fs->get_slug();
15
16 $fs_blog_id = $VARS['fs_blog_id'];
17
18 $active_plugins_directories_map = $VARS['active_plugins_directories_map'];
19
20 $addon_info = $VARS['addon_info'];
21 $is_addon_activated = $fs->is_addon_activated( $addon_id );
22 $is_addon_connected = $addon_info['is_connected'];
23 $is_addon_installed = $VARS['is_addon_installed'];
24
25 $fs_addon = ( $is_addon_connected && $is_addon_installed ) ?
26 freemius( $addon_id ) :
27 false;
28
29 // Aliases.
30 $download_latest_text = fs_text_x_inline( 'Download Latest', 'as download latest version', 'download-latest', $slug );
31 $downgrading_plan_text = fs_text_inline( 'Downgrading your plan', 'downgrading-plan', $slug );
32 $cancelling_subscription_text = fs_text_inline( 'Cancelling the subscription', 'cancelling-subscription', $slug );
33 /* translators: %1$s: Either 'Downgrading your plan' or 'Cancelling the subscription' */
34 $downgrade_x_confirm_text = fs_text_inline( '%1$s will immediately stop all future recurring payments and your %2$s plan license will expire in %3$s.', 'downgrade-x-confirm', $slug );
35 $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 );
36 $cancel_trial_confirm_text = fs_text_inline( 'Cancelling the trial will immediately block access to all premium features. Are you sure?', 'cancel-trial-confirm', $slug );
37 $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 );
38 $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 );
39 /* translators: %s: Plan title (e.g. "Professional") */
40 $activate_plan_text = fs_text_inline( 'Activate %s Plan', 'activate-x-plan', $slug );
41 $version_text = fs_text_x_inline( 'Version', 'product version', 'version', $slug );
42 /* translators: %s: Time period (e.g. Auto renews in "2 months") */
43 $renews_in_text = fs_text_inline( 'Auto renews in %s', 'renews-in', $slug );
44 /* translators: %s: Time period (e.g. Expires in "2 months") */
45 $expires_in_text = fs_text_inline( 'Expires in %s', 'expires-in', $slug );
46 $cancel_trial_text = fs_text_inline( 'Cancel Trial', 'cancel-trial', $slug );
47 $change_plan_text = fs_text_inline( 'Change Plan', 'change-plan', $slug );
48 $upgrade_text = fs_text_x_inline( 'Upgrade', 'verb', 'upgrade', $slug );
49 $addons_text = fs_text_inline( 'Add-Ons', 'add-ons', $slug );
50 $downgrade_text = fs_text_x_inline( 'Downgrade', 'verb', 'downgrade', $slug );
51 $trial_text = fs_text_x_inline( 'Trial', 'trial period', 'trial', $slug );
52 $free_text = fs_text_inline( 'Free', 'free', $slug );
53 $activate_text = fs_text_inline( 'Activate', 'activate', $slug );
54 $plan_text = fs_text_x_inline( 'Plan', 'as product pricing plan', 'plan', $slug );
55
56 // Defaults.
57 $plan = null;
58 $is_paid_trial = false;
59 /**
60 * @var FS_Plugin_License $license
61 */
62 $license = null;
63 $site = null;
64 $is_active_subscription = false;
65 $subscription = null;
66 $is_paying = false;
67 $show_upgrade = false;
68 $is_whitelabeled = $VARS['is_whitelabeled'];
69
70 if ( is_object( $fs_addon ) ) {
71 $is_paying = $fs_addon->is_paying();
72 $user = $fs_addon->get_user();
73 $site = $fs_addon->get_site();
74 $license = $fs_addon->_get_license();
75 $subscription = ( is_object( $license ) ?
76 $fs_addon->_get_subscription( $license->id ) :
77 null );
78 $plan = $fs_addon->get_plan();
79 $plan_name = $plan->name;
80 $plan_title = $plan->title;
81 $is_paid_trial = $fs_addon->is_paid_trial();
82 $version = $fs_addon->get_plugin_version();
83 $is_whitelabeled = (
84 $fs_addon->is_whitelabeled( true ) &&
85 ! $fs_addon->get_parent_instance()->is_data_debug_mode()
86 );
87 $show_upgrade = (
88 ! $is_whitelabeled &&
89 $fs_addon->has_paid_plan() &&
90 ! $is_paying &&
91 ! $is_paid_trial &&
92 ! $fs_addon->_has_premium_license()
93 );
94 } else if ( $is_addon_connected ) {
95 if (
96 empty( $addon_info ) ||
97 ! isset( $addon_info['site'] )
98 ) {
99 $is_addon_connected = false;
100 } else {
101 /**
102 * @var FS_Site $site
103 */
104 $site = $addon_info['site'];
105 $version = $addon_info['version'];
106
107 $plan_name = isset( $addon_info['plan_name'] ) ?
108 $addon_info['plan_name'] :
109 '';
110
111 $plan_title = isset( $addon_info['plan_title'] ) ?
112 $addon_info['plan_title'] :
113 '';
114
115 if ( isset( $addon_info['license'] ) ) {
116 $license = $addon_info['license'];
117 }
118
119 if ( isset( $addon_info['subscription'] ) ) {
120 $subscription = $addon_info['subscription'];
121 }
122
123 $has_valid_and_active_license = (
124 is_object( $license ) &&
125 $license->is_active() &&
126 $license->is_valid()
127 );
128
129 $is_paid_trial = (
130 $site->is_trial() &&
131 $has_valid_and_active_license &&
132 ( $site->trial_plan_id == $license->plan_id )
133 );
134
135 $is_whitelabeled = $addon_info['is_whitelabeled'];
136 }
137 }
138
139 $has_feature_enabled_license = (
140 is_object( $license ) &&
141 $license->is_features_enabled()
142 );
143
144 $is_active_subscription = ( is_object( $subscription ) && $subscription->is_active() );
145
146 $show_delete_install_button = ( ! $is_paying && WP_FS__DEV_MODE && ! $is_whitelabeled );
147 ?>
148 <tr<?php if ( $odd ) {
149 echo ' class="alternate"';
150 } ?>>
151 <td>
152 <!-- Title -->
153 <?php echo $addon_info['title'] ?>
154 </td>
155 <?php if ( $is_addon_connected ) : ?>
156 <!-- ID -->
157 <td><?php echo $site->id ?></td>
158 <!--/ ID -->
159
160 <!-- Version -->
161 <td><?php echo $version ?></td>
162 <!--/ Version -->
163
164 <!-- Plan Title -->
165 <td><?php echo strtoupper( is_string( $plan_name ) ? $plan_title : $free_text ) ?></td>
166 <!--/ Plan Title -->
167
168 <!-- Expiration -->
169 <td>
170 <?php if ( $site->is_trial() || is_object( $license ) ) : ?>
171 <?php
172 $tags = array();
173
174 if ( $site->is_trial() ) {
175 $tags[] = array( 'label' => $trial_text, 'type' => 'success' );
176
177 $tags[] = array(
178 'label' => sprintf(
179 ( $is_paid_trial ?
180 $renews_in_text :
181 $expires_in_text ),
182 human_time_diff( time(), strtotime( $site->trial_ends ) )
183 ),
184 'type' => ( $is_paid_trial ? 'success' : 'warn' )
185 );
186 } else {
187 if ( is_object( $license ) ) {
188 if ( $license->is_cancelled ) {
189 $tags[] = array(
190 'label' => fs_text_inline( 'Cancelled', 'cancelled', $slug ),
191 'type' => 'error'
192 );
193 } else if ( $license->is_expired() ) {
194 $tags[] = array(
195 'label' => fs_text_inline( 'Expired', 'expired', $slug ),
196 'type' => 'error'
197 );
198 } else if ( $license->is_lifetime() ) {
199 $tags[] = array(
200 'label' => fs_text_inline( 'No expiration', 'no-expiration', $slug ),
201 'type' => 'success'
202 );
203 } else if ( ! $is_active_subscription && ! $license->is_first_payment_pending() ) {
204 $tags[] = array(
205 'label' => sprintf( $expires_in_text, human_time_diff( time(), strtotime( $license->expiration ) ) ),
206 'type' => 'warn'
207 );
208 } else if ( $is_active_subscription && ! $subscription->is_first_payment_pending() ) {
209 $tags[] = array(
210 'label' => sprintf( $renews_in_text, human_time_diff( time(), strtotime( $subscription->next_payment ) ) ),
211 'type' => 'success'
212 );
213 }
214 }
215 }
216
217 foreach ( $tags as $t ) {
218 printf( '<label class="fs-tag fs-%s">%s</label>' . "\n", $t['type'], $t['label'] );
219 }
220 ?>
221 <?php endif ?>
222 </td>
223 <!--/ Expiration -->
224
225 <?php
226 $buttons = array();
227 $is_license_activation_added = false;
228
229 if ( $is_addon_activated ) {
230 if ( ! $is_whitelabeled ) {
231 if ( $is_paying ) {
232 $buttons[] = fs_ui_get_action_button(
233 $fs->get_id(),
234 'account',
235 'deactivate_license',
236 fs_text_inline( 'Deactivate License', 'deactivate-license', $slug ),
237 '',
238 array( 'plugin_id' => $addon_id ),
239 false,
240 true
241 );
242
243 $after_downgrade_message = ! $license->is_block_features ?
244 sprintf( $after_downgrade_non_blocking_text, $plan->title, $fs_addon->get_module_label( true ) ) :
245 sprintf( $after_downgrade_blocking_text, $plan->title );
246
247 if ( ! $license->is_lifetime() && $is_active_subscription ) {
248 $human_readable_license_expiration = human_time_diff( time(), strtotime( $license->expiration ) );
249 $downgrade_confirmation_message = sprintf(
250 $downgrade_x_confirm_text,
251 ( $fs_addon->is_only_premium() ? $cancelling_subscription_text : $downgrading_plan_text ),
252 $plan->title,
253 $human_readable_license_expiration
254 );
255
256 $buttons[] = fs_ui_get_action_button(
257 $fs->get_id(),
258 'account',
259 'downgrade_account',
260 esc_html( $fs_addon->is_only_premium() ? fs_text_inline( 'Cancel Subscription', 'cancel-subscription', $slug ) : $downgrade_text ),
261 '',
262 array( 'plugin_id' => $addon_id ),
263 false,
264 false,
265 false,
266 ( $downgrade_confirmation_message . ' ' . $after_downgrade_message . ' ' . $prices_increase_text ),
267 'POST'
268 );
269 }
270 } else if ( $is_paid_trial ) {
271 $buttons[] = fs_ui_get_action_button(
272 $fs->get_id(),
273 'account',
274 'cancel_trial',
275 esc_html( $cancel_trial_text ),
276 '',
277 array( 'plugin_id' => $addon_id ),
278 false,
279 false,
280 'dashicons dashicons-download',
281 $cancel_trial_confirm_text,
282 'POST'
283 );
284 } else if ( ! $has_feature_enabled_license ) {
285 $premium_licenses = $fs_addon->get_available_premium_licenses();
286
287 if ( ! empty( $premium_licenses ) ) {
288 $premium_license = $premium_licenses[0];
289 $has_multiple_premium_licenses = ( 1 < count( $premium_licenses ) );
290
291 if ( ! $has_multiple_premium_licenses ) {
292 $premium_plan = $fs_addon->_get_plan_by_id( $premium_license->plan_id );
293 $site = $fs_addon->get_site();
294
295 $buttons[] = fs_ui_get_action_button(
296 $fs->get_id(),
297 'account',
298 'activate_license',
299 esc_html( sprintf( $activate_plan_text, $premium_plan->title, ( $site->is_localhost() && $premium_license->is_free_localhost ) ? '[localhost]' : ( 1 < $premium_license->left() ? $premium_license->left() . ' left' : '' ) ) ),
300 ($has_multiple_premium_licenses ?
301 'activate-license-trigger ' . $fs_addon->get_unique_affix() :
302 ''),
303 array(
304 'plugin_id' => $addon_id,
305 'license_id' => $premium_license->id,
306 ),
307 true,
308 true
309 );
310
311 $is_license_activation_added = true;
312 }
313 }
314 }
315 }
316
317 // if ( 0 == count( $buttons ) ) {
318 if ( $fs_addon->is_premium() && ! $is_license_activation_added ) {
319 $fs_addon->_add_license_activation_dialog_box();
320
321 $buttons[] = fs_ui_get_action_button(
322 $fs->get_id(),
323 'account',
324 'activate_license',
325 ( ! $has_feature_enabled_license ) ?
326 fs_esc_html_inline( 'Activate License', 'activate-license', $slug ) :
327 fs_esc_html_inline( 'Change License', 'change-license', $slug ),
328 'activate-license-trigger ' . $fs_addon->get_unique_affix(),
329 array(
330 'plugin_id' => $addon_id,
331 ),
332 (! $has_feature_enabled_license),
333 true
334 );
335
336 $is_license_activation_added = true;
337 }
338
339 if ( $fs_addon->has_paid_plan() ) {
340 // Add sync license only if non of the other CTAs are visible.
341 $buttons[] = fs_ui_get_action_button(
342 $fs->get_id(),
343 'account',
344 $fs->get_unique_affix() . '_sync_license',
345 fs_esc_html_x_inline( 'Sync', 'as synchronize', 'sync', $slug ),
346 '',
347 array( 'plugin_id' => $addon_id ),
348 false,
349 true
350 );
351 }
352 // }
353 } else if ( ! $show_upgrade ) {
354 if ( $fs->is_addon_installed( $addon_id ) ) {
355 $addon_file = $fs->get_addon_basename( $addon_id );
356
357 if ( ! isset( $active_plugins_directories_map[ dirname( $addon_file ) ] ) ) {
358 $buttons[] = sprintf(
359 '<a class="button button-primary edit" href="%s" title="%s">%s</a>',
360 wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $addon_file, 'activate-plugin_' . $addon_file ),
361 fs_esc_attr_inline( 'Activate this add-on', 'activate-this-addon', $slug ),
362 $activate_text
363 );
364 }
365 } else {
366 if ( $fs->is_allowed_to_install() ) {
367 $buttons[] = sprintf(
368 '<a class="button button-primary edit" href="%s">%s</a>',
369 wp_nonce_url( self_admin_url( 'update.php?' . ( ( isset( $addon_info['has_paid_plan'] ) && $addon_info['has_paid_plan'] ) ? 'fs_allow_updater_and_dialog=true&' : '' ) . 'action=install-plugin&plugin=' . $addon_info['slug'] ), 'install-plugin_' . $addon_info['slug'] ),
370 fs_text_inline( 'Install Now', 'install-now', $slug )
371 );
372 } else {
373 $buttons[] = sprintf(
374 '<a target="_blank" rel="noopener" class="button button-primary edit" href="%s">%s</a>',
375 $fs->_get_latest_download_local_url( $addon_id ),
376 esc_html( $download_latest_text )
377 );
378 }
379 }
380 }
381
382 if ( $show_upgrade ) {
383 $buttons[] = sprintf( '<a href="%s" class="thickbox button button-small button-primary" aria-label="%s" data-title="%s"><i class="dashicons dashicons-cart"></i> %s</a>',
384 esc_url( network_admin_url( 'plugin-install.php?fs_allow_updater_and_dialog=true' . ( ! empty( $fs_blog_id ) ? '&fs_blog_id=' . $fs_blog_id : '' ) . '&tab=plugin-information&parent_plugin_id=' . $fs->get_id() . '&plugin=' . $addon_info['slug'] .
385 '&TB_iframe=true&width=600&height=550' ) ),
386 esc_attr( sprintf( fs_text_inline( 'More information about %s', 'more-information-about-x', $slug ), $addon_info['title'] ) ),
387 esc_attr( $addon_info['title'] ),
388 ( $fs_addon->has_free_plan() ?
389 $upgrade_text :
390 fs_text_x_inline( 'Purchase', 'verb', 'purchase', $slug ) )
391 );
392 }
393
394 $buttons_count = count( $buttons );
395 ?>
396
397 <!-- Actions -->
398 <td><?php if ( $buttons_count > 1 ) : ?>
399 <div class="button-group"><?php endif ?>
400 <?php foreach ( $buttons as $button ) {
401 echo $button;
402 } ?>
403 <?php if ( $buttons_count > 1 ) : ?></div><?php endif ?></td>
404 <!--/ Actions -->
405
406 <?php else : ?>
407 <?php // Add-on NOT Installed or was never connected.
408 $is_addon_installed_by_filesystem = $fs->is_addon_installed( $addon_id );
409 ?>
410 <!-- Action -->
411 <td colspan="<?php echo ( $is_addon_installed_by_filesystem || $show_delete_install_button ) ? '5' : '4' ?>">
412 <?php if ( $is_addon_installed_by_filesystem ) : ?>
413 <?php $addon_file = $fs->get_addon_basename( $addon_id ) ?>
414 <?php if ( ! isset( $active_plugins_directories_map[ dirname( $addon_file ) ] ) ) : ?>
415 <a class="button button-primary"
416 href="<?php echo wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $addon_file, 'activate-plugin_' . $addon_file ) ?>"
417 title="<?php fs_esc_attr_echo_inline( 'Activate this add-on', 'activate-this-addon', $slug ) ?>"
418 class="edit"><?php echo esc_html( $activate_text ) ?></a>
419 <?php endif ?>
420 <?php else : ?>
421 <?php if ( $fs->is_allowed_to_install() ) : ?>
422 <a class="button button-primary"
423 href="<?php echo wp_nonce_url( self_admin_url( 'update.php?' . ( ( isset( $addon_info['has_paid_plan'] ) && $addon_info['has_paid_plan'] ) ? 'fs_allow_updater_and_dialog=true&' : '' ) . 'action=install-plugin&plugin=' . $addon_info['slug'] ), 'install-plugin_' . $addon_info['slug'] ) ?>"><?php fs_esc_html_echo_inline( 'Install Now', 'install-now', $slug ) ?></a>
424 <?php else : ?>
425 <a target="_blank" rel="noopener" class="button button-primary"
426 href="<?php echo $fs->_get_latest_download_local_url( $addon_id ) ?>"><?php echo esc_html( $download_latest_text ) ?></a>
427 <?php endif ?>
428 <?php endif ?>
429 </td>
430 <!--/ Action -->
431 <?php endif ?>
432 <?php if ( $show_delete_install_button ) : ?>
433 <!-- Optional Delete Action -->
434 <td>
435 <?php
436 if ( $is_addon_activated ) {
437 fs_ui_action_button(
438 $fs->get_id(), 'account',
439 'delete_account',
440 fs_text_x_inline( 'Delete', 'verb', 'delete', $slug ),
441 '',
442 array( 'plugin_id' => $addon_id ),
443 false,
444 $show_upgrade
445 );
446 }
447 ?>
448 </td>
449 <!--/ Optional Delete Action -->
450 <?php endif ?>
451 </tr>
452