bbp_untrash_forum_topics

Trash all topics inside a forum.

Description

bbp_untrash_forum_topics( (int) $forum_id = 0 ); 

Parameters (1)

0. $forum_id — Optional. (int)
The forum id.

Usage

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

Defined (1)

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

/includes/forums/functions.php  
  1. function bbp_untrash_forum_topics( $forum_id = 0 ) { 
  2.  
  3. // Validate forum ID 
  4. $forum_id = bbp_get_forum_id( $forum_id ); 
  5.  
  6. if ( empty( $forum_id ) ) 
  7. return; 
  8.  
  9. // Get the topics that were not previously trashed 
  10. $pre_trashed_topics = get_post_meta( $forum_id, '_bbp_pre_trashed_topics', true ); 
  11.  
  12. // There are topics to untrash 
  13. if ( !empty( $pre_trashed_topics ) ) { 
  14.  
  15. // Maybe reverse the trashed topics array 
  16. if ( is_array( $pre_trashed_topics ) ) 
  17. $pre_trashed_topics = array_reverse( $pre_trashed_topics ); 
  18.  
  19. // Loop through topics 
  20. foreach ( (array) $pre_trashed_topics as $topic ) { 
  21. wp_untrash_post( $topic );