diff --git a/Tests/Unit/inc/classes/ImagifyUser/getError.php b/Tests/Unit/inc/classes/ImagifyUser/getError.php index c1e423e82..c13bf70b0 100644 --- a/Tests/Unit/inc/classes/ImagifyUser/getError.php +++ b/Tests/Unit/inc/classes/ImagifyUser/getError.php @@ -28,6 +28,7 @@ public function testShouldReturnFalseWhenFetchedUserData() { 'consumed_current_month_quota' => 123, 'next_date_update' => '', 'is_active' => 1, + 'is_monthly' => true, ]; Functions\when( 'get_imagify_user' )->justReturn( $userData ); diff --git a/Tests/Unit/inc/classes/ImagifyUser/getPercentConsumedQuota.php b/Tests/Unit/inc/classes/ImagifyUser/getPercentConsumedQuota.php index b1b656d1e..5d50b89a6 100644 --- a/Tests/Unit/inc/classes/ImagifyUser/getPercentConsumedQuota.php +++ b/Tests/Unit/inc/classes/ImagifyUser/getPercentConsumedQuota.php @@ -44,6 +44,7 @@ public function testShouldReturnQuotaWhenFetchedUserData() { 'consumed_current_month_quota' => 900, // Current consumed quota 90%. 'next_date_update' => '', 'is_active' => 1, + 'is_monthly' => true, ]; Functions\when( 'get_imagify_user' )->justReturn( $userData ); diff --git a/Tests/Unit/inc/classes/ImagifyUser/isOverQuota.php b/Tests/Unit/inc/classes/ImagifyUser/isOverQuota.php index 7169ca9c0..35f2bc20d 100644 --- a/Tests/Unit/inc/classes/ImagifyUser/isOverQuota.php +++ b/Tests/Unit/inc/classes/ImagifyUser/isOverQuota.php @@ -42,6 +42,7 @@ public function testShouldReturnFalseWhenPaidAccount() { 'consumed_current_month_quota' => 123, 'next_date_update' => '', 'is_active' => 1, + 'is_monthly' => true, ]; Functions\when( 'get_imagify_user' )->justReturn( $userData ); @@ -64,6 +65,7 @@ public function testShouldReturnFalseWhenFreeNotOverQuota() { 'consumed_current_month_quota' => 900, // Current consumed quota 90%. 'next_date_update' => '', 'is_active' => 1, + 'is_monthly' => true, ]; $this->createMocks( $userData, 90 ); @@ -86,6 +88,7 @@ public function testShouldReturnTrueWhenFreeOverQuota() { 'consumed_current_month_quota' => 1000, // Current consumed quota 100%. 'next_date_update' => '', 'is_active' => 1, + 'is_monthly' => true, ]; $this->createMocks( $userData, 100 ); diff --git a/assets/css/admin.css b/assets/css/admin.css index 29897c0e0..f9ec99fdd 100755 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -1543,3 +1543,45 @@ ul.imagify-datas-details.imagify-datas-details { padding-right: 0em; } } + +.imagify-upsell { + position:relative; + background: #c51161; + padding: 20px 40px; +} + +.imagify-upsell p { + color: #fff !important; +} + +.imagify-upsell-button { + display: block; + background: #fff; + border-radius: 5px; + color: #c51161 !important; + font-weight: bold; + padding: 10px; + text-align: center; + text-decoration: none; + text-transform: uppercase; +} + +.imagify-upsell-arrow::after { + content: '\2192'; + font-size: large; + margin-left: 5px; + vertical-align: top; +} + +.imagify-upsell-dismiss::before { + position: absolute; + top: 5px; + right: 5px; + content: "\2715"; + color: #2e3243; + font-size: 2em; +} + +.imagify-upsell .imagify-meteo-icon { + filter: invert(100%) sepia(100%) saturate(0%) hue-rotate(104deg) brightness(103%) contrast(103%); +} diff --git a/assets/css/bulk.css b/assets/css/bulk.css index fa6063dc4..cf3685183 100755 --- a/assets/css/bulk.css +++ b/assets/css/bulk.css @@ -330,7 +330,7 @@ body[class*="_imagify-ngg-bulk-optimization"] .media-item .progress .bar { .imagify-col-content .imagify-meteo-icon { height: 64px; - margin: 15px 15px 15px 20px; + margin: 15px 15px 15px 0; } .imagify-col-content .imagify-section-title + p { diff --git a/assets/css/options.css b/assets/css/options.css index c1d6b2fb3..6da0e12ff 100755 --- a/assets/css/options.css +++ b/assets/css/options.css @@ -936,3 +936,19 @@ input:checked + label .imagify-fake-checkbox:after, margin-top: 20px; } } + +.imagify-col-content .imagify-space-left { + margin: 15px 30px 15px 0; +} + +.imagify-col-content .imagify-space-left p { + margin: 0 0 10px 0; + font-size: 19px; + font-weight: 500; + color: #343A49; +} + +.imagify-col-content .imagify-meteo-icon { + height: 64px; + margin: 15px 15px 15px 0; +} diff --git a/assets/js/notices.js b/assets/js/notices.js index 6ca397b9b..cf13be3c1 100755 --- a/assets/js/notices.js +++ b/assets/js/notices.js @@ -6,7 +6,7 @@ */ $( '.imagify-notice-dismiss' ).on( 'click.imagify', function( e ) { var $this = $( this ), - $parent = $this.parents( '.imagify-welcome, .imagify-notice, .imagify-rkt-notice' ), + $parent = $this.parents( '.imagify-welcome, .imagify-notice, .imagify-rkt-notice, .imagify-upsell' ), href = $this.attr( 'href' ); e.preventDefault(); diff --git a/classes/Notices/Notices.php b/classes/Notices/Notices.php index 79eeaf28b..f97faca1e 100644 --- a/classes/Notices/Notices.php +++ b/classes/Notices/Notices.php @@ -67,8 +67,6 @@ class Notices { 'http-block-external', // This warning is displayed when the grid view is active on the library. Dismissible. 'grid-view', - // This warning is displayed to warn the user that the quota is almost consumed for the current month. Dismissible. - 'almost-over-quota', // This warning is displayed if the backup folder is not writable. NOT dismissible. 'backup-folder-not-writable', // This notice is displayed to rate the plugin after 100 optimizations & 7 days after the first installation. Dismissible. @@ -77,6 +75,7 @@ class Notices { 'wp-rocket', 'bulk-optimization-complete', 'bulk-optimization-running', + 'upsell-banner', ]; /** @@ -251,7 +250,7 @@ public function deactivate_plugin() { public function renew_almost_over_quota_notice() { global $wpdb; - $results = $wpdb->get_results( $wpdb->prepare( "SELECT umeta_id, user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value LIKE %s", self::DISMISS_META_NAME, '%almost-over-quota%' ) ); + $results = $wpdb->get_results( $wpdb->prepare( "SELECT umeta_id, user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value LIKE %s", self::DISMISS_META_NAME, '%upsell%' ) ); if ( ! $results ) { return; @@ -272,7 +271,7 @@ public function renew_almost_over_quota_notice() { // Renew the notice for all users. foreach ( $results as $result ) { - self::renew_notice( 'almost-over-quota', $result->user_id ); + self::renew_notice( 'upsell-banner', $result->user_id ); } } @@ -440,45 +439,6 @@ public function display_grid_view() { return $display; } - /** - * Tell if the 'almost-over-quota' notice should be displayed. - * - * @since 1.7.0 - * - * @return bool|object An Imagify user object. False otherwise. - */ - public function display_almost_over_quota() { - static $display; - - if ( isset( $display ) ) { - return $display; - } - - $display = false; - - if ( ! $this->user_can( 'almost-over-quota' ) ) { - return $display; - } - - if ( ! imagify_is_screen( 'imagify-settings' ) && ! imagify_is_screen( 'bulk' ) ) { - return $display; - } - - if ( self::notice_is_dismissed( 'almost-over-quota' ) ) { - return $display; - } - - $user = new User(); - - // Don't display the notice if the user's unconsumed quota is superior to 20%. - if ( $user->get_percent_unconsumed_quota() > 20 ) { - return $display; - } - - $display = $user; - return $display; - } - /** * Tell if the 'backup-folder-not-writable' notice should be displayed. * diff --git a/classes/User/User.php b/classes/User/User.php index 9e6813490..6786152ac 100755 --- a/classes/User/User.php +++ b/classes/User/User.php @@ -101,6 +101,13 @@ class User { */ public $is_active; + /** + * If the account is monthly or yearly. + * + * @var bool + */ + public $is_monthly; + /** * Store a \WP_Error object if the request to fetch the user data failed. * False overwise. @@ -135,6 +142,7 @@ public function __construct() { $this->consumed_current_month_quota = $user->consumed_current_month_quota; $this->next_date_update = $user->next_date_update; $this->is_active = $user->is_active; + $this->is_monthly = $user->is_monthly; $this->error = false; } @@ -244,6 +252,24 @@ public function is_free() { return 1 === $this->plan_id; } + /** + * Check if the user is a growth account + * + * @return bool + */ + public function is_growth() { + return ( 16 === $this->plan_id || 18 === $this->plan_id ); + } + + /** + * Check if the user is an infinite account + * + * @return bool + */ + public function is_infinite() { + return ( 15 === $this->plan_id || 17 === $this->plan_id ); + } + /** * Check if the user has consumed all his/her quota. * diff --git a/views/notice-almost-over-quota.php b/views/notice-almost-over-quota.php deleted file mode 100755 index ff8ddb2a4..000000000 --- a/views/notice-almost-over-quota.php +++ /dev/null @@ -1,39 +0,0 @@ -print_template( 'notice-header', array( - 'classes' => array( 'imagify-flex-notice-content', 'error' ), -) ); - -$views = Imagify_Views::get_instance(); -?> -
- ' . $views->get_quota_percent() . '%' - ); - ?> -
- -- -
- -print_template( 'notice-footer', array( - 'dismissible' => 'almost-over-quota', -) ); diff --git a/views/page-bulk.php b/views/page-bulk.php index 2efd24fd7..a6657acef 100755 --- a/views/page-bulk.php +++ b/views/page-bulk.php @@ -88,8 +88,11 @@- ' . $this->get_quota_percent() . '%' - ); - ?> -
- -- get_quota_percent() ) { - esc_html_e( 'Oops, It\'s Over!', 'imagify' ); - } elseif ( $this->get_quota_percent() <= 20 ) { - esc_html_e( 'Oops, It\'s almost over!', 'imagify' ); - } else { - esc_html_e( 'You\'re new to Imagify?', 'imagify' ); - } - ?> -
- - - -+ ' . $this->get_quota_percent() . '%' + ); + ?> +
+ +