Skip to:
Content

bbPress.org


Ignore:
Timestamp:
07/19/2017 04:11:11 PM (9 years ago)
Author:
johnjamesjacoby
Message:

General: Make sure object _get_ functions reach intended filters.

This retains existing behavior of bailing early and returning null if there is a post_type mismatch. Other similar functions would pass the null value through to the filter. These may do that eventually, but let's get these filters working first.

Fixes #3130.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/replies/template.php

    r6621 r6627  
    371371 */
    372372function bbp_get_reply( $reply, $output = OBJECT, $filter = 'raw' ) {
     373
     374    // Maybe get ID from empty or int
    373375    if ( empty( $reply ) || is_numeric( $reply ) ) {
    374376        $reply = bbp_get_reply_id( $reply );
    375377    }
    376378
     379    // Bail if no post object
    377380    $reply = get_post( $reply, OBJECT, $filter );
    378381    if ( empty( $reply ) ) {
     
    380383    }
    381384
     385    // Bail if not correct post type
    382386    if ( $reply->post_type !== bbp_get_reply_post_type() ) {
    383387        return null;
    384388    }
    385389
    386     if ( $output === OBJECT ) {
    387         return $reply;
    388 
    389     } elseif ( $output === ARRAY_A ) {
    390         $_reply = get_object_vars( $reply );
    391         return $_reply;
    392 
     390    // Default return value is OBJECT
     391    $retval = $reply;
     392
     393    // Array A
     394    if ( $output === ARRAY_A ) {
     395        $retval = get_object_vars( $reply );
     396
     397    // Array N
    393398    } elseif ( $output === ARRAY_N ) {
    394         $_reply = array_values( get_object_vars( $reply ) );
    395         return $_reply;
     399        $retval = array_values( get_object_vars( $reply ) );
    396400    }
    397401
    398402    // Filter & return
    399     return apply_filters( 'bbp_get_reply', $reply, $output, $filter );
     403    return apply_filters( 'bbp_get_reply', $retval, $reply, $output, $filter );
    400404}
    401405
Note: See TracChangeset for help on using the changeset viewer.