bb_get_post_ip_link

The BuddyPress bb get post ip link function.

Description

bb_get_post_ip_link( (null) $args = null ); 

Parameters (1)

0. $args — Optional. (null) => null
The args.

Usage

  1. if ( !function_exists( 'bb_get_post_ip_link' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-template.php'; 
  3.  
  4. // The args. 
  5. $args = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bb_get_post_ip_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_post_ip_link( $args = null ) 
  2. if ( !bb_current_user_can( 'view_by_ip' ) ) { 
  3. return; 
  4.  
  5. $defaults = array( 
  6. 'post_id' => 0,  
  7. 'before' => '',  
  8. 'after' => '',  
  9. 'text' => '%s' 
  10. ); 
  11. if ( is_numeric( $args ) ) { 
  12. $args = array( 'post_id' => $args ); 
  13. $args = wp_parse_args( $args, $defaults ); 
  14.  
  15. $bb_post = bb_get_post( get_post_id( $args['post_id'] ) ); 
  16.  
  17. $uri = bb_get_uri( 'bb-admin/posts.php', array( 'poster_ip' => get_post_ip( $bb_post->post_id ) ), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN ); 
  18.  
  19. // Make sure that the last tag in $before gets a class (if it's there) 
  20. if ( preg_match( '/.*(<[^>]+>)[^<]*/', $args['before'], $_node ) ) { 
  21. if ( preg_match( '/class=(\'|")(.*)\1/U', $_node[1], $_class ) ) { 
  22. $args['before'] = str_replace( $_class[0], 'class=' . $_class[1] . 'before-post-ip-link ' . $_class[2] . $_class[1], $args['before'] ); 
  23. } else { 
  24. $args['before'] = preg_replace( '/(.*)<([a-z0-9_-]+)(\s?)([^>]*)>([^<]*)/i', '$1<$2 class="before-post-ip-link"$3$4>$5', $args['before'], 1 ); 
  25.  
  26. $link = $args['before'] . '<a class="post-ip-link" href="' . esc_attr( $uri ) . '">' . esc_html( sprintf( $args['text'], get_post_ip( $bb_post->post_id ) ) ) . '</a>' . $args['after']; 
  27. return apply_filters( 'post_ip_link', $link, $bb_post->post_id, $args );