bbp_get_topic_edit_url

Return URL to the topic edit page.

Description

(string) bbp_get_topic_edit_url( (int) $topic_id = 0 ); 

Returns (string)

Topic edit url

Parameters (1)

0. $topic_id — Optional. (int)
Topic id

Usage

  1. if ( !function_exists( 'bbp_get_topic_edit_url' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/topics/template.php'; 
  3.  
  4. // Optional. Topic id 
  5. $topic_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_get_topic_edit_url($topic_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/topics/template.php  
  1. function bbp_get_topic_edit_url( $topic_id = 0 ) { 
  2. global $wp_rewrite; 
  3.  
  4. $bbp =bbpress); 
  5.  
  6. $topic = bbp_get_topic( bbp_get_topic_id( $topic_id ) ); 
  7. if ( empty( $topic ) ) 
  8. return; 
  9.  
  10. // Remove view=all link from edit 
  11. $topic_link = bbp_remove_view_all( bbp_get_topic_permalink( $topic_id ) ); 
  12.  
  13. // Pretty permalinks 
  14. if ( $wp_rewrite->using_permalinks() ) { 
  15. $url = trailingslashit( $topic_link ) . $bbp->edit_id; 
  16. $url = trailingslashit( $url ); 
  17.  
  18. // Unpretty permalinks 
  19. } else { 
  20. $url = add_query_arg( array( bbp_get_topic_post_type() => $topic->post_name, $bbp->edit_id => '1' ), $topic_link ); 
  21.  
  22. // Maybe add view=all 
  23. $url = bbp_add_view_all( $url ); 
  24.  
  25. return apply_filters( 'bbp_get_topic_edit_url', $url, $topic_id );