Changeset 3505 for branches/plugin/bbp-includes/bbp-topic-functions.php
- Timestamp:
- 09/10/2011 10:27:19 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-topic-functions.php
r3501 r3505 32 32 $default_topic = array( 33 33 'post_parent' => 0, // forum ID 34 'post_status' => 'publish',34 'post_status' => bbp_get_public_status_id(), 35 35 'post_type' => bbp_get_topic_post_type(), 36 36 'post_author' => 0, … … 124 124 return; 125 125 126 global $bbp;127 128 126 // Nonce check 129 127 check_admin_referer( 'bbp-new-topic' ); … … 268 266 'post_parent' => $forum_id, 269 267 'tax_input' => $terms, 270 'post_status' => 'publish',268 'post_status' => bbp_get_public_status_id(), 271 269 'post_type' => bbp_get_topic_post_type() 272 270 ); … … 310 308 // If the forum is trash, or the topic_status is switched to 311 309 // trash, trash it properly 312 if ( ( get_post_field( 'post_status', $forum_id ) == $bbp->trash_status_id ) || ( $topic_data['post_status'] == $bbp->trash_status_id) ) {310 if ( ( get_post_field( 'post_status', $forum_id ) == bbp_get_trash_status_id() ) || ( $topic_data['post_status'] == bbp_get_trash_status_id() ) ) { 313 311 314 312 // Trash the reply … … 322 320 323 321 // If reply or topic are spam, officially spam this reply 324 if ( $topic_data['post_status'] == $bbp->spam_status_id) {325 add_post_meta( $topic_id, '_bbp_spam_meta_status', 'publish');322 if ( $topic_data['post_status'] == bbp_get_spam_status_id() ) { 323 add_post_meta( $topic_id, '_bbp_spam_meta_status', bbp_get_public_status_id() ); 326 324 327 325 // Force view=all … … 817 815 if ( true == $refresh ) { 818 816 $forum_id = $topic_id = $reply_id = $active_id = $last_active_time = 0; 819 $topic_status = 'publish';817 $topic_status = bbp_get_public_status_id(); 820 818 } 821 819 … … 1279 1277 return; 1280 1278 1281 global $wpdb , $bbp;1279 global $wpdb; 1282 1280 1283 1281 // Prevent debug notices … … 2122 2120 */ 2123 2121 function bbp_update_topic_reply_count_hidden( $topic_id = 0, $reply_count = 0 ) { 2124 global $wpdb , $bbp;2122 global $wpdb; 2125 2123 2126 2124 // If it's a reply, then get the parent (topic id) … … 2132 2130 // Get replies of topic 2133 2131 if ( empty( $reply_count ) ) 2134 $reply_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( '" . join( '\',\'', array( $bbp->trash_status_id, $bbp->spam_status_id) ) . "') AND post_type = '%s';", $topic_id, bbp_get_reply_post_type() ) );2132 $reply_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( '" . join( '\',\'', array( bbp_get_trash_status_id(), bbp_get_spam_status_id() ) ) . "') AND post_type = '%s';", $topic_id, bbp_get_reply_post_type() ) ); 2135 2133 2136 2134 update_post_meta( $topic_id, '_bbp_reply_count_hidden', (int) $reply_count ); … … 2173 2171 2174 2172 // Update only if published 2175 if ( 'publish'== get_post_status( $active_id ) )2173 if ( bbp_get_public_status_id() == get_post_status( $active_id ) ) 2176 2174 update_post_meta( $topic_id, '_bbp_last_active_id', (int) $active_id ); 2177 2175 … … 2285 2283 2286 2284 // Query the DB to get voices in this topic 2287 $voices = $wpdb->get_col( $wpdb->prepare( "SELECT COUNT( DISTINCT post_author ) FROM {$wpdb->posts} WHERE ( post_parent = %d AND post_status = ' publish' AND post_type = '%s' ) OR ( ID = %d AND post_type = '%s' );", $topic_id, bbp_get_reply_post_type(), $topic_id, bbp_get_topic_post_type() ) );2285 $voices = $wpdb->get_col( $wpdb->prepare( "SELECT COUNT( DISTINCT post_author ) FROM {$wpdb->posts} WHERE ( post_parent = %d AND post_status = '%s' AND post_type = '%s' ) OR ( ID = %d AND post_type = '%s' );", $topic_id, bbp_get_public_status_id(), bbp_get_reply_post_type(), $topic_id, bbp_get_topic_post_type() ) ); 2288 2286 2289 2287 // If there's an error, make sure we at least have 1 voice … … 2326 2324 return; 2327 2325 2328 $anonymous_replies = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( ID ) FROM {$wpdb->posts} WHERE ( post_parent = %d AND post_status = ' publish' AND post_type = '%s' AND post_author = 0 ) OR ( ID = %d AND post_type = '%s' AND post_author = 0 );", $topic_id, bbp_get_reply_post_type(), $topic_id, bbp_get_topic_post_type() ) );2326 $anonymous_replies = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( ID ) FROM {$wpdb->posts} WHERE ( post_parent = %d AND post_status = '%s' AND post_type = '%s' AND post_author = 0 ) OR ( ID = %d AND post_type = '%s' AND post_author = 0 );", $topic_id, bbp_get_public_status_id(), bbp_get_reply_post_type(), $topic_id, bbp_get_topic_post_type() ) ); 2329 2327 2330 2328 update_post_meta( $topic_id, '_bbp_anonymous_reply_count', (int) $anonymous_replies ); … … 2391 2389 */ 2392 2390 function bbp_close_topic( $topic_id = 0 ) { 2393 global $bbp;2394 2391 2395 2392 // Get topic … … 2398 2395 2399 2396 // Bail if already closed 2400 if ( $topic['post_status'] == $bbp->closed_status_id)2397 if ( bbp_get_closed_status_id == $topic['post_status'] ) 2401 2398 return false; 2402 2399 … … 2408 2405 2409 2406 // Set closed status 2410 $topic['post_status'] = $bbp->closed_status_id;2407 $topic['post_status'] = bbp_get_closed_status_id(); 2411 2408 2412 2409 // No revisions … … 2438 2435 */ 2439 2436 function bbp_open_topic( $topic_id = 0 ) { 2440 global $bbp;2441 2437 2442 2438 // Get topic … … 2445 2441 2446 2442 // Bail if already open 2447 if ( $topic['post_status'] != $bbp->closed_status_id)2443 if ( bbp_get_closed_status_id() != $topic['post_status']) 2448 2444 return false; 2449 2445 … … 2487 2483 */ 2488 2484 function bbp_spam_topic( $topic_id = 0 ) { 2489 global $bbp;2490 2485 2491 2486 // Get the topic … … 2494 2489 2495 2490 // Bail if topic is spam 2496 if ( $topic['post_status'] == $bbp->spam_status_id)2491 if ( bbp_get_spam_status_id() == $topic['post_status'] ) 2497 2492 return false; 2498 2493 … … 2526 2521 2527 2522 // Set post status to spam 2528 $topic['post_status'] = $bbp->spam_status_id;2523 $topic['post_status'] = bbp_get_spam_status_id(); 2529 2524 2530 2525 // No revisions … … 2556 2551 */ 2557 2552 function bbp_unspam_topic( $topic_id = 0 ) { 2558 global $bbp;2559 2553 2560 2554 // Get the topic … … 2563 2557 2564 2558 // Bail if already not spam 2565 if ( $topic['post_status'] != $bbp->spam_status_id)2559 if ( bbp_get_spam_status_id() != $topic['post_status'] ) 2566 2560 return false; 2567 2561 … … 2713 2707 */ 2714 2708 function bbp_delete_topic( $topic_id = 0 ) { 2715 global $bbp;2716 2709 2717 2710 // Validate topic ID … … 2724 2717 2725 2718 // Valid topic/reply statuses 2726 $post_stati = join( ',', array( 'publish', $bbp->spam_status_id, 'trash' ) );2719 $post_stati = join( ',', array( bbp_get_public_status_id(), bbp_get_spam_status_id(), 'trash' ) ); 2727 2720 2728 2721 // Topic is being permanently deleted, so its replies gotta go too … … 2774 2767 if ( bbp_has_replies( array( 2775 2768 'post_type' => bbp_get_reply_post_type(), 2776 'post_status' => 'publish',2769 'post_status' => bbp_get_public_status_id(), 2777 2770 'posts_per_page' => -1, 2778 2771 'meta_query' => array( array(
Note: See TracChangeset
for help on using the changeset viewer.