Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #2884 Upgrade plan link in admin bar #899

Merged
merged 21 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions assets/css/admin-bar.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,10 @@
}
#wpadminbar #wp-admin-bar-imagify-profile .ab-item {
height: auto;
padding: 0 13px;
padding: 0;
}
#wpadminbar #wp-admin-bar-imagify-profile {
min-width: 200px;
padding: 15px 0 10px;
margin-top: 0.7em;
background: #222;
}
Expand Down Expand Up @@ -197,3 +196,20 @@
content: "\2715";
color: #fff;
}

#wpadminbar #wp-admin-bar-imagify-profile .imagify-admin-bar-upgrade-plan {
background: #8bc34a;
box-sizing: border-box;
border:none;
color: #fff;
cursor: pointer;
display: block;
font-weight: bold !important;
padding: 5px 10px;
text-align: left;
width: 100% !important;
}

#wpadminbar #wp-admin-bar-imagify-profile .imagify-admin-bar-quota {
padding: 13px 15px;
}
2 changes: 1 addition & 1 deletion assets/css/admin-bar.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions classes/Admin/AdminBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,17 @@ public function get_admin_bar_profile_callback() {
$text = '';
$button_text = '';
$upgrade_link = '';
$upgrade_button = '';

if ( $user->is_free() ) {
$text = esc_html__( 'Upgrade your plan now for more!', 'rocket' ) . '<br>' .
esc_html__( 'From $5.99/month only, keep going with image optimization!', 'rocket' );
$button_text = esc_html__( 'Upgrade My Plan', 'rocket' );
$upgrade_link = IMAGIFY_APP_DOMAIN . '/subscription/?utm_source=plugin&utm_medium=notification';

if ( $user->get_percent_unconsumed_quota() <= 20 ) {
$upgrade_button = '<button id="imagify-get-pricing-modal" data-nonce="' . wp_create_nonce( 'imagify_get_pricing_' . get_current_user_id() ) . '" data-target="#imagify-pricing-modal" type="button" class="imagify-modal-trigger imagify-admin-bar-upgrade-plan">' . __( 'Upgrade Plan', 'imagify' ) . '</button>';
}
} elseif ( $user->is_growth() ) {
$text = esc_html__( 'Switch to Infinite plan for unlimited optimization:', 'rocket' ) . '<br>';

Expand All @@ -72,6 +77,7 @@ public function get_admin_bar_profile_callback() {
'text' => $text,
'button_text' => $button_text,
'upgrade_link' => $upgrade_link,
'upgrade_button' => $upgrade_button,
];

$template = $views->get_template( 'admin/admin-bar-status', $data );
Expand Down
2 changes: 1 addition & 1 deletion views/admin/admin-bar-status.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
?>

<?php echo $data['upgrade_button']; ?>
<div class="imagify-admin-bar-quota">
<div class="imagify-abq-row">
<?php if ( $data['plan_with_quota'] ) : ?>
Expand Down
Loading