Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to edit the ‘reply’ link anchor in post headers?

  • @kodacollider

    Participant

    Hello. I’m looking for a way to edit the anchor for the reply links located in div.bbp-reply-header. The ones where it says ‘EDIT | MOVE | SPLIT | TRASH | SPAM | REPLY’.

    They link to #new-post, but I’ve embedded this form in a collapsible container, so I need the links to first trigger the container to expand in order for them to be able to actually go to #new-post.

    I imagine I will have to add a function to do this, can someone help me out please?

    Thanks in advance!

Viewing 3 replies - 1 through 3 (of 3 total)
  • @casiepa

    Moderator

    Hi,
    You will have to check the bbp_topic_admin_links, something like:

    add_filter ('bbp_topic_admin_links', 'change_topic_admin_links' );
    function change_topic_admin_links ($r) {
      // whatever is needed here
      return $r;
    }

    Pascal.

    @kodacollider

    Participant

    Thank you. I’m having a little bit of trouble.

    I found the original function I need to edit in bbpress/includes/topics/template.php:

    function bbp_get_topic_reply_link( $args = array() ) {
    
    		// Parse arguments against default values
    		$r = bbp_parse_args( $args, array(
    			'id'           => 0,
    			'link_before'  => '',
    			'link_after'   => '',
    			'reply_text'   => esc_html__( 'Reply', 'bbpress' ),
    		), 'get_topic_reply_link' );
    
    		// Get the reply to use it's ID and post_parent
    		$topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) );
    
    		// Bail if no reply or user cannot reply
    		if ( empty( $topic ) || ! bbp_current_user_can_access_create_reply_form() )
    			return;
    
    		$uri = '#new-post';
    
    		// Add $uri to the array, to be passed through the filter
    		$r['uri'] = $uri;
    		$retval   = $r['link_before'] . '<a href="' . esc_url( $r['uri'] ) . '" class="bbp-topic-reply-link">' . $r['reply_text'] . '</a>' . $r['link_after'];
    
    		return apply_filters( 'bbp_get_topic_reply_link', $retval, $r, $args );
    	}

    The only line I need to modify is:

    $retval = $r['link_before'] . '<a href="' . esc_url( $r['uri'] ) . '" class="bbp-topic-reply-link">' . $r['reply_text'] . '</a>' . $r['link_after'];

    Is there an easier way to phrase my new function to modify just this variable?

    @casiepa

    Moderator

    Hi,
    For sure NEVER edit files under bbPress, otherwise you loose it when there is an upgrade.
    If you could give me an example of what you get now and what you would need to get, I could maybe help you further. Or a link to your site and then what would need to be changed.
    Thanks, Pascal.

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