Skip to:
Content

bbPress.org


Ignore:
Timestamp:
11/26/2012 05:43:43 PM (9 years ago)
Author:
johnjamesjacoby
Message:

Deleting:

  • When deleting a forum or topic, make sure all child content is deleted also.
  • Also add some inline doc, and unset query variables, and clean up messy inline comparisons.
  • Props MZAWeb.
  • Fixes #2059.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/forums/functions.php

    r4508 r4524  
    19441944        return;
    19451945
    1946     // Forum is being permanently deleted, so its topics gotta go too
    1947     if ( $topics = new WP_Query( array(
     1946    // Forum is being permanently deleted, so its content has go too
     1947    // Note that we get all post statuses here
     1948    $topics = new WP_Query( array(
    19481949        'suppress_filters' => true,
    19491950        'post_type'        => bbp_get_topic_post_type(),
    19501951        'post_parent'      => $forum_id,
    1951         'post_status'      => 'any',
     1952        'post_status'      => array_keys( get_post_stati() ),
    19521953        'posts_per_page'   => -1,
    19531954        'nopaging'         => true,
    19541955        'fields'           => 'id=>parent'
    1955     ) ) ) {
     1956    ) );
     1957
     1958    // Loop through and delete child topics. Topic replies will get deleted by
     1959    // the bbp_delete_topic() action.
     1960    if ( !empty( $topics->posts ) ) {
    19561961        foreach ( $topics->posts as $topic ) {
    19571962            wp_delete_post( $topic->ID, true );
     
    19611966        wp_reset_postdata();
    19621967    }
     1968
     1969    // Cleanup
     1970    unset( $topics );
    19631971}
    19641972
Note: See TracChangeset for help on using the changeset viewer.