Skip to:
Content
Pages
Categories
Search
Top
Bottom

bbpress control bar


  • Voice4Vision
    Participant

    @voice4vision

    Good evening everyone,
    I seriously wish I was not seeking assistance as I generally try to figure things out on my own. What I am attempting to do, I know I am out of my league…

    I want to replace the topic/reply bbpress control bar text links with icons.

    EDIT | MERGE | CLOSE | STICK (TO FRONT) | TRASH | SPAM | UNAPPROVE | REPLY | QUOTE

    Could someone please assist me? Just one link to get me started, I am sure I can figure the rest from there.

    Any and all assistance would be greatly appreciated!

    Thank you,
    Voice4Vision

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

  • Robin W
    Moderator

    @robin-w

    ok, I’m hoping you are quite good at editing files, and some php?

    do you have a child theme?

    do you know how to add stuff to a child theme functions file?


    Voice4Vision
    Participant

    @voice4vision

    I am very comfortable with editing files…css, php, and html. I am not so good at creating new enhancements. Yes, I have a child theme and I know how to add to the fuctions.php file.

    I seriously appreciate this Robin!

    Thank you,
    Voice4Vision


    Robin W
    Moderator

    @robin-w

    ok, so the first bbpress file (there will be another for replies) that we need to filter is :

    incudes/topics/templates.php

    if you open and look at the file on line 2425 you’ll find the function that does the edit topic link.

    Within this is a function that bbpress uses to let us filter parameters (called bbp_parse_args)

    it looks like this

    // Parse arguments against default values
    		$r = bbp_parse_args( $args, array(
    			'id'           => 0,
    			'link_before'  => '',
    			'link_after'   => '',
    			'edit_text'    => esc_html__( 'Edit', 'bbpress' )
    		), 'get_topic_edit_link' );

    you’ll see the word ‘Edit’ is contained in the ‘edit_text’ parameter, so it is this that we need to amend.

    we can use a filter to change what this says, so we don’t need to amend that file- so this code put in your child theme functions file

    add_filter ('bbp_before_get_topic_edit_link_parse_args' , 'my_edit_topic_filter', 10 , 1 ) ;
    
    function my_edit_topic_filter ($args) {
    	$args['edit_text'] = 'this' ;
    
    return $args ;
    
    }

    will change ‘EDIT’ to ‘THIS’

    The parameter is effectively output on line 2455 in

    $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '">' . $r['edit_text'] . '</a>' . $r['link_after'];

    so if $r[‘edit_text’] outputs the icon, then you are on the way. If the icon is an image, then using html img etc. in the function above should be good.

    let me know that you make progress with this approach – or come back.

    If you fix that one, I’ll help you work out the rest 🙂


    Voice4Vision
    Participant

    @voice4vision

    AWESOME, Working perfectly!!!

    This what I have in my functions.php file

    add_filter (‘bbp_before_get_topic_edit_link_parse_args’ , ‘my_edit_topic_filter’, 10 , 1 ) ;
    function my_edit_topic_filter ($args) {
    $args[‘edit_text’] = ‘‘ ;
    return $args ;
    }
    add_filter (‘bbp_before_get_topic_merge_link_parse_args’ , ‘my_merge_topic_filter’, 10 , 1 ) ;
    function my_merge_topic_filter ($args) {
    $args[‘merge_text’] = ‘‘ ;
    return $args ;

    Thank you so much Robin!!! I am sure I can manage the rest. I know I’ll also need to get my parameters for the replies from the replies/template.php file


    Robin W
    Moderator

    @robin-w

    great – come back if you need further help !!


    Voice4Vision
    Participant

    @voice4vision

    Quick Question…
    Will the following properly switch between an approve or unapproved topic?

    add_filter (‘bbp_before_get_topic_approve_link_parse_args’ , ‘my_approve_topic_filter’, 10 , 1 ) ;
    function my_approve_topic_filter ($args) {
    $args[‘approve_text’] = ‘‘ ;
    $args[‘unapprove_text’] = ‘‘ ;
    return $args ;
    }


    Robin W
    Moderator

    @robin-w

    should do !!


    Chuckie
    Participant

    @ajtruckle

    Interesting discussion 🙂

    But what about “icons” as per the original question instead of replacement “text”?

    Interested!


    Voice4Vision
    Participant

    @voice4vision

    I’ll post everything I have when I get home, except the icons.


    Voice4Vision
    Participant

    @voice4vision

    I would like to personally thank Robin for getting me in the right direction. Is it possible for adding this into you’re bbp style pack plugin?


    Voice4Vision
    Participant

    @voice4vision

    Ok…limitedly tested, so please test further before going live. I have also added tooltips for those using this to easily identify the purpose of each image. Be advised, I am no developer…so you’re on your own. I can not confirm if this causes any security issues. I have been having issues creating this post due to

    ERROR: Duplicate reply detected; it looks as though you’ve already said that.

    Please disregard all previous attempts and keep this latest post!

    1) Put the code at the bottom of your child theme’s functions.php file.
    2) You will need to use your own icons or images.
    3) All image titles are hard-coded, so either ensure all images are renamed or edit the snippet accordingly.

    add_filter ('bbp_before_get_topic_edit_link_parse_args' , 'my_edit_topic_filter', 10 , 1 ) ;
    function my_edit_topic_filter ($args) {
    	$args['edit_text'] = '<img src="../../wp-content/themes/dna-child/images/edit.png" style="cursor:pointer;" title="EDIT">' ;
    return $args ;
    }
    add_filter ('bbp_before_get_topic_merge_link_parse_args' , 'my_merge_topic_filter', 10 , 1 ) ;
    function my_merge_topic_filter ($args) {
    	$args['merge_text'] = '<img src="../../wp-content/themes/dna-child/images/merge.png" style="cursor:pointer;" title="MERGE">' ;
    return $args ;
    }
    add_filter ('bbp_before_get_topic_close_link_parse_args' , 'my_close_topic_filter', 10 , 1 ) ;
    function my_close_topic_filter ($args) {
    	$args['close_text'] = '<img src="../../wp-content/themes/dna-child/images/close.png" style="cursor:pointer;" title="LOCK">' ;
    	$args['open_text'] = '<img src="../../wp-content/themes/dna-child/images/open.png" style="cursor:pointer;" title="UNLOCK">' ;
    return $args ;
    }
    add_filter ('bbp_before_get_topic_stick_link_parse_args' , 'my_stick_topic_filter', 10 , 1 ) ;
    function my_stick_topic_filter ($args) {
    	$args['stick_text'] = '<img src="../../wp-content/themes/dna-child/images/stick.png" style="cursor:pointer;" title="STICKY">' ;
    	$args['unstick_text'] = '<img src="../../wp-content/themes/dna-child/images/unstick.png" style="cursor:pointer;" title="UNSTICKY">' ;
    	$args['super_text'] = '<img src="../../wp-content/themes/dna-child/images/super.png" style="cursor:pointer;" title="GLOBAL STICKY">' ;
    return $args ;
    }
    add_filter ('bbp_before_get_topic_trash_link_parse_args' , 'my_trash_topic_filter', 10 , 1 ) ;
    function my_trash_topic_filter ($args) {
    	$args['trash_text'] = '<img src="../../wp-content/themes/dna-child/images/trash.png" style="cursor:pointer;" title="TRASH">' ;
    	$args['restore_text'] = '<img src="../../wp-content/themes/dna-child/images/restore.png" style="cursor:pointer;" title="RESTORE">' ;
    	$args['Delete_text'] = '<img src="../../wp-content/themes/dna-child/images/delete.png" style="cursor:pointer;" title="DELETE">' ;
    return $args ;
    }
    add_filter ('bbp_before_get_topic_spam_link_parse_args' , 'my_spam_topic_filter', 10 , 1 ) ;
    function my_spam_topic_filter ($args) {
    	$args['spam_text'] = '<img src="../../wp-content/themes/dna-child/images/spam.png" style="cursor:pointer;" title="SPAM">' ;
    	$args['unspam_text'] = '<img src="../../wp-content/themes/dna-child/images/unspam.png" style="cursor:pointer;" title="UNSPAM">' ;
    return $args ;
    }
    add_filter ('bbp_before_get_topic_approve_link_parse_args' , 'my_approve_topic_filter', 10 , 1 ) ;
    function my_approve_topic_filter ($args) {
    	$args['approve_text'] = '<img src="../../wp-content/themes/dna-child/images/approve.png" style="cursor:pointer;" title="APPROVE">' ;
    	$args['unapprove_text'] = '<img src="../../wp-content/themes/dna-child/images/unapprove.png" style="cursor:pointer;" title="DISAPPROVE">' ;
    return $args ;	
    }
    add_filter ('bbp_before_get_topic_reply_link_parse_args' , 'my_reply_topic_filter', 10 , 1 ) ;
    function my_reply_topic_filter ($args) {
    	$args['reply_text'] = '<img src="../../wp-content/themes/dna-child/images/reply.png" style="cursor:pointer;" title="REPLY">' ;
    return $args ;	
    }
    add_filter ('bbp_before_get_topic_split_link_parse_args' , 'my_split_topic_filter', 10 , 1 ) ;
    function my_split_topic_filter ($args) {
    	$args['split_text'] = '<img src="../../wp-content/themes/dna-child/images/split.png" style="cursor:pointer;" title="SPLIT">' ;
    return $args ;	
    }
    add_filter ('bbp_before_get_reply_edit_link_parse_args' , 'my_edit_reply_filter', 10 , 1 ) ;
    function my_edit_reply_filter ($args) {
    	$args['edit_text'] = '<img src="../../wp-content/themes/dna-child/images/edit.png" style="cursor:pointer;" title="EDIT">' ;
    return $args ;
    }
    add_filter ('bbp_before_get_reply_move_link_parse_args' , 'my_move_reply_filter', 10 , 1 ) ;
    function my_move_reply_filter ($args) {
    	$args['split_text'] = '<img src="../../wp-content/themes/dna-child/images/move.png" style="cursor:pointer;" title="MOVE">' ;
    return $args ;
    }
    add_filter ('bbp_before_get_reply_close_link_parse_args' , 'my_close_reply_filter', 10 , 1 ) ;
    function my_close_reply_filter ($args) {
    	$args['close_text'] = '<img src="../../wp-content/themes/dna-child/images/close.png" style="cursor:pointer;" title="LOCK">' ;
    	$args['open_text'] = '<img src="../../wp-content/themes/dna-child/images/open.png" style="cursor:pointer;" title="UNLOCK">' ;
    return $args ;
    }
    add_filter ('bbp_before_get_reply_trash_link_parse_args' , 'my_trash_reply_filter', 10 , 1 ) ;
    function my_trash_reply_filter ($args) {
    	$args['trash_text'] = '<img src="../../wp-content/themes/dna-child/images/trash.png" style="cursor:pointer;" title="TRASH">' ;
    	$args['restore_text'] = '<img src="../../wp-content/themes/dna-child/images/restore.png" style="cursor:pointer;" title="RESTORE">' ;
    	$args['delete_text'] = '<img src="../../wp-content/themes/dna-child/images/delete.png" style="cursor:pointer;" title="DELETE">' ;
    return $args ;
    }
    add_filter ('bbp_before_get_reply_spam_link_parse_args' , 'my_spam_reply_filter', 10 , 1 ) ;
    function my_spam_reply_filter ($args) {
    	$args['spam_text'] = '<img src="../../wp-content/themes/dna-child/images/spam.png" style="cursor:pointer;" title="SPAM">' ;
    	$args['unspam_text'] = '<img src="../../wp-content/themes/dna-child/images/unspam.png" style="cursor:pointer;" title="UNSPAM">' ;
    return $args ;
    }
    add_filter ('bbp_before_get_reply_approve_link_parse_args' , 'my_approve_reply_filter', 10 , 1 ) ;
    function my_approve_reply_filter ($args) {
    	$args['approve_text'] = '<img src="../../wp-content/themes/dna-child/images/approve.png" style="cursor:pointer;" title="APPROVE">' ;
    	$args['unapprove_text'] = '<img src="../../wp-content/themes/dna-child/images/unapprove.png" style="cursor:pointer;" title="DISAPPROVE">' ;
    return $args ;	
    }
    add_filter ('bbp_before_get_reply_to_link_parse_args' , 'my_reply_to_filter', 10 , 1 ) ;
    function my_reply_to_filter ($args) {
    	$args['reply_text'] = '<img src="../../wp-content/themes/dna-child/images/reply.png" style="cursor:pointer;" title="REPLY">' ;
    return $args ;	
    }

    Robin W
    Moderator

    @robin-w

    great – thanks for posting the final solution 🙂

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