From 4b76b8cef8c25d53ba916c5d475d1220fb27409c Mon Sep 17 00:00:00 2001 From: E2E Environment Date: Tue, 10 Dec 2024 11:16:56 +0100 Subject: [PATCH] Add more getter method --- classes/Admin/AdminBar.php | 2 +- classes/Admin/AdminSubscriber.php | 6 +++--- classes/User/User.php | 22 ++++++++++++++++++++++ inc/functions/admin.php | 2 +- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/classes/Admin/AdminBar.php b/classes/Admin/AdminBar.php index 6796d7501..61ad60f93 100644 --- a/classes/Admin/AdminBar.php +++ b/classes/Admin/AdminBar.php @@ -169,7 +169,7 @@ public function get_admin_bar_profile_callback() { 'plan_label' => $this->user->plan_label, 'plan_with_quota' => $this->user->is_free() || $this->user->is_growth(), 'unconsumed_quota' => $unconsumed_quota, - 'user_quota' => $this->user->quota, + 'user_quota' => $this->user->get_quota(), 'next_update' => $this->user->next_date_update, 'text' => $text, 'button_text' => $button_text, diff --git a/classes/Admin/AdminSubscriber.php b/classes/Admin/AdminSubscriber.php index edc79b397..32dc7630e 100644 --- a/classes/Admin/AdminSubscriber.php +++ b/classes/Admin/AdminSubscriber.php @@ -50,9 +50,9 @@ public static function get_subscribed_events() { * @return array */ public function plugin_action_links( $actions ) { - $text = 1 !== $this->user->plan_id ? __( 'Documentation', 'imagify' ) : __( 'Upgrade', 'imagify' ); - $url = 1 !== $this->user->plan_id ? 'documentation' : 'subscription'; - $class = 1 !== $this->user->plan_id ? '' : ' class="imagify-plugin-upgrade"'; + $text = 1 !== $this->user->get_plan_id() ? __( 'Documentation', 'imagify' ) : __( 'Upgrade', 'imagify' ); + $url = 1 !== $this->user->get_plan_id() ? 'documentation' : 'subscription'; + $class = 1 !== $this->user->get_plan_id() ? '' : ' class="imagify-plugin-upgrade"'; array_unshift( $actions, sprintf( '%s', esc_url( imagify_get_external_url( $url ) ), diff --git a/classes/User/User.php b/classes/User/User.php index 93339c67e..59cd66a5f 100755 --- a/classes/User/User.php +++ b/classes/User/User.php @@ -336,4 +336,26 @@ public function get_email() { return $this->email; } + + /** + * Get plan id. + * + * @return int + */ + public function get_plan_id() { + $this->init_user(); + + return $this->plan_id; + } + + /** + * Get user quota. + * + * @return int + */ + public function get_quota() { + $this->init_user(); + + return $this->quota; + } } diff --git a/inc/functions/admin.php b/inc/functions/admin.php index efe7c9354..566b34e71 100755 --- a/inc/functions/admin.php +++ b/inc/functions/admin.php @@ -411,7 +411,7 @@ function imagify_cache_user() { } } - $data->quota_formatted = imagify_size_format( $user->quota * pow( 1024, 2 ) ); + $data->quota_formatted = imagify_size_format( $user->get_quota() * pow( 1024, 2 ) ); $data->next_date_update_formatted = date_i18n( get_option( 'date_format' ), strtotime( $user->next_date_update ) ); if ( imagify_is_active_for_network() ) {