bb_ksd_post_delete_link

The BuddyPress bb ksd post delete link function.

Description

bb_ksd_post_delete_link( $parts, $args ); 

Parameters (2)

0. $parts
The parts.
1. $args
The args.

Usage

  1. if ( !function_exists( 'bb_ksd_post_delete_link' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-plugins/akismet.php'; 
  3.  
  4. // The parts. 
  5. $parts = null; 
  6.  
  7. // The args. 
  8. $args = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bb_ksd_post_delete_link($parts, $args); 
  12.  

Defined (1)

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

/bp-forums/bbpress/bb-plugins/akismet.php  
  1. function bb_ksd_post_delete_link( $parts, $args ) 
  2. if ( !bb_current_user_can( 'moderate' ) ) { 
  3. return $parts; 
  4. $bb_post = bb_get_post( get_post_id( $args['post_id'] ) ); 
  5.  
  6. if ( 2 == $bb_post->post_status ) { 
  7. $query = array( 
  8. 'id' => $bb_post->post_id,  
  9. 'status' => 0,  
  10. 'view' => 'all' 
  11. ); 
  12. $display = __('Not Spam'); 
  13. } else { 
  14. $query = array( 
  15. 'id' => $bb_post->post_id,  
  16. 'status' => 2 
  17. ); 
  18. $display = __('Spam'); 
  19. $uri = bb_get_uri( 'bb-admin/delete-post.php', $query, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN ); 
  20. $uri = esc_url( bb_nonce_url( $uri, 'delete-post_' . $bb_post->post_id ) ); 
  21. if ( !is_array( $parts ) ) { 
  22. $parts = array(); 
  23. $before = ''; 
  24. $after = ''; 
  25. } else { 
  26. $before = isset( $args['last_each']['before'] ) ? $args['last_each']['before'] : ''; 
  27. $after = isset( $args['last_each']['after'] ) ? $args['last_each']['after'] : ''; 
  28.  
  29. // Make sure that the last tag in $before gets a class (if it's there) 
  30. if ( preg_match( '/.*(<[^>]+>)[^<]*/', $before, $_node ) ) { 
  31. if ( preg_match( '/class=(\'|")(.*)\1/U', $_node[1], $_class ) ) { 
  32. $before = str_replace( $_class[0], 'class=' . $_class[1] . 'before-post-spam-link ' . $_class[2] . $_class[1], $before ); 
  33. } else { 
  34. $before = preg_replace( '/(.*)<([a-z0-9_-]+)(\s?)([^>]*)>([^<]*)/i', '$1<$2 class="before-post-spam-link"$3$4>$5', $before, 1 ); 
  35.  
  36. $parts[] = $before . '<a class="post-spam-link" href="' . $uri . '" >' . $display . '</a>' . $after; 
  37. return $parts;