Skip to:
Content

bbPress.org

Changeset 2923


Ignore:
Timestamp:
02/20/2011 08:58:25 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Add ancestor walkers to update_reply functions for topic and forum

File:
1 edited

Legend:

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

    r2914 r2923  
    2424    $forum_id = bbp_get_forum_id( $forum_id );
    2525
     26    // If no forum_id was passed, walk up ancestors and look for forum type
     27    if ( empty( $topic_id ) ) {
     28        $ancestors = get_post_ancestors( $reply_id );
     29        foreach ( $ancestors as $ancestor ) {
     30            if ( get_post_field( 'post_parent', $ancestor ) == bbp_get_forum_post_type() ) {
     31                $topic_id = $ancestor;
     32                continue;
     33            }
     34        }
     35    }
     36
    2637    // Update the last reply ID
    2738    return update_post_meta( $reply_id, '_bbp_forum_id', (int) $forum_id );
     
    4556    $reply_id = bbp_get_reply_id( $reply_id );
    4657    $topic_id = bbp_get_topic_id( $topic_id );
     58
     59    // If no topic_id was passed, walk up ancestors and look for topic type
     60    if ( empty( $topic_id ) ) {
     61        $ancestors = get_post_ancestors( $reply_id );
     62        foreach ( $ancestors as $ancestor ) {
     63            if ( get_post_field( 'post_parent', $ancestor ) == bbp_get_topic_post_type() ) {
     64                $topic_id = $ancestor;
     65                continue;
     66            }
     67        }
     68    }
    4769
    4870    // Update the last reply ID
Note: See TracChangeset for help on using the changeset viewer.