Skip to:
Content
Pages
Categories
Search
Top
Bottom

Remove friendship-buttons title-tooltip


  • dolf h
    Participant

    @dolf-h

    I have a problem by managing groups in front .I ‘d like to remove the title tooltips that show up by hovering the friendship-buttons (add friend and cancel friendship request). I have this code in the header.php of my child-theme:

    <script type="text/javascript">
        window.onload = function(){
    var titled = document.querySelectorAll('[title]');
    var numTitled = titled.length;
    var i = 0;
    for (i=0; i<numTitled; i++){
        titled[i].removeAttribute('title');
    }
        };
    </script>
    

    Works fine, but when I add a friend, the button changes in “cancel friendship request” shows the title again by hovering.

    In the forum I found this code:

    add_filter( ‘bp_core_avatar_title’, ‘__return_false’ );

    Perhaps I can use this after changing it, but into what?

    Would be nice if someone has a solution. Thanks in advance!

Viewing 4 replies - 1 through 4 (of 4 total)

  • danbp
    Moderator

    @danbp

    Hi,

    you could use the dedicated filter for buttons bp_get_add_friend_button to do this. In addition you need to add an ajax refresh.

    This will only work on the group members template, but you have to refresh the page (sorry, i’m not good in js). Add it to bp-custom.php.

    function tweak_button ( $button ) { 
    
    	if ( class_exists( 'BP_Group_Extension' ) ) : 
    	
    	$group = groups_get_current_group();
    	
    	if( !empty( $group ) )	
    
    	switch ( $button['id'] ) {
    		case 'pending' :
    			$button['link_title'] = '';
    		break;
    
    		case 'is_friend' :
    			$button['link_title'] = '';
    		break;
    
    	default:
    		$button['link_title'] = '';
    	}
    
    	return $button;
    	endif;
    }
    add_filter( 'bp_get_add_friend_button', 'tweak_button', 1, 1 );

    dolf h
    Participant

    @dolf-h

    Thanks Danbp. My skills concerning JS are copy-paste! Maybe someone else can help with an Ajax refresh solution?


    @mercime
    Keymaster

    @mercime

    Just to note that the “add friend and cancel friendship” tooltips, among other tooltips have been removed in BP 2.7 trunk (see #7090).


    dolf h
    Participant

    @dolf-h

    Thank you @mercime. My solution mentioned above is working website-wide (and I like that):

    <script type="text/javascript">
        window.onload = function(){
    var titled = document.querySelectorAll('[title]');
    var numTitled = titled.length;
    var i = 0;
    for (i=0; i<numTitled; i++){
        titled[i].removeAttribute('title');
    }
        };
    </script>

    I think I only need an Ajax refresh. Perhaps this plugin is suitable: https://wordpress.org/plugins/ajaxize/
    I ‘ll give it a try.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar