Changeset 5827 for trunk/src/includes/forums/functions.php
- Timestamp:
- 07/14/2015 12:31:42 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/includes/forums/functions.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/forums/functions.php
r5775 r5827 822 822 // Only run queries if visibility is changing 823 823 if ( bbp_get_public_status_id() !== $current_visibility ) { 824 825 // Update forums visibility setting 826 global $wpdb; 827 $wpdb->update( $wpdb->posts, array( 'post_status' => bbp_get_public_status_id() ), array( 'ID' => $forum_id ) ); 824 $bbp_db = bbp_db(); 825 $bbp_db->update( $bbp_db->posts, array( 'post_status' => bbp_get_public_status_id() ), array( 'ID' => $forum_id ) ); 828 826 wp_transition_post_status( bbp_get_public_status_id(), $current_visibility, get_post( $forum_id ) ); 829 827 bbp_clean_post_cache( $forum_id ); … … 874 872 875 873 // Update forums visibility setting 876 global $wpdb;877 $ wpdb->update( $wpdb->posts, array( 'post_status' => bbp_get_private_status_id() ), array( 'ID' => $forum_id ) );874 $bbp_db = bbp_db(); 875 $bbp_db->update( $bbp_db->posts, array( 'post_status' => bbp_get_private_status_id() ), array( 'ID' => $forum_id ) ); 878 876 wp_transition_post_status( bbp_get_private_status_id(), $current_visibility, get_post( $forum_id ) ); 879 877 bbp_clean_post_cache( $forum_id ); … … 924 922 925 923 // Update forums visibility setting 926 global $wpdb;927 $ wpdb->update( $wpdb->posts, array( 'post_status' => bbp_get_hidden_status_id() ), array( 'ID' => $forum_id ) );924 $bbp_db = bbp_db(); 925 $bbp_db->update( $bbp_db->posts, array( 'post_status' => bbp_get_hidden_status_id() ), array( 'ID' => $forum_id ) ); 928 926 wp_transition_post_status( bbp_get_hidden_status_id(), $current_visibility, get_post( $forum_id ) ); 929 927 bbp_clean_post_cache( $forum_id ); … … 1511 1509 */ 1512 1510 function bbp_update_forum_topic_count_hidden( $forum_id = 0, $topic_count = 0 ) { 1513 global $wpdb;1514 1511 1515 1512 // If topic_id was passed as $forum_id, then get its forum … … 1528 1525 // Get topics of forum 1529 1526 if ( empty( $topic_count ) ) { 1527 $bbp_db = bbp_db(); 1530 1528 $post_status = "'" . implode( "','", array( bbp_get_trash_status_id(), bbp_get_spam_status_id(), bbp_get_pending_status_id() ) ) . "'"; 1531 $topic_count = $ wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s';", $forum_id, bbp_get_topic_post_type() ) );1529 $topic_count = $bbp_db->get_var( $bbp_db->prepare( "SELECT COUNT(ID) FROM {$bbp_db->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s';", $forum_id, bbp_get_topic_post_type() ) ); 1532 1530 } 1533 1531 … … 1563 1561 */ 1564 1562 function bbp_update_forum_reply_count( $forum_id = 0 ) { 1565 global $wpdb;1566 1563 1567 1564 $forum_id = bbp_get_forum_id( $forum_id ); … … 1580 1577 $topic_ids = bbp_forum_query_topic_ids( $forum_id ); 1581 1578 if ( ! empty( $topic_ids ) ) { 1579 $bbp_db = bbp_db(); 1582 1580 $topic_ids = implode( ',', wp_parse_id_list( $topic_ids ) ); 1583 $reply_count = (int) $ wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent IN ( {$topic_ids} ) AND post_status = '%s' AND post_type = '%s';", bbp_get_public_status_id(), bbp_get_reply_post_type() ) );1581 $reply_count = (int) $bbp_db->get_var( $bbp_db->prepare( "SELECT COUNT(ID) FROM {$bbp_db->posts} WHERE post_parent IN ( {$topic_ids} ) AND post_status = '%s' AND post_type = '%s';", bbp_get_public_status_id(), bbp_get_reply_post_type() ) ); 1584 1582 } 1585 1583 … … 2004 2002 */ 2005 2003 function bbp_forum_query_last_reply_id( $forum_id, $topic_ids = 0 ) { 2006 global $wpdb;2007 2004 2008 2005 $cache_id = 'bbp_get_forum_' . $forum_id . '_reply_id'; … … 2016 2013 2017 2014 if ( !empty( $topic_ids ) ) { 2015 $bbp_db = bbp_db(); 2018 2016 $topic_ids = implode( ',', wp_parse_id_list( $topic_ids ) ); 2019 $reply_id = (int) $ wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent IN ( {$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() ) );2017 $reply_id = (int) $bbp_db->get_var( $bbp_db->prepare( "SELECT ID FROM {$bbp_db->posts} WHERE post_parent IN ( {$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() ) ); 2020 2018 } else { 2021 2019 $reply_id = 0;
Note: See TracChangeset
for help on using the changeset viewer.