Skip to:
Content
Pages
Categories
Search
Top
Bottom

Replace Default Comment Button on Activity Feed with Font Awesome Icon


  • burstboard
    Participant

    @burstboard

    Hi,

    I want to replace the default comment button (.bp-primary-action) on the activity feed with a font awesome icon. I was able to find a function for the delete button (.bp-secondary-action) that is working just fine. However, my attempts to rework this function to apply to the comment button has not worked. I’m hoping someone could take a look and offer some ideas for a solution.

    The original WORKING function which for the delete button replacement can be found below with it’s source:

    function sc_swap_delete_text( $link ) {
    	$trash = '<i class="icon-trash icon-large"></i>';
    	
    	$link = str_replace("Delete", $trash, $link);
    	
    	return $link;
    }
    add_filter( 'bp_get_activity_delete_link', 'sc_swap_delete_text', 1, 1 );

    source: https://buddypress.org/support/topic/font-awesome-breaks-ajax-on-delete-link/

    Below is the NON-FUNCTIONING example of the function I’ve been attempting. I’m looking for some ideas on a fix here:

    function sc_swap_comment_text( $link ) {
    	$fareply = '<i class="icon-fa fa-reply"></i>';
    	
    	$link = str_replace("Comment ", $fareply, $link);
    	
    	return $link;
    }
    add_filter( 'bp_get_activity_comment_link', 'sc_swap_comment_text', 1, 1 );

    Regards,

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

  • burstboard
    Participant

    @burstboard


    astrologeeks
    Participant

    @astrologeeks

    You will need to add something like this to your bp-custom.php file. If you haven’t already, create this file and place it in the wp-content/plugins/ folder. I added “aside” to the name to tell buddypress this is a custom function and not re-declare an already existing function.

    function bp_get_activity_delete_link_aside() { 
     
        $url = bp_get_activity_delete_url(); 
        $class = 'delete-activity'; 
     
        // Determine if we're on a single activity page, and customize accordingly. 
        if ( bp_is_activity_component() && is_numeric( bp_current_action() ) ) { 
            $class = 'delete-activity-single'; 
        } 
     
        $link = '<a href="' . esc_url( $url ) . '" class="item-button bp-secondary-action ' . $class . ' confirm btn white btn-xs" rel="nofollow" style="padding: .2195rem .5rem;font-size: 0.8rem;">' . __( '<i class="fa fa-fw fa-trash text-muted"></i>', 'buddypress' ) . '</a>'; 
     
        /** 
         * Filters the activity delete link. 
         * 
         * @since 1.1.0 
         * 
         * @param string $link Activity delete HTML link. 
         */ 
        return apply_filters( 'bp_get_activity_delete_link', $link ); 
    } 
    function bp_activity_delete_link_aside() { 
        echo bp_get_activity_delete_link_aside(); 
    } 

    astrologeeks
    Participant

    @astrologeeks

    Then in your entry.php file in your custom buddypress theme folder (located in wp-content/themes/your-theme/buddypress/activity/), replace the delete link code from this

    <?php if ( bp_activity_user_can_delete() ) bp_activity_delete_link(); ?>

    to this

    <?php if ( bp_activity_user_can_delete() ) bp_activity_delete_link_aside(); ?>

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