bb_get_post_edit_link

The BuddyPress bb get post edit link function.

Description

bb_get_post_edit_link( (null) $args = null ); 

Parameters (1)

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

Usage

  1. if ( !function_exists( 'bb_get_post_edit_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_edit_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_edit_link( $args = null ) 
  2. $defaults = array( 
  3. 'post_id' => 0,  
  4. 'before' => '',  
  5. 'after' => '',  
  6. 'text' => __( 'Edit' ) 
  7. ); 
  8. if ( is_numeric( $args ) ) { 
  9. $args = array( 'post_id' => $args ); 
  10. $args = wp_parse_args( $args, $defaults ); 
  11.  
  12. $bb_post = bb_get_post( get_post_id( $args['post_id'] ) ); 
  13.  
  14. if ( bb_current_user_can( 'edit_post', $bb_post->post_id ) ) { 
  15. $uri = bb_get_uri( 'edit.php', array( 'id' => $bb_post->post_id ) ); 
  16.  
  17. // Make sure that the last tag in $before gets a class (if it's there) 
  18. if ( preg_match( '/.*(<[^>]+>)[^<]*/', $args['before'], $_node ) ) { 
  19. if ( preg_match( '/class=(\'|")(.*)\1/U', $_node[1], $_class ) ) { 
  20. $args['before'] = str_replace( $_class[0], 'class=' . $_class[1] . 'before-post-edit-link ' . $_class[2] . $_class[1], $args['before'] ); 
  21. } else { 
  22. $args['before'] = preg_replace( '/(.*)<([a-z0-9_-]+)(\s?)([^>]*)>([^<]*)/i', '$1<$2 class="before-post-edit-link"$3$4>$5', $args['before'], 1 ); 
  23.  
  24. $r = $args['before'] . '<a class="post-edit-link" href="' . esc_attr( apply_filters( 'post_edit_uri', $uri, $bb_post->post_id, $args ) ) . '">' . esc_html( $args['text'] ) . '</a>' . $args['after']; 
  25. return apply_filters( 'bb_get_post_edit_link', $r, $bb_post->post_id, $args );