BuddyDev

Search

Plugin issues

  • Participant
    Level: Yogi
    Posts: 1112
    calu on #49816
    This reply has been marked as private.
  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #49823

    Hello Carsten,

    Sorry for the delayed reply. Please use the following code before the return statement of the ‘mobile_menu_logged_in_likes_button’ function:

    
    
    if ( ! $count ) {
         return;
    }
    
    

    It will hide the button if the count is empty

    Regards
    Ravi

  • Participant
    Level: Yogi
    Posts: 1112
    calu on #49824
    This reply has been marked as private.
  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #49831

    Hello Carsten,

    Use the following section of code in the function ‘mobile_menu_logged_in_likes_button’ :

    
    
    $show_count = '';
    
    	if ( $count ) {
    		$show_count = '<span class="bpuplike-like-count">' . $count . '</span>';
    	}
    
    	// Replace svg with your svg code.
    	return '<a href="' . esc_url( $like_link ) . '"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-search" viewBox="0 0 16 16">
    						<path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z"/>
    					</svg>' . $show_count . '</a>';
    
    

    Regards
    Ravi

  • Participant
    Level: Yogi
    Posts: 1112
    calu on #49833
    This reply has been marked as private.
  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #49841

    Hello Carsten,

    Thank you for the acknowledgement. Please share the SVG code you want to have in this button. I will put in the code and will share it with you.

    Regards
    Ravi

  • Participant
    Level: Yogi
    Posts: 1112
    calu on #49847
    This reply has been marked as private.
  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #49858

    Hello Carsten,

    Replace the function ‘mobile_menu_logged_in_likes_button’ with the following one:

    
    function mobile_menu_logged_in_likes_button( $loggedin_id ) {
    
    	if ( ! $loggedin_id || ! bpuplike_is_tab_available_for_user( $loggedin_id ) ) {
    		return;
    	}
    
    	$user_link  = bp_core_get_user_domain( $loggedin_id );
    	$like_link  = trailingslashit( $user_link . bpuplike_get_tab_slug() );
    	$count_type = bpuplike_get_option( 'enable_likes_counter', 'all' );
    
    	if ( 'unread' === $count_type ) {
    		$count = bpuplike_get_unread_received_likes_count_for_user( $loggedin_id );
    	} else {
    		// other people liking the user.
    		$count = bpuplike_get_received_likes_count_for_user( $loggedin_id );
    	}
    
    	$show_count = '';
    
    	if ( $count ) {
    		$show_count = '<span class="bpuplike-like-count">' . $count . '</span>';
    	}
    
    	$icon = '<svg xmlns="http://www.w3.org/2000/svg”" width="24" height="24" fill="currentColor" class="bi bi-heart" viewBox="0 0 16 16">
    <path d="m8 2.748-.717-.737C5.6.281 2.514.878 1.4 3.053c-.523 1.023-.641 2.5.314 4.385.92 1.815 2.834 3.989 6.286 6.357 3.452-2.368 5.365-4.542 6.286-6.357.955-1.886.838-3.362.314-4.385C13.486.878 10.4.28 8.717 2.01L8 2.748zM8 15C-7.333 4.868 3.279-3.04 7.824 1.143c.06.055.119.112.176.171a3.12 3.12 0 0 1 .176-.17C12.72-3.042 23.333 4.867 8 15z"/>
    </svg>';
    
    	// Replace svg with your svg code.
    	return '<a href="' . esc_url( $like_link ) . '">' . $icon . $show_count . '</a>';
    }
    
    

    Give it a try now.

    Regards
    Ravi

  • Participant
    Level: Yogi
    Posts: 1112
    calu on #49859
    This reply has been marked as private.
  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #49862

    Hello Carsten,

    I have modified the function a little bit. The likes count only reset once the user visits the ‘Received Tab’ on their profile. So, I have changed the link URL to ‘Received Tab’ if visible to the user.

    
    
    function mobile_menu_logged_in_likes_button( $loggedin_id ) {
    
    	if ( ! $loggedin_id || ! bpuplike_is_tab_available_for_user( $loggedin_id ) ) {
    		return;
    	}
    
    	$user_link  = bp_core_get_user_domain( $loggedin_id );
    	$like_link  = trailingslashit( $user_link . bpuplike_get_tab_slug() );
    
    	if ( _bplike_is_tab_visible( bpuplike_get_option( 'received_likes_tab_visibility', array() ), $loggedin_id, $loggedin_id ) ) {
    		$like_link = trailingslashit( $user_link . bpuplike_get_tab_slug() ) . 'by-others/';
    	}
    
    	$count_type = bpuplike_get_option( 'enable_likes_counter', 'all' );
    
    	if ( 'unread' === $count_type ) {
    		$count = bpuplike_get_unread_received_likes_count_for_user( $loggedin_id );
    	} else {
    		// other people liking the user.
    		$count = bpuplike_get_received_likes_count_for_user( $loggedin_id );
    	}
    
    	$show_count = '';
    
    	if ( $count ) {
    		$show_count = '<span class="bpuplike-like-count">' . $count . '</span>';
    	}
    
    	$icon = '<svg xmlns="http://www.w3.org/2000/svg”" width="24" height="24" fill="currentColor" class="bi bi-heart" viewBox="0 0 16 16">
    <path d="m8 2.748-.717-.737C5.6.281 2.514.878 1.4 3.053c-.523 1.023-.641 2.5.314 4.385.92 1.815 2.834 3.989 6.286 6.357 3.452-2.368 5.365-4.542 6.286-6.357.955-1.886.838-3.362.314-4.385C13.486.878 10.4.28 8.717 2.01L8 2.748zM8 15C-7.333 4.868 3.279-3.04 7.824 1.143c.06.055.119.112.176.171a3.12 3.12 0 0 1 .176-.17C12.72-3.042 23.333 4.867 8 15z"/>
    </svg>';
    
    	// Replace svg with your svg code.
    	return '<a href="' . esc_url( $like_link ) . '">' . $icon . $show_count . '</a>';
    }
    
    

    Please give it a try now.

    Regards
    Ravi

You must be logged in to reply to this topic.

This topic is: not resolved