Skip to:
Content

bbPress.org


Ignore:
Timestamp:
09/10/2011 10:27:19 PM (13 years ago)
Author:
johnjamesjacoby
Message:

API adjustments:

  • Refactor _status_ vars into callable functions.
  • Audit usage of $bbp global.
  • Perform get_class() checks on extensions to avoid errors if global $bbp is overloaded.
  • Bump DB version to 175.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-admin/bbp-functions.php

    r3415 r3505  
    196196    $tpt = bbp_get_topic_post_type();
    197197    $rpt = bbp_get_reply_post_type();
    198     $pps = 'publish';
    199     $cps = $bbp->closed_status_id;
     198    $pps = bbp_get_public_status_id();
     199    $cps = bbp_get_closed_status_id();
    200200
    201201    $sql = "INSERT INTO `{$wpdb->postmeta}` (`post_id`, `meta_key`, `meta_value`) (
     
    240240    $tpt = bbp_get_topic_post_type();
    241241    $rpt = bbp_get_reply_post_type();
    242     $pps = 'publish';
    243     $cps = $bbp->closed_status_id;
     242    $pps = bbp_get_public_status_id();
     243    $cps = bbp_get_closed_status_id();
    244244
    245245    $sql = "INSERT INTO `{$wpdb->postmeta}` (`post_id`, `meta_key`, `meta_value`) (
     
    280280        return array( 1, sprintf( $statement, $result ) );
    281281
    282     $sql = "INSERT INTO `{$wpdb->postmeta}` (`post_id`, `meta_key`, `meta_value`) (SELECT `post_parent`, '_bbp_reply_count_hidden', COUNT(`post_status`) as `meta_value` FROM `{$wpdb->posts}` WHERE `post_type` = '" . bbp_get_reply_post_type() . "' AND `post_status` IN ( '" . join( "','", array( 'trash', $bbp->spam_status_id ) ) . "') GROUP BY `post_parent`);";
     282    $sql = "INSERT INTO `{$wpdb->postmeta}` (`post_id`, `meta_key`, `meta_value`) (SELECT `post_parent`, '_bbp_reply_count_hidden', COUNT(`post_status`) as `meta_value` FROM `{$wpdb->posts}` WHERE `post_type` = '" . bbp_get_reply_post_type() . "' AND `post_status` IN ( '" . join( "','", array( 'trash', bbp_get_spam_status_id() ) ) . "') GROUP BY `post_parent`);";
    283283    if ( is_wp_error( $wpdb->query( $sql ) ) )
    284284        return array( 2, sprintf( $statement, $result ) );
     
    367367 */
    368368function bbp_recount_user_topics_replied() {
    369     global $wpdb;
     369    global $wpdb, $bbp;
    370370
    371371    $statement = __( 'Counting the number of topics to which each user has replied… %s', 'bbpress' );
    372372    $result    = __( 'Failed!', 'bbpress' );
    373373
    374     $sql_select = "SELECT `post_author`, COUNT(DISTINCT `ID`) as `_count` FROM `{$wpdb->posts}` WHERE `post_type` = '" . bbp_get_reply_post_type() . "' AND `post_status` = 'publish' GROUP BY `post_author`;";
     374    $sql_select = "SELECT `post_author`, COUNT(DISTINCT `ID`) as `_count` FROM `{$wpdb->posts}` WHERE `post_type` = '" . bbp_get_reply_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "' GROUP BY `post_author`;";
    375375    $insert_rows = $wpdb->get_results( $sql_select );
    376376
     
    706706 */
    707707function bbp_recount_clean_favorites() {
    708     global $wpdb;
     708    global $wpdb, $bbp;
    709709
    710710    $statement = __( 'Removing trashed topics from user favorites… %s', 'bbpress' );
     
    715715        return array( 1, sprintf( $statement, $result ) );
    716716
    717     $topics = $wpdb->get_col( "SELECT `ID` FROM `$wpdb->posts` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = 'publish';" );
     717    $topics = $wpdb->get_col( "SELECT `ID` FROM `$wpdb->posts` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "';" );
    718718
    719719    if ( is_wp_error( $topics ) )
     
    765765 */
    766766function bbp_recount_clean_subscriptions() {
    767     global $wpdb;
     767    global $wpdb, $bbp;
    768768
    769769    $statement = __( 'Removing trashed topics from user subscriptions… %s', 'bbpress' );
     
    774774        return array( 1, sprintf( $statement, $result ) );
    775775
    776     $topics = $wpdb->get_col( "SELECT `ID` FROM `$wpdb->posts` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = 'publish';" );
     776    $topics = $wpdb->get_col( "SELECT `ID` FROM `$wpdb->posts` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "';" );
    777777    if ( is_wp_error( $topics ) )
    778778        return array( 2, sprintf( $statement, $result ) );
     
    822822 */
    823823function bbp_recount_rewalk() {
    824     global $wpdb;
     824    global $wpdb, $bbp;
    825825
    826826    $statement = __( 'Recomputing latest post in every topic and forum… %s', 'bbpress' );
     
    835835            ( SELECT `topic`.`ID`, '_bbp_last_reply_id', MAX( `reply`.`ID` )
    836836            FROM `$wpdb->posts` AS `topic` INNER JOIN `$wpdb->posts` AS `reply` ON `topic`.`ID` = `reply`.`post_parent`
    837             WHERE `reply`.`post_status` IN ( 'publish' ) AND `topic`.`post_type` = 'topic' AND `reply`.`post_type` = 'reply'
     837            WHERE `reply`.`post_status` IN ( '" . bbp_get_public_status_id() . "' ) AND `topic`.`post_type` = 'topic' AND `reply`.`post_type` = 'reply'
    838838            GROUP BY `topic`.`ID` );" ) ) )
    839839        return array( 2, sprintf( $statement, $result ) );
     
    851851            ( SELECT `forum`.`ID`, '_bbp_last_topic_id', `topic`.`ID`
    852852            FROM `$wpdb->posts` AS `forum` INNER JOIN `$wpdb->posts` AS `topic` ON `forum`.`ID` = `topic`.`post_parent`
    853             WHERE `topic`.`post_status` IN ( 'publish' ) AND `forum`.`post_type` = 'forum' AND `topic`.`post_type` = 'topic'
     853            WHERE `topic`.`post_status` IN ( '" . bbp_get_public_status_id() . "' ) AND `forum`.`post_type` = 'forum' AND `topic`.`post_type` = 'topic'
    854854            GROUP BY `forum`.`ID` );" ) ) )
    855855        return array( 4, sprintf( $statement, $result ) );
     
    867867            ( SELECT `topic`.`ID`, '_bbp_last_active_id', MAX( `reply`.`ID` )
    868868            FROM `$wpdb->posts` AS `topic` INNER JOIN `$wpdb->posts` AS `reply` ON `topic`.`ID` = `reply`.`post_parent`
    869             WHERE `reply`.`post_status` IN ( 'publish' ) AND `topic`.`post_type` = 'topic' AND `reply`.`post_type` = 'reply'
     869            WHERE `reply`.`post_status` IN ( '" . bbp_get_public_status_id() . "' ) AND `topic`.`post_type` = 'topic' AND `reply`.`post_type` = 'reply'
    870870            GROUP BY `topic`.`ID` );" ) ) )
    871871        return array( 6, sprintf( $statement, $result ) );
     
    883883            ( SELECT `topic`.`ID`, '_bbp_last_active_time', MAX( `reply`.`post_date` )
    884884            FROM `$wpdb->posts` AS `topic` INNER JOIN `$wpdb->posts` AS `reply` ON `topic`.`ID` = `reply`.`post_parent`
    885             WHERE `reply`.`post_status` IN ( 'publish' ) AND `topic`.`post_type` = 'topic' AND `reply`.`post_type` = 'reply'
     885            WHERE `reply`.`post_status` IN ( '" . bbp_get_public_status_id() . "' ) AND `topic`.`post_type` = 'topic' AND `reply`.`post_type` = 'reply'
    886886            GROUP BY `topic`.`ID` );" ) ) )
    887887        return array( 8, sprintf( $statement, $result ) );
Note: See TracChangeset for help on using the changeset viewer.