From c7cbc1b492b88e1ebd6729ab909a71de96380f90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Perona?= Date: Wed, 25 Sep 2024 14:52:38 -0400 Subject: [PATCH 01/19] add upgrade plan button --- classes/Admin/AdminBar.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/classes/Admin/AdminBar.php b/classes/Admin/AdminBar.php index 145a46364..eb776e82b 100644 --- a/classes/Admin/AdminBar.php +++ b/classes/Admin/AdminBar.php @@ -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' ) . '
' . 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 = ''; + } } elseif ( $user->is_growth() ) { $text = esc_html__( 'Switch to Infinite plan for unlimited optimization:', 'rocket' ) . '
'; @@ -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 ); From 917875e195dcd9136f2dac944d7050ab834bbb3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Perona?= Date: Wed, 25 Sep 2024 14:52:46 -0400 Subject: [PATCH 02/19] add upgrade button data --- views/admin/admin-bar-status.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/admin/admin-bar-status.php b/views/admin/admin-bar-status.php index d59aff71c..cf48ce90d 100644 --- a/views/admin/admin-bar-status.php +++ b/views/admin/admin-bar-status.php @@ -1,7 +1,7 @@ - +
From f02f821506d06df70f4c981026a05d011b854464 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Perona?= Date: Wed, 25 Sep 2024 14:52:51 -0400 Subject: [PATCH 03/19] update admin bar CSS --- assets/css/admin-bar.css | 20 ++++++++++++++++++-- assets/css/admin-bar.min.css | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/assets/css/admin-bar.css b/assets/css/admin-bar.css index 92936f18a..39c23f09c 100755 --- a/assets/css/admin-bar.css +++ b/assets/css/admin-bar.css @@ -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; } @@ -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; +} diff --git a/assets/css/admin-bar.min.css b/assets/css/admin-bar.min.css index 90142c9a1..9e51085ff 100755 --- a/assets/css/admin-bar.min.css +++ b/assets/css/admin-bar.min.css @@ -1 +1 @@ -.imagify-account,.imagify-account-link{padding-right:15px}.imagify-meteo-icon{display:inline-block;height:38px;vertical-align:middle;margin-right:10px}.imagify-user-plan{color:#40b1d0}.imagify-meteo-title.imagify-meteo-title{color:#fff;font-size:17px}.imagify-space-left>p{color:#fff}#wp-admin-bar-imagify-profile [class^=imagify-bar-]{position:relative;height:1.5em;width:100%;background:#60758d;color:#fff;font-size:10px}#wp-admin-bar-imagify-profile .imagify-progress{height:1.5em;font-size:1em}.imagify-progress{-webkit-transition:width .3s;-o-transition:width .3s;transition:width .3s}.imagify-bar-positive .imagify-progress{background:#8cc152}.imagify-bar-positive .imagify-barnb{color:#8cc152}.imagify-bar-negative .imagify-progress{background:#73818c}.imagify-bar-negative .imagify-barnb{color:#73818c}.imagify-bar-neutral .imagify-progress{background:#f5a623}.imagify-space-left .imagify-bar-negative .imagify-progress{background:#d0021b}#wpadminbar #wp-admin-bar-imagify-profile *{line-height:1.5;white-space:initial}#wpadminbar #wp-admin-bar-imagify .ab-submenu{padding-bottom:0}#wpadminbar #wp-admin-bar-imagify-profile .ab-item{height:auto;padding:0 13px}#wpadminbar #wp-admin-bar-imagify-profile{min-width:200px;padding:15px 0 10px;margin-top:.7em;background:#222}#wp-admin-bar-imagify .dashicons{font-family:dashicons;font-size:18px;vertical-align:middle;margin:0 5px 0 0}#wp-admin-bar-imagify .button-text{display:inline-block;vertical-align:middle}#wp-admin-bar-imagify .imagify-abq-row{display:table;width:100%}#wp-admin-bar-imagify .imagify-abq-row+.imagify-abq-row{margin-top:.75em}#wp-admin-bar-imagify .imagify-abq-row>*{display:table-cell}#wp-admin-bar-imagify-profile .imagify-meteo-icon{padding-right:7px}#wp-admin-bar-imagify-profile .imagify-meteo-icon img{width:37px}#wp-admin-bar-imagify-profile .imagify-meteo-title{font-size:17px}#wp-admin-bar-imagify-profile .imagify-meteo-subs{color:#72889f}#wpadminbar #wp-admin-bar-imagify-profile strong{font-weight:700}#wpadminbar #wp-admin-bar-imagify-profile .imagify-user-plan,#wpadminbar #wp-admin-bar-imagify-profile a{padding:0;color:#40b1d0}#wpadminbar #wp-admin-bar-imagify-profile .imagify-account-link{display:table}#wpadminbar #wp-admin-bar-imagify-profile .imagify-account-link>*{display:table-cell}#wpadminbar #wp-admin-bar-imagify-profile .imagify-space-left{max-width:210px;min-width:210px;width:210px}#wpadminbar #wp-admin-bar-imagify-profile .imagify-space-left p{font-size:12px}#wp-admin-bar-imagify-profile .imagify-error,#wp-admin-bar-imagify-profile .imagify-warning{padding:10px;margin:0 -13px -13px}#wp-admin-bar-imagify-profile .imagify-error p+p,#wp-admin-bar-imagify-profile .imagify-warning p+p{margin-top:.5em}#wp-admin-bar-imagify-profile .imagify-error p+p+p,#wp-admin-bar-imagify-profile .imagify-warning p+p+p{margin-top:1em}#wpadminbar #wp-admin-bar-imagify-profile .imagify-btn-ghost{display:inline-block;height:auto;padding:7px 10px;border:1px solid #fff;text-align:center;background:0 0;color:#fff;border-radius:3px;-webkit-transition:all .275s;-o-transition:all .275s;transition:all .275s}#wpadminbar #wp-admin-bar-imagify-profile .imagify-btn-ghost:focus,#wpadminbar #wp-admin-bar-imagify-profile .imagify-btn-ghost:hover{background:#fff;color:#888}#wpadminbar .imagify-warning *{background:#f5a623;color:#fff;text-shadow:0 0 2px rgba(0,0,0,.2)}#wp-admin-bar-imagify-profile .imagify-upsell-admin-bar{position:relative;background:#c51161;margin:10px -13px -10px -13px;padding:20px}#wp-admin-bar-imagify-profile .imagify-upsell-admin-bar p{color:#fff}#wp-admin-bar-imagify-profile a.imagify-upsell-admin-bar-button{display:block;height:auto!important;border:1px solid #fff;border-radius:5px;color:#fff!important;padding:5px 10px!important;text-align:center;text-decoration:none;margin-top:10px}#wpadminbar #wp-admin-bar-imagify-profile a.imagify-upsell-dismiss{display:inline!important;height:auto!important}#wpadminbar #wp-admin-bar-imagify-profile .imagify-upsell-dismiss::before{position:absolute;top:5px;right:10px;content:"\2715";color:#fff} \ No newline at end of file +.imagify-account,.imagify-account-link{padding-right:15px}.imagify-meteo-icon{display:inline-block;height:38px;vertical-align:middle;margin-right:10px}.imagify-user-plan{color:#40b1d0}.imagify-meteo-title.imagify-meteo-title{color:#fff;font-size:17px}.imagify-space-left>p{color:#fff}#wp-admin-bar-imagify-profile [class^=imagify-bar-]{position:relative;height:1.5em;width:100%;background:#60758d;color:#fff;font-size:10px}#wp-admin-bar-imagify-profile .imagify-progress{height:1.5em;font-size:1em}.imagify-progress{-webkit-transition:width .3s;-o-transition:width .3s;transition:width .3s}.imagify-bar-positive .imagify-progress{background:#8cc152}.imagify-bar-positive .imagify-barnb{color:#8cc152}.imagify-bar-negative .imagify-progress{background:#73818c}.imagify-bar-negative .imagify-barnb{color:#73818c}.imagify-bar-neutral .imagify-progress{background:#f5a623}.imagify-space-left .imagify-bar-negative .imagify-progress{background:#d0021b}#wpadminbar #wp-admin-bar-imagify-profile *{line-height:1.5;white-space:initial}#wpadminbar #wp-admin-bar-imagify .ab-submenu{padding-bottom:0}#wpadminbar #wp-admin-bar-imagify-profile .ab-item{height:auto;padding:0}#wpadminbar #wp-admin-bar-imagify-profile{min-width:200px;margin-top:.7em;background:#222}#wp-admin-bar-imagify .dashicons{font-family:dashicons;font-size:18px;vertical-align:middle;margin:0 5px 0 0}#wp-admin-bar-imagify .button-text{display:inline-block;vertical-align:middle}#wp-admin-bar-imagify .imagify-abq-row{display:table;width:100%}#wp-admin-bar-imagify .imagify-abq-row+.imagify-abq-row{margin-top:.75em}#wp-admin-bar-imagify .imagify-abq-row>*{display:table-cell}#wp-admin-bar-imagify-profile .imagify-meteo-icon{padding-right:7px}#wp-admin-bar-imagify-profile .imagify-meteo-icon img{width:37px}#wp-admin-bar-imagify-profile .imagify-meteo-title{font-size:17px}#wp-admin-bar-imagify-profile .imagify-meteo-subs{color:#72889f}#wpadminbar #wp-admin-bar-imagify-profile strong{font-weight:700}#wpadminbar #wp-admin-bar-imagify-profile .imagify-user-plan,#wpadminbar #wp-admin-bar-imagify-profile a{padding:0;color:#40b1d0}#wpadminbar #wp-admin-bar-imagify-profile .imagify-account-link{display:table}#wpadminbar #wp-admin-bar-imagify-profile .imagify-account-link>*{display:table-cell}#wpadminbar #wp-admin-bar-imagify-profile .imagify-space-left{max-width:210px;min-width:210px;width:210px}#wpadminbar #wp-admin-bar-imagify-profile .imagify-space-left p{font-size:12px}#wp-admin-bar-imagify-profile .imagify-error,#wp-admin-bar-imagify-profile .imagify-warning{padding:10px;margin:0 -13px -13px}#wp-admin-bar-imagify-profile .imagify-error p+p,#wp-admin-bar-imagify-profile .imagify-warning p+p{margin-top:.5em}#wp-admin-bar-imagify-profile .imagify-error p+p+p,#wp-admin-bar-imagify-profile .imagify-warning p+p+p{margin-top:1em}#wpadminbar #wp-admin-bar-imagify-profile .imagify-btn-ghost{display:inline-block;height:auto;padding:7px 10px;border:1px solid #fff;text-align:center;background:0 0;color:#fff;border-radius:3px;-webkit-transition:all .275s;-o-transition:all .275s;transition:all .275s}#wpadminbar #wp-admin-bar-imagify-profile .imagify-btn-ghost:focus,#wpadminbar #wp-admin-bar-imagify-profile .imagify-btn-ghost:hover{background:#fff;color:#888}#wpadminbar .imagify-warning *{background:#f5a623;color:#fff;text-shadow:0 0 2px rgba(0,0,0,.2)}#wp-admin-bar-imagify-profile .imagify-upsell-admin-bar{position:relative;background:#c51161;margin:10px -13px -10px -13px;padding:20px}#wp-admin-bar-imagify-profile .imagify-upsell-admin-bar p{color:#fff}#wp-admin-bar-imagify-profile a.imagify-upsell-admin-bar-button{display:block;height:auto!important;border:1px solid #fff;border-radius:5px;color:#fff!important;padding:5px 10px!important;text-align:center;text-decoration:none;margin-top:10px}#wpadminbar #wp-admin-bar-imagify-profile a.imagify-upsell-dismiss{display:inline!important;height:auto!important}#wpadminbar #wp-admin-bar-imagify-profile .imagify-upsell-dismiss::before{position:absolute;top:5px;right:10px;content:"\2715";color:#fff}#wpadminbar #wp-admin-bar-imagify-profile .imagify-admin-bar-upgrade-plan{background:#8bc34a;-webkit-box-sizing:border-box;box-sizing:border-box;border:none;color:#fff;cursor:pointer;display:block;font-weight:700!important;padding:5px 10px;text-align:left;width:100%!important}#wpadminbar #wp-admin-bar-imagify-profile .imagify-admin-bar-quota{padding:13px 15px} \ No newline at end of file From f039368eae9a052afcffcf2219f994dd8662d8ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Perona?= Date: Thu, 26 Sep 2024 11:45:28 -0400 Subject: [PATCH 04/19] remove instantiation with singleton --- classes/Plugin.php | 1 - 1 file changed, 1 deletion(-) diff --git a/classes/Plugin.php b/classes/Plugin.php index 7f10bbfb6..cfc702960 100644 --- a/classes/Plugin.php +++ b/classes/Plugin.php @@ -115,7 +115,6 @@ class_alias( '\\Imagify\\Traits\\InstanceGetterTrait', '\\Imagify\\Traits\\FakeS \Imagify\Auth\Basic::get_instance()->init(); \Imagify\Job\MediaOptimization::get_instance()->init(); Bulk::get_instance()->init(); - AdminBar::get_instance()->init(); if ( is_admin() ) { Notices::get_instance()->init(); From 98c78f6ae2b03614201f100ca1ba93b0d252a83c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Perona?= Date: Thu, 26 Sep 2024 11:45:47 -0400 Subject: [PATCH 05/19] implement subscriber interface --- classes/Admin/AdminBar.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/classes/Admin/AdminBar.php b/classes/Admin/AdminBar.php index eb776e82b..8a9d648f4 100644 --- a/classes/Admin/AdminBar.php +++ b/classes/Admin/AdminBar.php @@ -1,26 +1,25 @@ 'get_admin_bar_profile_callback', + ]; } /** From 820f6a7512662bcef93c8d71dea9a5a1bf40945b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Perona?= Date: Thu, 26 Sep 2024 11:45:55 -0400 Subject: [PATCH 06/19] add service provider for admin --- classes/Admin/ServiceProvider.php | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 classes/Admin/ServiceProvider.php diff --git a/classes/Admin/ServiceProvider.php b/classes/Admin/ServiceProvider.php new file mode 100644 index 000000000..5d4a96422 --- /dev/null +++ b/classes/Admin/ServiceProvider.php @@ -0,0 +1,47 @@ +getContainer()->share( 'admin_bar', AdminBar::class ); + } + + /** + * Returns the subscribers array + * + * @return array + */ + public function get_subscribers() { + return $this->subscribers; + } +} From 378a944e132739edad601cdab5dd46d3759384fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Perona?= Date: Thu, 26 Sep 2024 11:46:02 -0400 Subject: [PATCH 07/19] add admin service provider to config --- config/providers.php | 1 + 1 file changed, 1 insertion(+) diff --git a/config/providers.php b/config/providers.php index 0a40a32a6..072de60cf 100644 --- a/config/providers.php +++ b/config/providers.php @@ -1,5 +1,6 @@ Date: Mon, 30 Sep 2024 09:13:45 -0400 Subject: [PATCH 08/19] display upgrade banner when above 20% --- classes/Admin/AdminBar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Admin/AdminBar.php b/classes/Admin/AdminBar.php index 8a9d648f4..b5fcf364b 100644 --- a/classes/Admin/AdminBar.php +++ b/classes/Admin/AdminBar.php @@ -48,7 +48,7 @@ public function get_admin_bar_profile_callback() { $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 ) { + if ( $user->get_percent_unconsumed_quota() > 20 ) { $upgrade_button = ''; } } elseif ( $user->is_growth() ) { From 02b9dea4eb0667edc9928a2d5922e5e52c763cfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Perona?= Date: Mon, 30 Sep 2024 10:17:08 -0400 Subject: [PATCH 09/19] load the pricing modal on all pages --- inc/classes/class-imagify-assets.php | 6 ++++-- inc/classes/class-imagify-views.php | 7 +++++++ views/page-bulk.php | 2 -- views/page-settings.php | 1 - 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/inc/classes/class-imagify-assets.php b/inc/classes/class-imagify-assets.php index 7d5e1fc2c..ff2f57eed 100755 --- a/inc/classes/class-imagify-assets.php +++ b/inc/classes/class-imagify-assets.php @@ -276,14 +276,14 @@ public function enqueue_styles_and_scripts() { * Loaded in the bulk optimization page. */ if ( imagify_is_screen( 'bulk' ) ) { - $this->enqueue_assets( [ 'pricing-modal', 'bulk' ] ); + $this->enqueue_assets( 'bulk' ); } /* * Loaded in the settings page. */ if ( imagify_is_screen( 'imagify-settings' ) ) { - $this->enqueue_assets( [ 'sweetalert', 'notices', 'twentytwenty', 'pricing-modal', 'options' ] ); + $this->enqueue_assets( [ 'sweetalert', 'notices', 'twentytwenty', 'options' ] ); } /* @@ -293,6 +293,8 @@ public function enqueue_styles_and_scripts() { $this->enqueue_assets( [ 'files-list', 'twentytwenty' ] ); } + $this->enqueue_assets( 'pricing-modal' ); + /** * Triggered after Imagify CSS and JS have been enqueued. * diff --git a/inc/classes/class-imagify-views.php b/inc/classes/class-imagify-views.php index 726641027..7f9c8255f 100644 --- a/inc/classes/class-imagify-views.php +++ b/inc/classes/class-imagify-views.php @@ -130,6 +130,7 @@ public function init() { // JS templates in footer. add_action( 'admin_print_footer_scripts', [ $this, 'print_js_templates' ] ); + add_action( 'admin_footer', [ $this, 'print_modal_payment' ] ); } @@ -651,6 +652,12 @@ public function print_js_templates() { } } + /** + * Print the payment modal. + */ + public function print_modal_payment() { + $this->print_template( 'modal-payment' ); + } /** ----------------------------------------------------------------------------------------- */ /** TOOLS =================================================================================== */ diff --git a/views/page-bulk.php b/views/page-bulk.php index a6657acef..dd17010a7 100755 --- a/views/page-bulk.php +++ b/views/page-bulk.php @@ -160,8 +160,6 @@
print_template( 'modal-payment' ); - if ( Imagify_Requirements::is_api_key_valid() ) { $display_infos = get_transient( 'imagify_bulk_optimization_infos' ); diff --git a/views/page-settings.php b/views/page-settings.php index abb1b5e03..6fd7747f1 100755 --- a/views/page-settings.php +++ b/views/page-settings.php @@ -177,7 +177,6 @@ $this->print_template( 'modal-settings-infos' ); $this->print_template( 'modal-settings-partners-infos' ); $this->print_template( 'modal-settings-visual-comparison' ); - $this->print_template( 'modal-payment' ); ?>
From 3e1229c15e1edfb6c4f84bec918c785c4407f68a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Perona?= Date: Mon, 30 Sep 2024 12:42:41 -0400 Subject: [PATCH 10/19] update from id to class selector --- assets/js/pricing-modal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/pricing-modal.js b/assets/js/pricing-modal.js index bc6d2dee3..db7d72f68 100755 --- a/assets/js/pricing-modal.js +++ b/assets/js/pricing-modal.js @@ -1100,7 +1100,7 @@ * Get pricings on modal opening. * Build the pricing tables inside modal. */ - $('#imagify-get-pricing-modal').on('click.imagify-ajax', function () { + $('.imagify-get-pricing-modal').on('click.imagify-ajax', function () { imagifyModal.getPricing($(this)); }); From 36a9fc85897c3f620b4dfe510051f4e877b139f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Perona?= Date: Mon, 30 Sep 2024 12:42:46 -0400 Subject: [PATCH 11/19] update css --- assets/css/admin-bar.css | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/assets/css/admin-bar.css b/assets/css/admin-bar.css index 39c23f09c..1a69b99ee 100755 --- a/assets/css/admin-bar.css +++ b/assets/css/admin-bar.css @@ -197,7 +197,11 @@ color: #fff; } -#wpadminbar #wp-admin-bar-imagify-profile .imagify-admin-bar-upgrade-plan { +#wpadminbar #wp-admin-bar-imagify-upgrade-plan .ab-empty-item { + padding: 0; +} + +#wpadminbar .imagify-admin-bar-upgrade-plan { background: #8bc34a; box-sizing: border-box; border:none; @@ -205,7 +209,7 @@ cursor: pointer; display: block; font-weight: bold !important; - padding: 5px 10px; + padding: 0 10px; text-align: left; width: 100% !important; } From 443db6ff9ef45756073f71733e8377eff673753d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Perona?= Date: Mon, 30 Sep 2024 12:42:55 -0400 Subject: [PATCH 12/19] remove admin bar file --- classes/Plugin.php | 1 - inc/common/admin-bar.php | 79 ---------------------------------------- 2 files changed, 80 deletions(-) delete mode 100755 inc/common/admin-bar.php diff --git a/classes/Plugin.php b/classes/Plugin.php index cfc702960..877fc0b9f 100644 --- a/classes/Plugin.php +++ b/classes/Plugin.php @@ -189,7 +189,6 @@ public function include_files() { require_once $inc_path . 'functions/i18n.php'; require_once $inc_path . 'functions/partners.php'; require_once $inc_path . 'common/attachments.php'; - require_once $inc_path . 'common/admin-bar.php'; require_once $inc_path . 'common/partners.php'; require_once $inc_path . '3rd-party/3rd-party.php'; diff --git a/inc/common/admin-bar.php b/inc/common/admin-bar.php deleted file mode 100755 index af89ec436..000000000 --- a/inc/common/admin-bar.php +++ /dev/null @@ -1,79 +0,0 @@ -current_user_can( 'manage' ) ) { - return; - } - - if ( ! get_imagify_option( 'admin_bar_menu' ) ) { - return; - } - - // Parent. - $wp_admin_bar->add_menu( array( - 'id' => 'imagify', - 'title' => 'Imagify', - 'href' => get_imagify_admin_url(), - ) ); - - // Settings. - $wp_admin_bar->add_menu(array( - 'parent' => 'imagify', - 'id' => 'imagify-settings', - 'title' => __( 'Settings' ), - 'href' => get_imagify_admin_url(), - ) ); - - // Bulk Optimization. - if ( ! is_network_admin() ) { - $wp_admin_bar->add_menu(array( - 'parent' => 'imagify', - 'id' => 'imagify-bulk-optimization', - 'title' => __( 'Bulk Optimization', 'imagify' ), - 'href' => get_imagify_admin_url( 'bulk-optimization' ), - ) ); - } - - // Documentation. - $wp_admin_bar->add_menu(array( - 'parent' => 'imagify', - 'id' => 'imagify-documentation', - 'title' => __( 'Documentation', 'imagify' ), - 'href' => imagify_get_external_url( 'documentation' ), - 'meta' => array( - 'target' => '_blank', - ), - ) ); - - // Rate it. - $wp_admin_bar->add_menu(array( - 'parent' => 'imagify', - 'id' => 'imagify-rate-it', - /* translators: %s is WordPress.org. */ - 'title' => sprintf( __( 'Rate Imagify on %s', 'imagify' ), 'WordPress.org' ), - 'href' => imagify_get_external_url( 'rate' ), - 'meta' => array( - 'target' => '_blank', - ), - ) ); - - // Quota & Profile informations. - if ( defined( 'IMAGIFY_HIDDEN_ACCOUNT' ) && IMAGIFY_HIDDEN_ACCOUNT || ! get_imagify_option( 'api_key' ) ) { - return; - } - - $wp_admin_bar->add_menu( array( - 'parent' => 'imagify', - 'id' => 'imagify-profile', - 'title' => wp_nonce_field( 'imagify-get-admin-bar-profile', 'imagifygetadminbarprofilenonce', false, false ) . '
' . __( 'Loading...', 'imagify' ) . '
', - ) ); -} From 463919931a113a91d8d8da8044e210444dc0f9c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Perona?= Date: Mon, 30 Sep 2024 12:43:05 -0400 Subject: [PATCH 13/19] update from id to class --- views/part-upsell.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/part-upsell.php b/views/part-upsell.php index 8d1633fed..f748c5850 100644 --- a/views/part-upsell.php +++ b/views/part-upsell.php @@ -29,7 +29,7 @@

- From 18ff070b77a8b68561a889bf344ffc6f9f098d55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Perona?= Date: Mon, 30 Sep 2024 12:43:36 -0400 Subject: [PATCH 14/19] move admin bar code to new architecture --- classes/Admin/AdminBar.php | 123 +++++++++++++++++++++++++++--- classes/Admin/ServiceProvider.php | 6 +- 2 files changed, 116 insertions(+), 13 deletions(-) diff --git a/classes/Admin/AdminBar.php b/classes/Admin/AdminBar.php index b5fcf364b..7cfd0b894 100644 --- a/classes/Admin/AdminBar.php +++ b/classes/Admin/AdminBar.php @@ -6,11 +6,28 @@ use Imagify\EventManagement\SubscriberInterface; use Imagify\User\User; use Imagify_Views; +use WP_Admin_Bar; /** * Admin bar handler */ class AdminBar implements SubscriberInterface { + /** + * User instance. + * + * @var User + */ + private $user; + + /** + * AdminBar constructor. + * + * @param User $user User instance. + */ + public function __construct( User $user ) { + $this->user = $user; + } + /** * Returns an array of events this subscriber listens to * @@ -19,9 +36,96 @@ class AdminBar implements SubscriberInterface { public static function get_subscribed_events(): array { return [ 'wp_ajax_imagify_get_admin_bar_profile' => 'get_admin_bar_profile_callback', + 'admin_bar_menu' => [ 'add_imagify_admin_bar_menu', IMAGIFY_INT_MAX ], ]; } + /** + * Add Imagify menu in the admin bar. + * + * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance, passed by reference. + */ + public function add_imagify_admin_bar_menu( $wp_admin_bar ) { + if ( ! imagify_get_context( 'wp' )->current_user_can( 'manage' ) ) { + return; + } + + if ( ! get_imagify_option( 'admin_bar_menu' ) ) { + return; + } + + // Parent. + $wp_admin_bar->add_menu( array( + 'id' => 'imagify', + 'title' => 'Imagify', + 'href' => get_imagify_admin_url(), + ) ); + + // Settings. + $wp_admin_bar->add_menu(array( + 'parent' => 'imagify', + 'id' => 'imagify-settings', + 'title' => __( 'Settings' ), + 'href' => get_imagify_admin_url(), + ) ); + + // Bulk Optimization. + if ( ! is_network_admin() ) { + $wp_admin_bar->add_menu(array( + 'parent' => 'imagify', + 'id' => 'imagify-bulk-optimization', + 'title' => __( 'Bulk Optimization', 'imagify' ), + 'href' => get_imagify_admin_url( 'bulk-optimization' ), + ) ); + } + + // Documentation. + $wp_admin_bar->add_menu(array( + 'parent' => 'imagify', + 'id' => 'imagify-documentation', + 'title' => __( 'Documentation', 'imagify' ), + 'href' => imagify_get_external_url( 'documentation' ), + 'meta' => array( + 'target' => '_blank', + ), + ) ); + + // Rate it. + $wp_admin_bar->add_menu(array( + 'parent' => 'imagify', + 'id' => 'imagify-rate-it', + /* translators: %s is WordPress.org. */ + 'title' => sprintf( __( 'Rate Imagify on %s', 'imagify' ), 'WordPress.org' ), + 'href' => imagify_get_external_url( 'rate' ), + 'meta' => array( + 'target' => '_blank', + ), + ) ); + + // Quota & Profile informations. + if ( defined( 'IMAGIFY_HIDDEN_ACCOUNT' ) && IMAGIFY_HIDDEN_ACCOUNT || ! get_imagify_option( 'api_key' ) ) { + return; + } + + if ( + $this->user->is_free() + && + $this->user->get_percent_unconsumed_quota() > 20 + ) { + $wp_admin_bar->add_menu( [ + 'parent' => 'imagify', + 'id' => 'imagify-upgrade-plan', + 'title' => '', + ] ); + } + + $wp_admin_bar->add_menu( array( + 'parent' => 'imagify', + 'id' => 'imagify-profile', + 'title' => wp_nonce_field( 'imagify-get-admin-bar-profile', 'imagifygetadminbarprofilenonce', false, false ) . '
' . __( 'Loading...', 'imagify' ) . '
', + ) ); + } + /** * Get admin bar profile output. * @@ -34,7 +138,6 @@ public function get_admin_bar_profile_callback() { imagify_die(); } - $user = new User(); $views = Imagify_Views::get_instance(); $unconsumed_quota = $views->get_quota_percent(); $text = ''; @@ -42,19 +145,15 @@ public function get_admin_bar_profile_callback() { $upgrade_link = ''; $upgrade_button = ''; - if ( $user->is_free() ) { + if ( $this->user->is_free() ) { $text = esc_html__( 'Upgrade your plan now for more!', 'rocket' ) . '
' . 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 = ''; - } - } elseif ( $user->is_growth() ) { + } elseif ( $this->user->is_growth() ) { $text = esc_html__( 'Switch to Infinite plan for unlimited optimization:', 'rocket' ) . '
'; - if ( $user->is_monthly ) { + if ( $this->user->is_monthly ) { $text .= esc_html__( 'For $9.99/month, optimize as many images as you like!', 'rocket' ); $upgrade_link = IMAGIFY_APP_DOMAIN . '/subscription/plan_switch/?label=infinite&payment_plan=1&utm_source=plugin&utm_medium=notification '; } else { @@ -68,11 +167,11 @@ public function get_admin_bar_profile_callback() { $data = [ 'quota_icon' => $views->get_quota_icon(), 'quota_class' => $views->get_quota_class(), - 'plan_label' => $user->plan_label, - 'plan_with_quota' => $user->is_free() || $user->is_growth(), + 'plan_label' => $this->user->plan_label, + 'plan_with_quota' => $this->user->is_free() || $this->user->is_growth(), 'unconsumed_quota' => $unconsumed_quota, - 'user_quota' => $user->quota, - 'next_update' => $user->next_date_update, + 'user_quota' => $this->user->quota, + 'next_update' => $this->user->next_date_update, 'text' => $text, 'button_text' => $button_text, 'upgrade_link' => $upgrade_link, diff --git a/classes/Admin/ServiceProvider.php b/classes/Admin/ServiceProvider.php index 5d4a96422..e1c7ba649 100644 --- a/classes/Admin/ServiceProvider.php +++ b/classes/Admin/ServiceProvider.php @@ -4,6 +4,7 @@ namespace Imagify\Admin; use Imagify\Dependencies\League\Container\ServiceProvider\AbstractServiceProvider; +use Imagify\User\User; /** * Service provider for Admin @@ -16,6 +17,7 @@ class ServiceProvider extends AbstractServiceProvider { */ protected $provides = [ 'admin_bar', + 'user', ]; /** @@ -33,7 +35,9 @@ class ServiceProvider extends AbstractServiceProvider { * @return void */ public function register() { - $this->getContainer()->share( 'admin_bar', AdminBar::class ); + $this->getContainer()->add( 'user', User::class ); + $this->getContainer()->share( 'admin_bar', AdminBar::class ) + ->addArgument( $this->getContainer()->get( 'user' ) ); } /** From dd793bc5b7eac3b6f4a02b76dd4119b91733d766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Perona?= Date: Mon, 30 Sep 2024 15:21:13 -0400 Subject: [PATCH 15/19] remove extra code --- classes/Admin/ServiceProvider.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/classes/Admin/ServiceProvider.php b/classes/Admin/ServiceProvider.php index e1c7ba649..680480ea4 100644 --- a/classes/Admin/ServiceProvider.php +++ b/classes/Admin/ServiceProvider.php @@ -17,7 +17,6 @@ class ServiceProvider extends AbstractServiceProvider { */ protected $provides = [ 'admin_bar', - 'user', ]; /** @@ -35,7 +34,6 @@ class ServiceProvider extends AbstractServiceProvider { * @return void */ public function register() { - $this->getContainer()->add( 'user', User::class ); $this->getContainer()->share( 'admin_bar', AdminBar::class ) ->addArgument( $this->getContainer()->get( 'user' ) ); } From f5d85e24c26513967907f50e25dd0f59a27ed467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Perona?= Date: Mon, 30 Sep 2024 15:22:47 -0400 Subject: [PATCH 16/19] update loading order --- config/providers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/providers.php b/config/providers.php index 63925a05e..9cdbbec97 100644 --- a/config/providers.php +++ b/config/providers.php @@ -1,10 +1,10 @@ Date: Mon, 30 Sep 2024 15:23:03 -0400 Subject: [PATCH 17/19] remove unused import --- classes/Admin/ServiceProvider.php | 1 - 1 file changed, 1 deletion(-) diff --git a/classes/Admin/ServiceProvider.php b/classes/Admin/ServiceProvider.php index 680480ea4..e1683314f 100644 --- a/classes/Admin/ServiceProvider.php +++ b/classes/Admin/ServiceProvider.php @@ -4,7 +4,6 @@ namespace Imagify\Admin; use Imagify\Dependencies\League\Container\ServiceProvider\AbstractServiceProvider; -use Imagify\User\User; /** * Service provider for Admin From 8794762110d5e0904e696d0758447f43070a2f6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Perona?= Date: Fri, 4 Oct 2024 13:19:55 -0400 Subject: [PATCH 18/19] remove unused code --- classes/Admin/AdminBar.php | 2 -- views/admin/admin-bar-status.php | 1 - 2 files changed, 3 deletions(-) diff --git a/classes/Admin/AdminBar.php b/classes/Admin/AdminBar.php index 7cfd0b894..6796d7501 100644 --- a/classes/Admin/AdminBar.php +++ b/classes/Admin/AdminBar.php @@ -143,7 +143,6 @@ public function get_admin_bar_profile_callback() { $text = ''; $button_text = ''; $upgrade_link = ''; - $upgrade_button = ''; if ( $this->user->is_free() ) { $text = esc_html__( 'Upgrade your plan now for more!', 'rocket' ) . '
' . @@ -175,7 +174,6 @@ 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 ); diff --git a/views/admin/admin-bar-status.php b/views/admin/admin-bar-status.php index 1880fa5f4..c688f8eca 100644 --- a/views/admin/admin-bar-status.php +++ b/views/admin/admin-bar-status.php @@ -1,7 +1,6 @@ -
From 0082f1e407655620a7b9e1b94c91b1ee3d2c7f36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Perona?= Date: Tue, 8 Oct 2024 09:31:34 -0400 Subject: [PATCH 19/19] update min file --- assets/js/pricing-modal.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/pricing-modal.min.js b/assets/js/pricing-modal.min.js index 763e601e3..d6a3d760e 100755 --- a/assets/js/pricing-modal.min.js +++ b/assets/js/pricing-modal.min.js @@ -1 +1 @@ -!function(t,i){t(i).on("click.imagify",".imagify-tab",function(i){var e=t(this),a="imagify-current";i.preventDefault(),e.hasClass("imagify-current")||(i=e.find("a").attr("href")||"#"+e.find("a").attr("aria-controls"),e.closest(".imagify-tabs").next(".imagify-tabs-contents").find(".imagify-tab-content").hide().attr("aria-hidden","true"),t(i).fadeIn(275).attr("aria-hidden","false"),e.closest(".imagify-tabs").find(".imagify-tab").removeClass(a).attr("aria-selected","false"),e.addClass(a).attr("aria-selected","true"))})}(jQuery,document,window),function(b,i,k){var _={};b("#imagify-pricing-modal").length&&((_={$modal:b("#imagify-pricing-modal"),$checkboxes:b(".imagify-offer-line .imagify-checkbox"),$radios:b(".imagify-payment-modal .imagify-radio-line input"),$preView:b("#imagify-pre-checkout-view"),$plansView:b("#imagify-plans-selection-view").hide(),$paymentView:b("#imagify-payment-process-view").hide(),$successView:b("#imagify-success-view").hide(),$anotherBtn:b(".imagify-choose-another-plan"),speedFadeIn:300,getHtmlPrice:function(i,e){var a,t;return e=e||null,"object"!=typeof i?((i=(i+="").split("."))[1]=1===i[1].length?i[1]+"0":(""+i[1]).substring(0,2),t=''+i[0]+" ",t+('.'+i[1])+""):(a=i.monthly+"",i=i.yearly+"",a="0"===a?["0","00"]:a.split("."),i="0"===i?["0","00"]:i.split("."),(t=(t=(t=(t='')+''+a[0]+" ")+'.'+(1===a[1].length?a[1]+"0":(""+a[1]).substring(0,2))+" ")+''+i[0]+" ")+'.'+(1===i[1].length?i[1]+"0":(""+i[1]).substring(0,2))+"")},getHtmlDiscountPrice:function(i,e){var a="";return e=e||null,a="object"==typeof i?(a=(a=(a+='$')+''+(i.monthly+"")+"")+'')+''+(i.yearly+"")+"":(a+='$')+''+(i+="")+""},populateOffer:function(i,e,a,t){var o,n=k.imagify_discount_datas,l=e.additional_gb,s=e.annual_cost,f=e.id,c=e.label,m=e.monthly_cost,r=e.quota,e=e.cost,d=-1===r?"Unlimited":1e3<=r?r/1e3+" GB":r+" MB",y="monthly"===a?{monthly:m,yearly:Math.round(s/12*100)/100}:e,g=y,p=[],p=_.getPromoAppliesTo(n);return n.is_active&&"percentage"===n.coupon_type&&"monthly"===a&&0

'+imagifyPricingModal.labels.errorPriceAPI+"

");else{if((k.imagify_discount_datas=e).is_active){if(e.applies_to instanceof Array){for(var d=[],y=[],g=0;gm.quota&&(m={index:i,selected:1,quota:e.quota,plan_id:e.id,plan_label:e.label}),0===e.monthly_cost&&0===e.annual_cost||e.quota<=0&&a.month>e.quota||a.total>e.quota||0<=e.quota&&a.monthe.quota)&&(o=e,r.mo={index:i,selected:t>a.month&&t>a.total?0:1,plan_id:e.id,plan_label:e.label}),!0}),!1===r.mo&&(r.mo=void 0!==n?n:m),c-=i.mo[r.mo.index].quota,0!==i.ot.length&&(c<=0?(b.each(i.ot,function(i,e){return e.quota'+a.find(".imagify-price-by").text()+"",c=a.find(".imagify-price-discount").html(),m=a.find(".imagify-approx-nb").text(),r=a.find(".imagify-offer-size").text(),d=b("#imagify-coupon-code");i.preventDefault(),_.switchToView(_.$preView),l.find(".imagify-number-block").html(s+f),c?(l.find(".imagify-price-discount").length<=0&&l.find(".imagify-col-price").prepend(''),l.find(".imagify-price-discount").html(c),l.find(".imagify-price-discount").show()):l.find(".imagify-price-discount").hide(),l.find(".imagify-approx-nb").text(m),l.find(".imagify-offer-size").text(r),l.attr("data-offer",o),n||(l.find(".imagify-price-add-data").text(a.find(".imagify-price-add-data").text()),("monthly"===e?l.find("#imagify-subscription-monthly"):l.find("#imagify-subscription-yearly")).trigger("click.imagify"),l.find(".imagify-inline-options").find("input:radio:checked").trigger("change.imagify")),(d=b("#imagify-coupon-code")).val(""),k.imagify_discount_datas&&((i=_.getPromoAppliesTo(k.imagify_discount_datas)).includes(t[Object.keys(t)[0]].label)||"all"===i[0])&&d.val(k.imagify_discount_datas.label),_.checkCoupon(),_.populatePayBtn()}),b("#imagify-modal-checkout-btn").on("click.imagify",function(i){var e,a;i.preventDefault(),b(this).hasClass("imagify-button-disabled")||(i=b(".imagify-offer-monthly"),e=b(".imagify-offer-onetime"),a={},i.hasClass("imagify-offer-selected")&&(a.monthly=JSON.parse(i.attr("data-offer"))),e.hasClass("imagify-offer-selected")&&(a.onetime=JSON.parse(e.attr("data-offer"))),imagifyPricingModal.userDataCache&&b.post(ajaxurl,{action:imagifyPricingModal.userDataCache.deleteAction,_wpnonce:imagifyPricingModal.userDataCache.deleteNonce}),_.switchToView(_.$paymentView),a.period=_.getPeriod(),_.iframeSetSrc(a))}),b(".imagify-back-to-plans").on("click.imagify",function(i){var e=b(this).closest(".imagify-cart-item").hasClass("imagify-cart-item-onetime");i.preventDefault(),b(e?".imagify-offer-onetime":".imagify-offer-monthly").find(".imagify-choose-another-plan").trigger("click.imagify")}),k.addEventListener("message",_.checkPluginMessage,!0))}(jQuery,document,window); \ No newline at end of file +!function(t,i){t(i).on("click.imagify",".imagify-tab",function(i){var e=t(this),a="imagify-current";i.preventDefault(),e.hasClass("imagify-current")||(i=e.find("a").attr("href")||"#"+e.find("a").attr("aria-controls"),e.closest(".imagify-tabs").next(".imagify-tabs-contents").find(".imagify-tab-content").hide().attr("aria-hidden","true"),t(i).fadeIn(275).attr("aria-hidden","false"),e.closest(".imagify-tabs").find(".imagify-tab").removeClass(a).attr("aria-selected","false"),e.addClass(a).attr("aria-selected","true"))})}(jQuery,document,window),function(b,i,k){var _={};b("#imagify-pricing-modal").length&&((_={$modal:b("#imagify-pricing-modal"),$checkboxes:b(".imagify-offer-line .imagify-checkbox"),$radios:b(".imagify-payment-modal .imagify-radio-line input"),$preView:b("#imagify-pre-checkout-view"),$plansView:b("#imagify-plans-selection-view").hide(),$paymentView:b("#imagify-payment-process-view").hide(),$successView:b("#imagify-success-view").hide(),$anotherBtn:b(".imagify-choose-another-plan"),speedFadeIn:300,getHtmlPrice:function(i,e){var a,t;return e=e||null,"object"!=typeof i?((i=(i+="").split("."))[1]=1===i[1].length?i[1]+"0":(""+i[1]).substring(0,2),t=''+i[0]+" ",t+('.'+i[1])+""):(a=i.monthly+"",i=i.yearly+"",a="0"===a?["0","00"]:a.split("."),i="0"===i?["0","00"]:i.split("."),(t=(t=(t=(t='')+''+a[0]+" ")+'.'+(1===a[1].length?a[1]+"0":(""+a[1]).substring(0,2))+" ")+''+i[0]+" ")+'.'+(1===i[1].length?i[1]+"0":(""+i[1]).substring(0,2))+"")},getHtmlDiscountPrice:function(i,e){var a="";return e=e||null,a="object"==typeof i?(a=(a=(a+='$')+''+(i.monthly+"")+"")+'')+''+(i.yearly+"")+"":(a+='$')+''+(i+="")+""},populateOffer:function(i,e,a,t){var o,n=k.imagify_discount_datas,l=e.additional_gb,s=e.annual_cost,f=e.id,c=e.label,m=e.monthly_cost,r=e.quota,e=e.cost,d=-1===r?"Unlimited":1e3<=r?r/1e3+" GB":r+" MB",y="monthly"===a?{monthly:m,yearly:Math.round(s/12*100)/100}:e,g=y,p=[],p=_.getPromoAppliesTo(n);return n.is_active&&"percentage"===n.coupon_type&&"monthly"===a&&0

'+imagifyPricingModal.labels.errorPriceAPI+"

");else{if((k.imagify_discount_datas=e).is_active){if(e.applies_to instanceof Array){for(var d=[],y=[],g=0;gm.quota&&(m={index:i,selected:1,quota:e.quota,plan_id:e.id,plan_label:e.label}),0===e.monthly_cost&&0===e.annual_cost||e.quota<=0&&a.month>e.quota||a.total>e.quota||0<=e.quota&&a.monthe.quota)&&(o=e,r.mo={index:i,selected:t>a.month&&t>a.total?0:1,plan_id:e.id,plan_label:e.label}),!0}),!1===r.mo&&(r.mo=void 0!==n?n:m),c-=i.mo[r.mo.index].quota,0!==i.ot.length&&(c<=0?(b.each(i.ot,function(i,e){return e.quota'+a.find(".imagify-price-by").text()+"",c=a.find(".imagify-price-discount").html(),m=a.find(".imagify-approx-nb").text(),r=a.find(".imagify-offer-size").text(),d=b("#imagify-coupon-code");i.preventDefault(),_.switchToView(_.$preView),l.find(".imagify-number-block").html(s+f),c?(l.find(".imagify-price-discount").length<=0&&l.find(".imagify-col-price").prepend(''),l.find(".imagify-price-discount").html(c),l.find(".imagify-price-discount").show()):l.find(".imagify-price-discount").hide(),l.find(".imagify-approx-nb").text(m),l.find(".imagify-offer-size").text(r),l.attr("data-offer",o),n||(l.find(".imagify-price-add-data").text(a.find(".imagify-price-add-data").text()),("monthly"===e?l.find("#imagify-subscription-monthly"):l.find("#imagify-subscription-yearly")).trigger("click.imagify"),l.find(".imagify-inline-options").find("input:radio:checked").trigger("change.imagify")),(d=b("#imagify-coupon-code")).val(""),k.imagify_discount_datas&&((i=_.getPromoAppliesTo(k.imagify_discount_datas)).includes(t[Object.keys(t)[0]].label)||"all"===i[0])&&d.val(k.imagify_discount_datas.label),_.checkCoupon(),_.populatePayBtn()}),b("#imagify-modal-checkout-btn").on("click.imagify",function(i){var e,a;i.preventDefault(),b(this).hasClass("imagify-button-disabled")||(i=b(".imagify-offer-monthly"),e=b(".imagify-offer-onetime"),a={},i.hasClass("imagify-offer-selected")&&(a.monthly=JSON.parse(i.attr("data-offer"))),e.hasClass("imagify-offer-selected")&&(a.onetime=JSON.parse(e.attr("data-offer"))),imagifyPricingModal.userDataCache&&b.post(ajaxurl,{action:imagifyPricingModal.userDataCache.deleteAction,_wpnonce:imagifyPricingModal.userDataCache.deleteNonce}),_.switchToView(_.$paymentView),a.period=_.getPeriod(),_.iframeSetSrc(a))}),b(".imagify-back-to-plans").on("click.imagify",function(i){var e=b(this).closest(".imagify-cart-item").hasClass("imagify-cart-item-onetime");i.preventDefault(),b(e?".imagify-offer-onetime":".imagify-offer-monthly").find(".imagify-choose-another-plan").trigger("click.imagify")}),k.addEventListener("message",_.checkPluginMessage,!0))}(jQuery,document,window); \ No newline at end of file