phpface

myCred: Display total points of current author

Jun 18th, 2022 (edited)
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.37 KB | None | 0 0
  1. add_filter( 'streamtube/core/mycred/button_donate', function( $args ){
  2.     $args['button_classes'][] = 'ms-sm-auto';
  3.     return $args;
  4. }, 10, 2 );
  5.  
  6. add_action( 'streamtube/core/mycred/button_donate/before', function( $args ){
  7.  
  8.     $author = 0;
  9.  
  10.     if( is_singular( 'video' ) ){
  11.         global $post;
  12.  
  13.         $author = $post->post_author;
  14.     }
  15.  
  16.     if( is_author() ){
  17.         $author = get_queried_object_id();
  18.     }
  19.  
  20.     $total_points = mycred_display_users_balance( $author );
  21.  
  22.     if( $total_points ){
  23.         ?>
  24.         <span class="total-points d-block mb-2 text-secondary">
  25.             <?php
  26.                 printf(
  27.                     esc_html__( '%s collected %s', 'streamtube-child' ),
  28.                     '<strong class="text-secondary">'. get_userdata( $author )->display_name .'</strong>',
  29.                     '<strong class="text-info">$'. number_format_i18n( $total_points ) .'</strong>'
  30.                 );
  31.             ?>
  32.         </span>
  33.         <?php
  34.     }
  35.  
  36. }, 10, 1 );
  37.  
  38. add_action( 'wp_footer', function(){
  39.     ?>
  40.     <style type="text/css">
  41.         @media (max-width: 768px){
  42.  
  43.             body.author .button-donate-wrap{
  44.                 text-align: center;
  45.             }
  46.             body.author .button-donate-wrap .button-group button{
  47.                 margin: 0 auto!important;
  48.             }
  49.         }
  50.     </style>
  51.     <?php
  52. } );
Add Comment
Please, Sign In to add comment