Changeset 3505 for branches/plugin/bbp-includes/bbp-forum-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-forum-functions.php
r3501 r3505 32 32 $default_forum = 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_forum_post_type(), 36 36 'post_author' => 0, … … 208 208 209 209 // Only run queries if visibility is changing 210 if ( 'publish'!= $current_visibility ) {210 if ( bbp_get_public_status_id() != $current_visibility ) { 211 211 212 212 // Remove from _bbp_private_forums site option 213 if ( 'private'== $current_visibility ) {213 if ( bbp_get_private_status_id() == $current_visibility ) { 214 214 215 215 // Get private forums … … 230 230 231 231 // Remove from _bbp_hidden_forums site option 232 if ( 'hidden'== $current_visibility ) {232 if ( bbp_get_hidden_status_id() == $current_visibility ) { 233 233 234 234 // Get hidden forums … … 250 250 // Update forum post_status 251 251 global $wpdb; 252 $wpdb->update( $wpdb->posts, array( 'post_status' => 'publish'), array( 'ID' => $forum_id ) );253 wp_transition_post_status( 'publish', $current_visibility, get_post( $forum_id ) );252 $wpdb->update( $wpdb->posts, array( 'post_status' => bbp_get_public_status_id() ), array( 'ID' => $forum_id ) ); 253 wp_transition_post_status( bbp_get_public_status_id(), $current_visibility, get_post( $forum_id ) ); 254 254 } 255 255 … … 275 275 276 276 // Only run queries if visibility is changing 277 if ( 'private'!= $current_visibility ) {277 if ( bbp_get_private_status_id() != $current_visibility ) { 278 278 279 279 // Remove from _bbp_hidden_forums site option 280 if ( 'hidden'== $current_visibility ) {280 if ( bbp_get_hidden_status_id() == $current_visibility ) { 281 281 282 282 // Get hidden forums … … 303 303 // Update forums visibility setting 304 304 global $wpdb; 305 $wpdb->update( $wpdb->posts, array( 'post_status' => 'private'), array( 'ID' => $forum_id ) );306 wp_transition_post_status( 'private', $current_visibility, get_post( $forum_id ) );305 $wpdb->update( $wpdb->posts, array( 'post_status' => bbp_get_private_status_id() ), array( 'ID' => $forum_id ) ); 306 wp_transition_post_status( bbp_get_private_status_id(), $current_visibility, get_post( $forum_id ) ); 307 307 } 308 308 … … 328 328 329 329 // Only run queries if visibility is changing 330 if ( 'hidden'!= $current_visibility ) {330 if ( bbp_get_hidden_status_id() != $current_visibility ) { 331 331 332 332 // Remove from _bbp_private_forums site option 333 if ( 'private'== $current_visibility ) {333 if ( bbp_get_private_status_id() == $current_visibility ) { 334 334 335 335 // Get private forums … … 355 355 356 356 // Update forums visibility setting 357 global $ bbp, $wpdb;358 $wpdb->update( $wpdb->posts, array( 'post_status' => 'hidden'), array( 'ID' => $forum_id ) );359 wp_transition_post_status( $bbp->hidden_status_id, $current_visibility, get_post( $forum_id ) );357 global $wpdb; 358 $wpdb->update( $wpdb->posts, array( 'post_status' => bbp_get_hidden_status_id() ), array( 'ID' => $forum_id ) ); 359 wp_transition_post_status( bbp_get_hidden_status_id(), $current_visibility, get_post( $forum_id ) ); 360 360 } 361 361 … … 511 511 */ 512 512 function bbp_update_forum_last_active_id( $forum_id = 0, $active_id = 0 ) { 513 513 514 $forum_id = bbp_get_forum_id( $forum_id ); 514 515 … … 544 545 545 546 // Update only if published 546 if ( 'publish'== get_post_status( $active_id ) )547 if ( bbp_get_public_status_id() == get_post_status( $active_id ) ) 547 548 update_post_meta( $forum_id, '_bbp_last_active_id', (int) $active_id ); 548 549 … … 661 662 */ 662 663 function bbp_update_forum_topic_count_hidden( $forum_id = 0, $topic_count = 0 ) { 663 global $wpdb , $bbp;664 global $wpdb; 664 665 665 666 // If topic_id was passed as $forum_id, then get its forum … … 678 679 // Get topics of forum 679 680 if ( empty( $topic_count ) ) 680 $topic_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';", $forum_id, bbp_get_topic_post_type() ) );681 $topic_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';", $forum_id, bbp_get_topic_post_type() ) ); 681 682 682 683 // Update the count … … 709 710 */ 710 711 function bbp_update_forum_reply_count( $forum_id = 0 ) { 711 global $wpdb , $bbp;712 global $wpdb; 712 713 713 714 $forum_id = bbp_get_forum_id( $forum_id ); … … 721 722 // Don't count replies if the forum is a category 722 723 if ( $topic_ids = bbp_forum_query_topic_ids( $forum_id ) ) 723 $reply_count = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent IN ( " . join( ',', $topic_ids ) . " ) AND post_status = ' publish' AND post_type = '%s';", bbp_get_reply_post_type() ) );724 $reply_count = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent IN ( " . join( ',', $topic_ids ) . " ) AND post_status = '%s' AND post_type = '%s';", bbp_get_public_status_id(), bbp_get_reply_post_type() ) ); 724 725 else 725 726 $reply_count = 0; … … 768 769 'last_active_id' => 0, 769 770 'last_active_time' => 0, 770 'last_active_status' => 'publish'771 'last_active_status' => bbp_get_public_status_id() 771 772 ); 772 773 … … 785 786 $last_active_time = get_post_field( 'post_date', $last_active_id ); 786 787 787 if ( 'publish'== $last_active_status ) {788 if ( bbp_get_public_status_id() == $last_active_status ) { 788 789 bbp_update_forum_last_active_time( $forum_id, $last_active_time ); 789 790 } … … 980 981 */ 981 982 function bbp_forum_query_topic_ids( $forum_id ) { 982 global $bbp;983 984 983 $topic_ids = bbp_get_public_child_ids( $forum_id, bbp_get_topic_post_type() ); 985 984 … … 1001 1000 */ 1002 1001 function bbp_forum_query_subforum_ids( $forum_id ) { 1003 global $bbp, $wpdb;1004 1005 1002 $subforum_ids = bbp_get_public_child_ids( $forum_id, bbp_get_forum_post_type() ); 1006 1003 … … 1025 1022 */ 1026 1023 function bbp_forum_query_last_reply_id( $forum_id, $topic_ids = 0 ) { 1027 global $ bbp, $wpdb;1024 global $wpdb; 1028 1025 1029 1026 $cache_id = 'bbp_get_forum_' . $forum_id . '_reply_id'; … … 1034 1031 $topic_ids = bbp_forum_query_topic_ids( $forum_id ); 1035 1032 1036 if ( !empty( $topic_ids ) && ( $reply_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent IN ( " . join( ',', $topic_ids ) . " ) AND post_status = ' publish' AND post_type = '%s' ORDER BY ID DESC LIMIT 1;", bbp_get_reply_post_type() ) ) ) )1033 if ( !empty( $topic_ids ) && ( $reply_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent IN ( " . join( ',', $topic_ids ) . " ) AND post_status = '%s' AND post_type = '%s' ORDER BY ID DESC LIMIT 1;", bbp_get_public_status_id(), bbp_get_reply_post_type() ) ) ) ) 1037 1034 wp_cache_set( $cache_id, $reply_id, 'bbpress' ); 1038 1035 else
Note: See TracChangeset
for help on using the changeset viewer.