bb_get_new_topic_link

Bb_get_new_topic_link() - Get the link to the form for a new topic.

Description

(string) bb_get_new_topic_link( (null) $args = null ); 

Returns (string)

The link to the new topic form

Parameters (1)

0. $args — Optional. (null) => null
The arguments for this function.

Usage

  1. if ( !function_exists( 'bb_get_new_topic_link' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-template.php'; 
  3.  
  4. // The arguments for this function. 
  5. $args = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bb_get_new_topic_link($args); 
  9.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/functions.bb-template.php  
  1. function bb_get_new_topic_link( $args = null ) { 
  2. $defaults = array( 'text' => __('Add New »'), 'forum' => 0, 'tag' => '' ); 
  3. if ( $args && is_string($args) && false === strpos($args, '=') ) 
  4. $args = array( 'text' => $args ); 
  5.  
  6. $args = wp_parse_args( $args, $defaults ); 
  7. extract( $args, EXTR_SKIP ); 
  8.  
  9. if ( $forum && $forum = bb_get_forum( $forum ) ) 
  10. $url = get_forum_link( $forum->forum_id ) . '#postform'; 
  11. elseif ( $tag && $tag = bb_get_tag( $tag ) ) 
  12. $url = bb_get_tag_link( $tag->tag ) . '#postform'; 
  13. elseif ( bb_is_forum() ) { 
  14. global $forum; 
  15. $url = get_forum_link( $forum->forum_id ) . '#postform'; 
  16. } elseif ( bb_is_tag() ) { 
  17. global $tag; 
  18. $url = bb_get_tag_link( $tag ) . '#postform'; 
  19. } elseif ( bb_is_topic() ) 
  20. $url = get_forum_link() . '#postform'; 
  21. elseif ( bb_is_front() ) 
  22. $url = bb_get_uri(null, array('new' => 1)); 
  23.  
  24. if ( !bb_is_user_logged_in() && bb_is_login_required() ) 
  25. $url = bb_get_uri('bb-login.php', array('redirect_to' => $url), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_USER_FORMS); 
  26. elseif ( bb_is_forum() || bb_is_topic() ) { 
  27. if ( !bb_current_user_can( 'write_topic', get_forum_id() ) ) 
  28. return; 
  29. } else { 
  30. if ( !bb_current_user_can( 'write_topics' ) ) 
  31. return; 
  32.  
  33. if ( $url = esc_attr( apply_filters( 'new_topic_url', $url, $args ) ) ) 
  34. return '<a href="' . $url . '" class="new-topic">' . $text . '</a>' . "\n";