Skip to:
Content

bbPress.org

Changeset 6814


Ignore:
Timestamp:
04/23/2018 04:59:08 AM (6 years ago)
Author:
johnjamesjacoby
Message:

Common: introduce bbp_get_post_types() and use where appropriate.

Fixes #2769.

Location:
trunk/src/includes
Files:
5 edited

Legend:

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

    r6787 r6814  
    1313// Exit if accessed directly
    1414defined( 'ABSPATH' ) || exit;
     15
     16/**
     17 * Return array of bbPress registered post types
     18 *
     19 * @since 2.6.0 bbPress (r6813)
     20 *
     21 * @return array
     22 */
     23function bbp_get_post_types() {
     24    return get_post_types( array( 'source' => 'bbpress' ) );
     25}
    1526
    1627/** URLs **********************************************************************/
  • trunk/src/includes/core/sub-actions.php

    r6792 r6814  
    271271    // Get bbPress post types
    272272    $post_type = get_post_type( $post );
    273     $types     = get_post_types( array( 'source' => 'bbpress' ) );
     273    $types     = bbp_get_post_types();
    274274
    275275    // Bail if post is not a bbPress post type
  • trunk/src/includes/core/theme-compat.php

    r6777 r6814  
    10111011 * @return bool True if open, false if closed
    10121012 */
    1013 function bbp_force_comment_status( $open, $post_id = 0 ) {
     1013function bbp_force_comment_status( $open = false, $post_id = 0 ) {
     1014
     1015    // Default return value is what is passed in $open
     1016    $retval = (bool) $open;
    10141017
    10151018    // Get the post type of the post ID
    10161019    $post_type = get_post_type( $post_id );
    10171020
    1018     // Default return value is what is passed in $open
    1019     $retval = (bool) $open;
    1020 
    10211021    // Only force for bbPress post types
    1022     switch ( $post_type ) {
    1023         case bbp_get_forum_post_type() :
    1024         case bbp_get_topic_post_type() :
    1025         case bbp_get_reply_post_type() :
    1026             $retval = false;
    1027             break;
     1022    if ( in_array( $post_type, bbp_get_post_types(), true ) ) {
     1023        $retval = false;
    10281024    }
    10291025
  • trunk/src/includes/forums/functions.php

    r6784 r6814  
    20592059
    20602060    // Some other post type besides Forums, Topics, or Replies
    2061     } elseif ( ! array_diff( $post_types, get_post_types( array( 'source' => 'bbpress' ) ) ) ) {
     2061    } elseif ( ! array_diff( $post_types, bbp_get_post_types() ) ) {
    20622062
    20632063        // Get forums to exclude
  • trunk/src/includes/search/template.php

    r6745 r6814  
    2626
    2727    $default_search_terms = bbp_get_search_terms();
    28     $default_post_types   = get_post_types( array( 'source' => 'bbpress' ) );
     28    $default_post_types   = bbp_get_post_types();
    2929
    3030    // Default query args
Note: See TracChangeset for help on using the changeset viewer.