Advertisement
phpface

Untitled

Jun 18th, 2023
766
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. add_filter( 'streamtube/core/widget/posts/query_args', function( $query_args, $instance ){
  2.  
  3.     $current_logged_in_user = get_current_user_id();
  4.  
  5.     if( ! function_exists( 'wpuf_is_following' ) ){
  6.         return $query_args;
  7.     }
  8.  
  9.     $query_args = wp_parse_args( $query_args, array(
  10.         'author__in'    =>  array()
  11.     ) );
  12.  
  13.     if( array_key_exists( 'current_logged_in_following', $instance ) ){
  14.  
  15.         if( ! $query_args['author__in'] ){
  16.             return $query_args;
  17.         }
  18.  
  19.         for ( $i = 0; $i < count( $query_args['author__in'] ) ; $i++) {
  20.             if( ! wpuf_is_following( $query_args['author__in'][$i], $current_logged_in_user ) ){
  21.                 unset( $query_args['author__in'][$i] );
  22.             }
  23.         }
  24.  
  25.         $query_args['author__in'] = array_values( $query_args['author__in'] );
  26.  
  27.         if( ! $query_args['author__in'] ){
  28.             $query_args['nothing'] = true;
  29.         }
  30.     }
  31.  
  32.     return $query_args;
  33.  
  34. }, 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement