bbp_untrash_topic

Called before untrashing a topic.

Description

bbp_untrash_topic( (int) $topic_id = 0 ); 

Parameters (1)

0. $topic_id — Optional. (int)
The topic id.

Usage

  1. if ( !function_exists( 'bbp_untrash_topic' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/topics/functions.php'; 
  3.  
  4. // The topic id. 
  5. $topic_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_untrash_topic($topic_id); 
  9.  

Defined (1)

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

/includes/topics/functions.php  
  1. function bbp_untrash_topic( $topic_id = 0 ) { 
  2. $topic_id = bbp_get_topic_id( $topic_id ); 
  3.  
  4. if ( empty( $topic_id ) || !bbp_is_topic( $topic_id ) ) 
  5. return false; 
  6.  
  7. do_action( 'bbp_untrash_topic', $topic_id ); 
  8.  
  9. // Get the replies that were not previously trashed 
  10. $pre_trashed_replies = get_post_meta( $topic_id, '_bbp_pre_trashed_replies', true ); 
  11.  
  12. // There are replies to untrash 
  13. if ( !empty( $pre_trashed_replies ) ) { 
  14.  
  15. // Maybe reverse the trashed replies array 
  16. if ( is_array( $pre_trashed_replies ) ) 
  17. $pre_trashed_replies = array_reverse( $pre_trashed_replies ); 
  18.  
  19. // Loop through replies 
  20. foreach ( (array) $pre_trashed_replies as $reply ) { 
  21. wp_untrash_post( $reply );