bb_get_post_undelete_link

The BuddyPress bb get post undelete link function.

Description

bb_get_post_undelete_link( (null) $args = null ); 

Parameters (1)

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

Usage

  1. if ( !function_exists( 'bb_get_post_undelete_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_undelete_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_undelete_link( $args = null ) 
  2. $defaults = array( 
  3. 'post_id' => 0,  
  4. 'before' => '',  
  5. 'after' => '',  
  6. 'text' => __( 'Undelete' ),  
  7. 'redirect' => true 
  8. ); 
  9. if ( is_numeric( $args ) || is_object( $args ) ) { 
  10. $args = array( 'post_id' => $args ); 
  11.  
  12. $args = wp_parse_args( $args, $defaults ); 
  13. extract( $args, EXTR_SKIP ); 
  14.  
  15. $bb_post = bb_get_post( get_post_id( $post_id ) ); 
  16.  
  17. if ( !bb_current_user_can( 'delete_post', $bb_post->post_id ) ) { 
  18. return; 
  19.  
  20. if ( true === $redirect ) { 
  21. $redirect = $_SERVER['REQUEST_URI']; 
  22.  
  23. $uri = bb_get_uri('bb-admin/delete-post.php', array( 
  24. 'id' => $bb_post->post_id,  
  25. 'status' => 0,  
  26. 'view' => 'all',  
  27. '_wp_http_referer' => $redirect ? rawurlencode( $redirect ) : false 
  28. $uri = esc_url( bb_nonce_url( $uri, 'delete-post_' . $bb_post->post_id ) ); 
  29.  
  30. $ajax_class = 'dim:thread:post-' . $bb_post->post_id . ':deleted:FF3333:FFFF33:action=delete-post&status=0'; 
  31.  
  32. $text = esc_html( $text ); 
  33.  
  34. // Make sure that the last tag in $before gets a class (if it's there) 
  35. if ( preg_match( '/.*(<[^>]+>)[^<]*/', $before, $_node ) ) { 
  36. if ( preg_match( '/class=(\'|")(.*)\1/U', $_node[1], $_class ) ) { 
  37. $before = str_replace( $_class[0], 'class=' . $_class[1] . 'before-post-undelete-link ' . $_class[2] . $_class[1], $before ); 
  38. } else { 
  39. $before = preg_replace( '/(.*)<([a-z0-9_-]+)(\s?)([^>]*)>([^<]*)/i', '$1<$2 class="before-post-undelete-link"$3$4>$5', $before, 1 ); 
  40.  
  41. $r = $before . '<a href="' . $uri . '" class="' . $ajax_class . ' post-undelete-link">' . $text . '</a>' . $after; 
  42. $r = apply_filters( 'post_undelete_link', $r, $bb_post->post_status, $bb_post->post_id, $args ); 
  43. return $r;