Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,11 @@ public function get_usage_stat( $type, $stat = null ) {

if ( 'limit' === $stat && isset( $this->usage[ $type ]['usage'] ) ) {
$value = $this->usage[ $type ]['usage'];
} elseif ( 'used_percent' === $stat && isset( $this->usage[ $type ]['credits_usage'] ) ) {
} elseif (
'used_percent' === $stat
&& isset( $this->usage[ $type ]['credits_usage'] )
&& ! empty( $this->usage['credits']['limit'] )
) {
// Calculate percentage based on credit limit and usage.
$value = round( $this->usage[ $type ]['credits_usage'] / $this->usage['credits']['limit'] * 100, 2 );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,29 @@
<?php if ( false !== $connection->get_usage_stat( 'credits', 'limit' ) ) : ?>
<span class="cloudinary-stat" title="<?php esc_attr_e( 'Credits', 'cloudinary' ); ?>">
<span class="dashicons dashicons-marker"></span> <?php esc_html_e( number_format_i18n( $connection->get_usage_stat( 'credits', 'limit' ) ) ); ?>
<span class="cloudinary-percent"> <?php esc_html_e( $connection->get_usage_stat( 'credits', 'used_percent' ) . '%' ); ?></span> |
<?php if ( false !== $connection->get_usage_stat( 'credits', 'used_percent' ) ) : ?>
<span class="cloudinary-percent"> <?php esc_html_e( $connection->get_usage_stat( 'credits', 'used_percent' ) . '%' ); ?></span> |
<?php endif; ?>
</span>
<?php endif; ?>

<span class="cloudinary-stat" title="<?php esc_attr_e( 'Storage', 'cloudinary' ); ?>">
<span class="dashicons dashicons-cloud"></span> <?php esc_html_e( size_format( $connection->get_usage_stat( 'storage', 'limit' ) ) ); ?>
<span class="cloudinary-percent"> <?php esc_html_e( $connection->get_usage_stat( 'storage', 'used_percent' ) . '%' ); ?></span> |
<?php if ( false !== $connection->get_usage_stat( 'storage', 'used_percent' ) ) : ?>
<span class="cloudinary-percent"> <?php esc_html_e( $connection->get_usage_stat( 'storage', 'used_percent' ) . '%' ); ?></span> |
<?php endif; ?>
</span>
<span class="cloudinary-stat" title="<?php esc_attr_e( 'Transformations', 'cloudinary' ); ?>">
<span class="dashicons dashicons-image-filter"></span> <?php esc_html_e( number_format_i18n( $connection->get_usage_stat( 'transformations', 'limit' ) ) ); ?>
<span class="cloudinary-percent success"> <?php esc_html_e( $connection->get_usage_stat( 'transformations', 'used_percent' ) . '%' ); ?></span> |
<?php if ( false !== $connection->get_usage_stat( 'transformations', 'used_percent' ) ) : ?>
<span class="cloudinary-percent success"> <?php esc_html_e( $connection->get_usage_stat( 'transformations', 'used_percent' ) . '%' ); ?></span> |
<?php endif; ?>
</span>
<span class="cloudinary-stat" title="<?php esc_attr_e( 'Bandwidth', 'cloudinary' ); ?>">
<span class="dashicons dashicons-dashboard"></span> <?php esc_html_e( size_format( $connection->get_usage_stat( 'bandwidth', 'limit' ) ) ); ?>
<span class="cloudinary-percent success"> <?php esc_html_e( $connection->get_usage_stat( 'bandwidth', 'used_percent' ) . '%' ); ?></span>
<?php if ( false !== $connection->get_usage_stat( 'bandwidth', 'used_percent' ) ) : ?>
<span class="cloudinary-percent success"> <?php esc_html_e( $connection->get_usage_stat( 'bandwidth', 'used_percent' ) . '%' ); ?></span>
<?php endif; ?>
</span>
</div>
<hr>
Expand Down