Skip to content

Commit

Permalink
Add more getter method
Browse files Browse the repository at this point in the history
  • Loading branch information
E2E Environment committed Dec 10, 2024
1 parent c671fca commit 4b76b8c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion classes/Admin/AdminBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions classes/Admin/AdminSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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( '<a href="%s" target="_blank"%s>%s</a>',
esc_url( imagify_get_external_url( $url ) ),
Expand Down
22 changes: 22 additions & 0 deletions classes/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
2 changes: 1 addition & 1 deletion inc/functions/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() ) {
Expand Down

0 comments on commit 4b76b8c

Please sign in to comment.