Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'the_content', 'mycred_rank_progress_bar_in_bottom' );
- function mycred_rank_progress_bar_in_bottom( $content ) {
- global $post;
- if ( $post->post_type == 'mycred_rank' && function_exists( 'mycred' ) ) {
- $mycred = mycred();
- $min = get_post_meta( $post->ID, 'mycred_rank_min', true );
- $max = get_post_meta( $post->ID, 'mycred_rank_max', true );
- ob_start(); ?>
- <div class="blog-pad blog-content-excerpt">
- <p>This rank requires a minimum token earnings of <?php echo $mycred->format_creds( $min ); ?>.</p>
- <?php if ( is_user_logged_in() ) : $users_balance = $mycred->get_users_balance( get_current_user_id() ); ?>
- <h5>Your rank progress</h5>
- <?php
- $progress = number_format( ( ( $users_balance / $max ) * 100 ), 1 );
- $options = 'options="striped,animated"';
- if ( $users_balance > $min && $users_balance > $max ) {
- $progress = number_format( 100, 1 );
- $options = '';
- }
- elseif ( $users_balance < $min ) {
- $progress = number_format( 0, 1 );
- $options = '';
- }
- echo do_shortcode( '[vc_row][vc_column width="1/1"][vc_progress_bar values="' . $progress . '|' . get_the_title() . '" bgcolor="custom" ' . $options . ' custombgcolor="#E74C3C" title="" units="%"]<div class="mycred-progress-desc"><div class="rank-minimum">' . $mycred->format_creds( $min ) . '</div><div class="rank-maximum">' . $mycred->format_creds( $max ) . '</div></div>[/vc_column][/vc_row]' );
- endif;
- ?>
- </div>
- <?php
- $bottom = ob_get_contents();
- ob_end_clean();
- $content .= $bottom;
- }
- return $content;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement