bbp_get_topic_edit_link( mixed $args = '' )
Return the edit link of the topic
Description
Parameters
- $args
-
(Optional) This function supports these args: - id: Optional. Topic id - link_before: Before the link - link_after: After the link - edit_text: Edit text
Default value: ''
Return
(string) Topic edit link
Source
File: bp-forums/topics/template.php
2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 | function bbp_get_topic_edit_link( $args = '' ) { // Parse arguments against default values $r = bbp_parse_args( $args , array ( 'id' => 0, 'link_before' => '' , 'link_after' => '' , 'edit_text' => esc_html__( 'Edit' , 'buddyboss' ) ), 'get_topic_edit_link' ); $topic = bbp_get_topic( bbp_get_topic_id( (int) $r [ 'id' ] ) ); // Bypass check if user has caps if ( !current_user_can( 'edit_others_topics' ) ) { // User cannot edit or it is past the lock time if ( empty ( $topic ) || !current_user_can( 'edit_topic' , $topic ->ID ) || bbp_past_edit_lock( $topic ->post_date_gmt ) ) { return ; } } // Get uri $uri = bbp_get_topic_edit_url( $r [ 'id' ] ); // Bail if no uri if ( empty ( $uri ) ) return ; $retval = $r [ 'link_before' ] . '<a href="' . esc_url( $uri ) . '" class="bbp-topic-edit-link">' . $r [ 'edit_text' ] . '</a>' . $r [ 'link_after' ]; return apply_filters( 'bbp_get_topic_edit_link' , $retval , $r ); } |
Changelog
Version | Description |
---|---|
bbPress (r2727) | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.