Skip to:
Content

bbPress.org


Ignore:
Timestamp:
11/07/2019 07:40:16 PM (5 years ago)
Author:
johnjamesjacoby
Message:

Statuses: normalize status related functions across post types.

This commit adds 2 missing functions for forum statuses, and relocates all of them to the correct functions.php files for their post types.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/common/functions.php

    r6920 r6922  
    18691869        // Forum
    18701870        case bbp_get_forum_post_type() :
    1871             $post_status = array( bbp_get_private_status_id(), bbp_get_hidden_status_id() );
     1871            $post_status = bbp_get_non_public_forum_statuses();
    18721872            break;
    18731873
     
    18791879        // Reply
    18801880        case bbp_get_reply_post_type() :
     1881            $post_status = bbp_get_non_public_reply_statuses();
     1882            break;
     1883
     1884        // Any
    18811885        default :
    1882             $post_status = bbp_get_non_public_reply_statuses();
     1886            $post_status = bbp_get_public_status_id();
    18831887            break;
    18841888    }
     
    19121916    }
    19131917
    1914     // Get the public post status
    1915     $post_status = array( bbp_get_public_status_id() );
    1916 
    1917     // Add closed status if topic post type
    1918     if ( bbp_get_topic_post_type() === $post_type ) {
    1919         $post_status[] = bbp_get_closed_status_id();
     1918    // Which statuses
     1919    switch ( $post_type ) {
     1920
     1921        // Forum
     1922        case bbp_get_forum_post_type() :
     1923            $post_status = bbp_get_public_forum_statuses();
     1924            break;
     1925
     1926        // Topic
     1927        case bbp_get_topic_post_type() :
     1928            $post_status = bbp_get_public_topic_statuses();
     1929            break;
     1930
     1931        // Reply
     1932        case bbp_get_reply_post_type() :
     1933        default :
     1934            $post_status = bbp_get_public_reply_statuses();
     1935            break;
    19201936    }
    19211937
     
    19391955        'no_found_rows'          => true
    19401956    ) );
    1941     $child_ids = ! empty( $query->posts ) ? $query->posts : array();
     1957
     1958    $child_ids = ! empty( $query->posts )
     1959        ? $query->posts
     1960        : array();
     1961
    19421962    unset( $query );
    19431963
     
    19631983    }
    19641984
    1965     // Check cache key
    1966     $key          = md5( serialize( array( 'parent_id' => $parent_id, 'post_type' => $post_type ) ) );
     1985    // Make cache key
     1986    $not_in = array( 'draft', 'future' );
     1987    $key    = md5( serialize( array(
     1988        'parent_id'   => $parent_id,
     1989        'post_type'   => $post_type,
     1990        'post_status' => $not_in
     1991    ) ) );
     1992
     1993    // Check last changed
    19671994    $last_changed = wp_cache_get_last_changed( 'bbpress_posts' );
    19681995    $cache_key    = "bbp_child_ids:{$key}:{$last_changed}";
     
    19701997    // Check for cache and set if needed
    19711998    $child_ids = wp_cache_get( $cache_key, 'bbpress_posts' );
     1999
     2000    // Not already cached
    19722001    if ( false === $child_ids ) {
    19732002
    19742003        // Join post statuses to specifically exclude together
    1975         $not_in      = array( 'draft', 'future' );
    19762004        $post_status = "'" . implode( "', '", $not_in ) . "'";
    19772005        $bbp_db      = bbp_db();
Note: See TracChangeset for help on using the changeset viewer.