PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 2.2.1
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v2.2.1
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / classes / Admin / AdminBar.php

AdminBar.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 2.2.1, at classes/Admin/AdminBar.php

82 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Imagify\Admin;
4
5 use Imagify\Traits\InstanceGetterTrait;
6 use Imagify\User\User;
7 use Imagify_Views;
8
9 /**
10 * Admin bar handler
11 */
12 class AdminBar {
13 use InstanceGetterTrait;
14
15 /**
16 * Launch the hooks.
17 *
18 * @return void
19 */
20 public function init() {
21 if ( wp_doing_ajax() ) {
22 add_action( 'wp_ajax_imagify_get_admin_bar_profile', array( $this, 'get_admin_bar_profile_callback' ) );
23 }
24 }
25
26 /**
27 * Get admin bar profile output.
28 *
29 * @return void
30 */
31 public function get_admin_bar_profile_callback() {
32 imagify_check_nonce( 'imagify-get-admin-bar-profile', 'imagifygetadminbarprofilenonce' );
33
34 if ( ! imagify_get_context( 'wp' )->current_user_can( 'manage' ) ) {
35 imagify_die();
36 }
37
38 $user = new User();
39 $views = Imagify_Views::get_instance();
40 $unconsumed_quota = $views->get_quota_percent();
41 $text = '';
42 $button_text = '';
43 $upgrade_link = '';
44
45 if ( $user->is_free() ) {
46 $text = esc_html__( 'Upgrade your plan now for more!', 'rocket' ) . '<br>' .
47 esc_html__( 'From $5.99/month only, keep going with image optimization!', 'rocket' );
48 $button_text = esc_html__( 'Upgrade My Plan', 'rocket' );
49 $upgrade_link = IMAGIFY_APP_DOMAIN . '/subscription/?utm_source=plugin&utm_medium=notification';
50 } elseif ( $user->is_growth() ) {
51 $text = esc_html__( 'Switch to Infinite plan for unlimited optimization:', 'rocket' ) . '<br>';
52
53 if ( $user->is_monthly ) {
54 $text .= esc_html__( 'For $9.99/month, optimize as many images as you like!', 'rocket' );
55 $upgrade_link = IMAGIFY_APP_DOMAIN . '/subscription/plan_switch/?label=infinite&payment_plan=1&utm_source=plugin&utm_medium=notification ';
56 } else {
57 $text .= esc_html__( 'For $99.9/year, optimize as many images as you like!', 'rocket' );
58 $upgrade_link = IMAGIFY_APP_DOMAIN . '/subscription/plan_switch/?label=infinite&payment_plan=2&utm_source=plugin&utm_medium=notification ';
59 }
60
61 $button_text = esc_html__( 'Switch To Infinite Plan', 'rocket' );
62 }
63
64 $data = [
65 'quota_icon' => $views->get_quota_icon(),
66 'quota_class' => $views->get_quota_class(),
67 'plan_label' => $user->plan_label,
68 'plan_with_quota' => $user->is_free() || $user->is_growth(),
69 'unconsumed_quota' => $unconsumed_quota,
70 'user_quota' => $user->quota,
71 'next_update' => $user->next_date_update,
72 'text' => $text,
73 'button_text' => $button_text,
74 'upgrade_link' => $upgrade_link,
75 ];
76
77 $template = $views->get_template( 'admin/admin-bar-status', $data );
78
79 wp_send_json_success( $template );
80 }
81 }
82