Skip to:
Content

bbPress.org

Ticket #2036: 2036.7.diff

File 2036.7.diff, 41.8 KB (added by jmdodd, 10 years ago)
  • includes/admin/metaboxes.php

     
    400400        // Get some meta
    401401        $reply_topic_id = bbp_get_reply_topic_id( $post_id );
    402402        $reply_forum_id = bbp_get_reply_forum_id( $post_id );
     403        $reply_to       = bbp_get_reply_to(       $post_id );
    403404
    404405        // Allow individual manipulation of reply forum
    405406        if ( current_user_can( 'edit_others_replies' ) || current_user_can( 'moderate' ) ) : ?>
     
    435436                <input name="parent_id" id="bbp_topic_id" type="text" value="<?php echo esc_attr( $reply_topic_id ); ?>" />
    436437        </p>
    437438
     439        <p>
     440                <strong class="label"><?php _e( 'Reply To:', 'bbpress' ); ?></strong>
     441                <label class="screen-reader-text" for="bbp_reply_to"><?php _e( 'Reply To', 'bbpress' ); ?></label>
     442                <input name="bbp_reply_to" id="bbp_reply_to" type="text" value="<?php echo esc_attr( $reply_to ); ?>" />
     443        </p>
     444
    438445        <?php
    439446        wp_nonce_field( 'bbp_reply_metabox_save', 'bbp_reply_metabox' );
    440447        do_action( 'bbp_reply_metabox', $post_id );
  • includes/admin/replies.php

     
    220220                                '<ul>' .
    221221                                        '<li>' . __( '<strong>Forum</strong> dropdown determines the parent forum that the reply belongs to. Select the forum, or leave the default (Use Forum of Topic) to post the reply in forum of the topic.', 'bbpress' ) . '</li>' .
    222222                                        '<li>' . __( '<strong>Topic</strong> determines the parent topic that the reply belongs to.', 'bbpress' ) . '</li>' .
     223                                        '<li>' . __( '<strong>Reply To</strong> determines the threading of the reply.', 'bbpress' ) . '</li>' .
    223224                                '</ul>'
    224225                ) );
    225226
     
    300301                // Get the reply meta post values
    301302                $topic_id = !empty( $_POST['parent_id']    ) ? (int) $_POST['parent_id']    : 0;
    302303                $forum_id = !empty( $_POST['bbp_forum_id'] ) ? (int) $_POST['bbp_forum_id'] : bbp_get_topic_forum_id( $topic_id );
     304                $reply_to = !empty( $_POST['bbp_reply_to'] ) ? (int) $_POST['bbp_reply_to'] : 0;
    303305
    304306                // Get reply author data
    305307                $anonymous_data = bbp_filter_anonymous_post_data();
     
    307309                $is_edit        = (bool) isset( $_POST['save'] );
    308310
    309311                // Formally update the reply
    310                 bbp_update_reply( $reply_id, $topic_id, $forum_id, $anonymous_data, $author_id, $is_edit );
     312                bbp_update_reply( $reply_id, $topic_id, $forum_id, $anonymous_data, $author_id, $is_edit, $reply_to );
    311313
    312314                // Allow other fun things to happen
    313                 do_action( 'bbp_reply_attributes_metabox_save', $reply_id, $topic_id, $forum_id );
     315                do_action( 'bbp_reply_attributes_metabox_save', $reply_id, $topic_id, $forum_id, $reply_to );
    314316                do_action( 'bbp_author_metabox_save',           $reply_id, $anonymous_data      );
    315317
    316318                return $reply_id;
  • includes/admin/settings.php

     
    176176
    177177                'bbp_settings_theme_compat' => array(
    178178
    179                         // Replies per page setting
     179                        // Theme package setting
    180180                        '_bbp_theme_package_id' => array(
    181181                                'title'             => __( 'Current Package', 'bbpress' ),
    182182                                'callback'          => 'bbp_admin_setting_callback_subtheme_id',
     
    203203                                'callback'          => 'bbp_admin_setting_callback_replies_per_page',
    204204                                'sanitize_callback' => 'intval',
    205205                                'args'              => array()
     206                        ),
     207
     208                        // Set reply threading level
     209                        '_bbp_thread_replies_depth' => array(
     210                                'title'             => __( 'Thread level', 'bbpress' ),
     211                                'callback'          => 'bbp_admin_setting_callback_thread_replies_depth',
     212                                'sanitize_callback' => 'intval',
     213                                'args'              => array()
    206214                        )
    207215                ),
    208216
     
    505513}
    506514
    507515/**
     516 * Hierarchical reply max depth level setting field; replies will be threaded
     517 * if depth is 2 or greater
     518 *
     519 * @since bbPress (r####)
     520 *
     521 * @uses apply_filters() Calls 'bbp_thread_replies_depth_max' to set a
     522 *                        maximum displayed level
     523 * @uses selected() To display the selected attribute
     524 */
     525function bbp_admin_setting_callback_thread_replies_depth() {
     526
     527        // Set maximum depth for dropdown
     528        $max_depth = (int) apply_filters( 'bbp_thread_replies_depth_max', 10 );
     529        $current_depth = get_option( '_bbp_thread_replies_depth' );
     530
     531?>
     532        <label for="_bbp_thread_replies_depth">
     533                <select id="_bbp_thread_replies_depth" name="_bbp_thread_replies_depth">
     534                <?php for ( $i = 0; $i <= $max_depth; $i++ ) : ?>
     535
     536                        <option value="<?php echo esc_attr( $i ); ?>" <?php selected( $i, $current_depth ); ?>><?php echo esc_html( $i ); ?></option>
     537
     538                <?php endfor; ?>
     539                </select>
     540        <?php _e( ' levels deep', 'bbpress' ); ?>
     541        </label>
     542<?php
     543}
     544
     545/**
    508546 * Allow topic and reply revisions
    509547 *
    510548 * @since bbPress (r3412)
  • includes/common/classes.php

     
    259259        }
    260260}
    261261
     262/**
     263 * Create hierarchical list of bbPress replies.
     264 *
     265 * @package bbPress
     266 * @subpackage Classes
     267 *
     268 * @since bbPress (r####)
     269 */
     270class Walker_Reply extends Walker {
     271
     272        /**
     273         * @see Walker::$tree_type
     274         *
     275         * @since bbPress (r####)
     276         *
     277         * @var string
     278         */
     279        var $tree_type = 'reply';
     280
     281        /**
     282         * @see Walker::$db_fields
     283         *
     284         * @since bbPress (r####)
     285         *
     286         * @var array
     287         */
     288        var $db_fields = array(
     289                'parent' => 'reply_to',
     290                'id' => 'ID'
     291        );
     292
     293        /**
     294         * @see Walker::start_lvl()
     295         *
     296         * @since bbPress (r####)
     297         *
     298         * @param string $output Passed by reference. Used to append additional content
     299         * @param int $depth Depth of reply
     300         * @param array $args Uses 'style' argument for type of HTML list
     301         */
     302        public function start_lvl( &$output, $depth = 0, $args = array( ) ) {
     303                $GLOBALS['reply_depth'] = $depth + 1;
     304
     305                switch ( $args['style'] ) {
     306                        case 'div':
     307                                break;
     308                        case 'ol':
     309                                echo "<ol class='children'>\n";
     310                                break;
     311                        case 'ul':
     312                        default:
     313                                echo "<ul class='children'>\n";
     314                                break;
     315                }
     316        }
     317
     318        /**
     319         * @see Walker::end_lvl()
     320         *
     321         * @since bbPress (r####)
     322         *
     323         * @param string $output Passed by reference. Used to append additional content
     324         * @param int $depth Depth of reply
     325         * @param array $args Will only append content if style argument value is 'ol' or 'ul'
     326         */
     327        public function end_lvl( &$output, $depth = 0, $args = array( ) ) {
     328                $GLOBALS['reply_depth'] = $depth + 1;
     329
     330                switch ( $args['style'] ) {
     331                        case 'div':
     332                                break;
     333                        case 'ol':
     334                                echo "</ol>\n";
     335                                break;
     336                        case 'ul':
     337                        default:
     338                                echo "</ul>\n";
     339                                break;
     340                }
     341        }
     342
     343        /**
     344         * @since bbPress (r####)
     345         */
     346        public function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) {
     347
     348                if ( !$element )
     349                        return;
     350
     351                // Get element's id
     352                $id_field = $this->db_fields['id'];
     353                $id = $element->$id_field;
     354
     355                // Display element
     356                parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
     357
     358                // If we're at the max depth and the current element still has children, loop over those
     359                // and display them at this level to prevent them being orphaned to the end of the list.
     360                if ( $max_depth <= $depth + 1 && isset( $children_elements[$id] ) ) {
     361                        foreach ( $children_elements[$id] as $child )
     362                                $this->display_element( $child, $children_elements, $max_depth, $depth, $args, $output );
     363
     364                        unset( $children_elements[$id] );
     365                }
     366        }
     367
     368        /**
     369         * @see Walker:start_el()
     370         *
     371         * @since bbPress (r####)
     372         */
     373        public function start_el( &$output, $reply, $depth, $args, $id = 0 ) {
     374
     375                // Set up reply
     376                $depth++;
     377                $GLOBALS['reply_depth'] = $depth;
     378                bbpress()->reply_query->post = $reply;
     379                bbpress()->current_reply_id = $reply->ID;
     380
     381                // Check for a callback and use it if specified
     382                if ( !empty( $args['callback'] ) ) {
     383                        call_user_func( $args['callback'], $reply, $args, $depth );
     384                        return;
     385                }
     386
     387                // Style for div or list element
     388                if ( 'div' == $args['style'] ) {
     389                        $tag = 'div';
     390                        $add_below = 'reply';
     391                } else {
     392                        $tag = 'li';
     393                        $add_below = 'div-reply';
     394                } ?>
     395
     396                <<?php echo $tag ?>>
     397
     398                        <?php bbp_get_template_part( 'loop', 'single-reply' ); ?>
     399
     400                </<?php echo $tag ?>>
     401
     402                <?php
     403        }
     404
     405        /**
     406         * @since bbPress (r####)
     407         */
     408        public function end_el( &$output, $reply, $depth = 0, $args = array( ) ) {
     409
     410                // Check for a callback and use it if specified
     411                if ( !empty( $args['end-callback'] ) ) {
     412                        call_user_func( $args['end-callback'], $reply, $args, $depth );
     413                        return;
     414                }
     415
     416                // Style for div or list element
     417                if ( 'div' == $args['style'] )
     418                        echo "</div>\n";
     419                else
     420                        echo "</li>\n";
     421        }
     422}
     423
    262424endif; // class_exists check
  • includes/common/template-tags.php

     
    15821582
    15831583                <input type="hidden" name="bbp_reply_title" id="bbp_reply_title" value="<?php bbp_reply_title(); ?>" />
    15841584                <input type="hidden" name="bbp_reply_id"    id="bbp_reply_id"    value="<?php bbp_reply_id(); ?>" />
     1585                <input type="hidden" name="bbp_reply_to"    id="bbp_reply_to"    value="<?php bbp_form_reply_to(); ?>" />
    15851586                <input type="hidden" name="action"          id="bbp_post_action" value="bbp-edit-reply" />
    15861587
    15871588                <?php if ( current_user_can( 'unfiltered_html' ) )
     
    15931594
    15941595                <input type="hidden" name="bbp_reply_title" id="bbp_reply_title" value="<?php printf( __( 'Reply To: %s', 'bbpress' ), bbp_get_topic_title() ); ?>" />
    15951596                <input type="hidden" name="bbp_topic_id"    id="bbp_topic_id"    value="<?php bbp_topic_id(); ?>" />
     1597                <input type="hidden" name="bbp_reply_to"    id="bbp_reply_to"    value="<?php bbp_form_reply_to(); ?>" />
    15961598                <input type="hidden" name="action"          id="bbp_post_action" value="bbp-new-reply" />
    15971599
    15981600                <?php if ( current_user_can( 'unfiltered_html' ) )
  • includes/core/actions.php

     
    181181add_action( 'bbp_forum_attributes_metabox_save', 'bbp_save_forum_extras', 2 );
    182182
    183183// New/Edit Reply
    184 add_action( 'bbp_new_reply',  'bbp_update_reply', 10, 6 );
    185 add_action( 'bbp_edit_reply', 'bbp_update_reply', 10, 6 );
     184add_action( 'bbp_new_reply',  'bbp_update_reply', 10, 7 );
     185add_action( 'bbp_edit_reply', 'bbp_update_reply', 10, 7 );
    186186
    187187// Before Delete/Trash/Untrash Reply
    188188add_action( 'wp_trash_post', 'bbp_trash_reply'   );
  • includes/core/options.php

     
    3434                '_bbp_enable_favorites'     => 1,                          // Favorites
    3535                '_bbp_enable_subscriptions' => 1,                          // Subscriptions
    3636                '_bbp_allow_topic_tags'     => 1,                          // Topic Tags
     37                '_bbp_thread_replies_depth' => 0,                          // Thread replies depth
    3738                '_bbp_allow_anonymous'      => 0,                          // Allow anonymous posting
    3839                '_bbp_allow_global_access'  => 1,                          // Users from all sites can post
    3940                '_bbp_use_wp_editor'        => 1,                          // Use the WordPress editor if available
     
    227228}
    228229
    229230/**
     231 * Are replies threaded
     232 *
     233 * @since bbPress (r####)
     234 *
     235 * @param bool $default Optional. Default value true
     236 * @uses apply_filters() Calls 'bbp_thread_replies' with the calculated value and
     237 *                        the thread replies depth
     238 * @uses get_option() To get thread replies option
     239 * @return bool Are replies threaded?
     240 */
     241function bbp_thread_replies() {
     242        $depth  = bbp_thread_replies_depth();
     243        $retval = (bool) ( $depth > 1 );
     244
     245        return (bool) apply_filters( 'bbp_thread_replies', $retval, $depth );
     246}
     247
     248/**
     249 * Maximum reply thread depth
     250 *
     251 * @since bbPress (r####)
     252 *
     253 * @param int $default Thread replies depth
     254 * @uses apply_filters() Calls 'bbp_thread_replies_depth' with the option value and
     255 *                       the default depth
     256 * @uses get_option() To get the thread replies depth
     257 * @return int Thread replies depth
     258 */
     259function bbp_thread_replies_depth( $default = 1 ) {
     260        return (int) apply_filters( 'bbp_thread_replies_depth', (int) get_option( '_bbp_thread_replies_depth', $default ) );
     261}
     262
     263/**
    230264 * Are topic and reply revisions allowed
    231265 *
    232266 * @since bbPress (r3412)
     
    283317 * @return bool Use WP editor?
    284318 */
    285319function bbp_use_wp_editor( $default = 1 ) {
     320
     321        // Disable if replies are threaded
     322        if ( bbp_thread_replies() )
     323                $default = 0;
     324
    286325        return (bool) apply_filters( 'bbp_use_wp_editor', (bool) get_option( '_bbp_use_wp_editor', $default ) );
    287326}
    288327
  • includes/replies/functions.php

     
    9797 * @uses wp_set_post_terms() To set the topic tags
    9898 * @uses wp_insert_post() To insert the reply
    9999 * @uses do_action() Calls 'bbp_new_reply' with the reply id, topic id, forum
    100  *                    id, anonymous data and reply author
     100 *                    id, anonymous data, reply author, edit (false), and
     101 *                    the reply to id
    101102 * @uses bbp_get_reply_url() To get the paginated url to the reply
    102103 * @uses wp_safe_redirect() To redirect to the reply url
    103104 * @uses bbPress::errors::get_error_message() To get the {@link WP_Error} error
     
    116117        }
    117118
    118119        // Define local variable(s)
    119         $topic_id = $forum_id = $reply_author = $anonymous_data = 0;
     120        $topic_id = $forum_id = $reply_author = $anonymous_data = $reply_to = 0;
    120121        $reply_title = $reply_content = $terms = '';
    121122
    122123        /** Reply Author **********************************************************/
     
    195196                }
    196197        }
    197198
     199        /** Reply To **************************************************************/
     200
     201        // Handle Reply To of the reply; $_REQUEST for non-JS submissions
     202        if ( isset( $_REQUEST['bbp_reply_to'] ) ) {
     203                $reply_to = (int) $_REQUEST['bbp_reply_to'];
     204        }
     205
     206        $reply_to = bbp_get_reply_id( $reply_to );
     207
    198208        /** Unfiltered HTML *******************************************************/
    199209
    200210        // Remove kses filters from title and content for capable users and if the nonce is verified
     
    364374
    365375                /** Update counts, etc... *********************************************/
    366376
    367                 do_action( 'bbp_new_reply', $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author );
     377                do_action( 'bbp_new_reply', $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author, false, $reply_to );
    368378
    369379                /** Additional Actions (After Save) ***********************************/
    370380
     
    421431 * @uses wp_update_post() To update the reply
    422432 * @uses bbp_get_reply_topic_id() To get the reply topic id
    423433 * @uses bbp_get_topic_forum_id() To get the topic forum id
     434 * @uses bbp_get_reply_to() To get the reply to id
    424435 * @uses do_action() Calls 'bbp_edit_reply' with the reply id, topic id, forum
    425  *                    id, anonymous data, reply author and bool true (for edit)
     436 *                    id, anonymous data, reply author, bool true (for edit),
     437 *                    and the reply to id
    426438 * @uses bbp_get_reply_url() To get the paginated url to the reply
    427439 * @uses wp_safe_redirect() To redirect to the reply url
    428440 * @uses bbPress::errors::get_error_message() To get the {@link WP_Error} error
     
    501513
    502514        $forum_id = bbp_get_topic_forum_id( $topic_id );
    503515
     516        /** Reply To **************************************************************/
     517
     518        $reply_to = bbp_get_reply_to( $reply_id );
     519
    504520        // Forum exists
    505521        if ( !empty( $forum_id ) && ( $forum_id !== bbp_get_reply_forum_id( $reply_id ) ) ) {
    506522
     
    660676        if ( !empty( $reply_id ) && !is_wp_error( $reply_id ) ) {
    661677
    662678                // Update counts, etc...
    663                 do_action( 'bbp_edit_reply', $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author , true /* Is edit */ );
     679                do_action( 'bbp_edit_reply', $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author , true /* Is edit */, $reply_to );
    664680
    665681                /** Additional Actions (After Save) ***********************************/
    666682
     
    702718 * @param bool|array $anonymous_data Optional logged-out user data.
    703719 * @param int $author_id Author id
    704720 * @param bool $is_edit Optional. Is the post being edited? Defaults to false.
     721 * @param int $reply_to Optional. Reply to id
    705722 * @uses bbp_get_reply_id() To get the reply id
    706723 * @uses bbp_get_topic_id() To get the topic id
    707724 * @uses bbp_get_forum_id() To get the forum id
     
    718735 * @uses bbp_add_user_subscription() To add the user's subscription
    719736 * @uses bbp_update_reply_forum_id() To update the reply forum id
    720737 * @uses bbp_update_reply_topic_id() To update the reply topic id
     738 * @uses bbp_update_reply_to() To update the reply to id
    721739 * @uses bbp_update_reply_walker() To update the reply's ancestors' counts
    722740 */
    723 function bbp_update_reply( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $author_id = 0, $is_edit = false ) {
     741function bbp_update_reply( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $author_id = 0, $is_edit = false, $reply_to = 0 ) {
    724742
    725743        // Validate the ID's passed from 'bbp_new_reply' action
    726         $reply_id = bbp_get_reply_id( $reply_id );
    727         $topic_id = bbp_get_topic_id( $topic_id );
    728         $forum_id = bbp_get_forum_id( $forum_id );
     744        $reply_id    = bbp_get_reply_id( $reply_id );
     745        $topic_id    = bbp_get_topic_id( $topic_id );
     746        $forum_id    = bbp_get_forum_id( $forum_id );
     747        $reply_to    = bbp_get_reply_id( $reply_to );
    729748
    730749        // Bail if there is no reply
    731750        if ( empty( $reply_id ) )
     
    789808        // Reply meta relating to reply position in tree
    790809        bbp_update_reply_forum_id( $reply_id, $forum_id );
    791810        bbp_update_reply_topic_id( $reply_id, $topic_id );
     811        bbp_update_reply_to(       $reply_id, $reply_to );
    792812
    793813        // Update associated topic values if this is a new reply
    794814        if ( empty( $is_edit ) ) {
     
    10261046        return apply_filters( 'bbp_update_reply_topic_id', (int) $topic_id, $reply_id );
    10271047}
    10281048
     1049/*
     1050 * Update the reply's meta data with its reply to id
     1051 *
     1052 * @since bbPress (r####)
     1053 *
     1054 * @param int $reply_id Reply id to update
     1055 * @param int $reply_to Optional. Reply to id
     1056 * @uses bbp_get_reply_id() To get the reply id
     1057 * @uses update_post_meta() To update the reply to meta
     1058 * @uses apply_filters() Calls 'bbp_update_reply_to' with the reply id and
     1059 *                        and reply to id
     1060 * @return bool Reply's parent reply id
     1061 */
     1062function bbp_update_reply_to( $reply_id = 0, $reply_to = 0 ) {
     1063
     1064        // Validation
     1065        $reply_id = bbp_get_reply_id( $reply_id );
     1066        $reply_to = bbp_get_reply_id( $reply_to );
     1067
     1068        // Return if no reply
     1069        if ( empty( $reply_id ) )
     1070                return;
     1071
     1072        // Return if no reply to
     1073        if ( empty( $reply_to ) )
     1074                return;
     1075
     1076        // Set the reply to
     1077        update_post_meta( $reply_id, '_bbp_reply_to', $reply_to );
     1078
     1079        return (int) apply_filters( 'bbp_update_reply_to', (int) $reply_to, $reply_id );
     1080}
     1081
    10291082/**
    10301083 * Update the revision log of the reply
    10311084 *
     
    12861339        $last_reply_id = $move_reply->ID;
    12871340        $freshness     = $move_reply->post_date;
    12881341
     1342        // Get the reply to
     1343        $parent = bbp_get_reply_to( $move_reply->ID );
     1344
     1345        // Fix orphaned children
     1346        $children = get_posts( array(
     1347                'post_type'  => bbp_get_reply_post_type(),
     1348                'meta_key'   => '_bbp_reply_to',
     1349                'meta_value' => $move_reply->ID,
     1350        ) );
     1351        foreach ( $children as $child )
     1352                bbp_update_reply_to( $child->ID, $parent );
     1353
     1354        // Remove reply_to from moved reply
     1355        delete_post_meta( $move_reply->ID, '_bbp_reply_to' );
     1356
    12891357        // It is a new topic and we need to set some default metas to make
    12901358        // the topic display in bbp_has_topics() list
    12911359        if ( 'topic' == $move_option ) {
     
    20722140
    20732141        return (int) $reply_position;
    20742142}
     2143
     2144/** Hierarchical Replies ******************************************************/
     2145
     2146/**
     2147 * List replies
     2148 *
     2149 * @since bbPress (r####)
     2150 */
     2151function bbp_list_replies( $args = array(), $replies = null ) {
     2152        global $reply_alt, $reply_depth, $reply_thread_alt;
     2153
     2154        // In reply loop
     2155        bbpress()->reply_query->in_the_loop = true;
     2156
     2157        // Initialize variables
     2158        $reply_alt = $reply_thread_alt = 0;
     2159        $reply_depth = 1;
     2160
     2161        $defaults = array(
     2162                'walker'       => null,
     2163                'max_depth'    => bbp_thread_replies_depth(),
     2164                'style'        => 'ul',
     2165                'callback'     => null,
     2166                'end_callback' => null,
     2167                'page'         => 1,
     2168                'per_page'     => -1
     2169        );
     2170
     2171        $r = wp_parse_args( $args, $defaults );
     2172
     2173        // Get replies to loop through in $_replies
     2174        if ( null !== $replies ) {
     2175                $replies = (array) $replies;
     2176                if ( empty( $replies ) )
     2177                        return;
     2178                $_replies = $replies;
     2179        } else {
     2180                if ( empty( bbpress()->reply_query->posts ) )
     2181                        return;
     2182                $_replies = bbpress()->reply_query->posts;
     2183        }
     2184
     2185        if ( empty( $walker ) )
     2186                $walker = new Walker_Reply;
     2187
     2188        $walker->paged_walk( $_replies, $r['max_depth'], $r['page'], $r['per_page'], $r );
     2189        bbpress()->max_num_pages = $walker->max_pages;
     2190
     2191        bbpress()->reply_query->in_the_loop = false;
     2192}
  • includes/replies/template-tags.php

     
    8080                'paged'               => bbp_get_paged(),            // On this page
    8181                'orderby'             => 'date',                     // Sorted by date
    8282                'order'               => 'ASC',                      // Oldest to newest
     83                'hierarchical'        => false,                      // Hierarchical replies
    8384                'ignore_sticky_posts' => true,                       // Stickies not supported
    8485                's'                   => $default_reply_search,      // Maybe search
    8586        );
     
    113114        // Parse arguments against default values
    114115        $r = bbp_parse_args( $args, $default, 'has_replies' );
    115116
     117        // Set posts_per_page value if replies are threaded
     118        $replies_per_page = $r['posts_per_page'];
     119        if ( $r['hierarchical'] ) {
     120                $r['posts_per_page'] = -1;
     121        }
     122
    116123        // Get bbPress
    117124        $bbp = bbpress();
    118125
     
    120127        $bbp->reply_query = new WP_Query( $r );
    121128
    122129        // Add pagination values to query object
    123         $bbp->reply_query->posts_per_page = $r['posts_per_page'];
     130        $bbp->reply_query->posts_per_page = $replies_per_page;
    124131        $bbp->reply_query->paged          = $r['paged'];
    125132
    126133        // Never home, regardless of what parse_query says
     
    131138                $bbp->reply_query->is_single = true;
    132139        }
    133140
     141        // Only add reply to if query returned results
     142        if ( (int) $bbp->reply_query->found_posts ) {
     143
     144                // Get reply to for each reply
     145                foreach ( $bbp->reply_query->posts as &$post ) {
     146
     147                        // Check for reply post type
     148                        if ( $post->post_type == bbp_get_reply_post_type() ) {
     149                                $reply_to = bbp_get_reply_to( $post->ID );
     150
     151                                // Make sure it's a reply to a reply
     152                                if ( empty( $reply_to ) || ( bbp_get_reply_topic_id( $post->ID ) == $reply_to ) )
     153                                        $reply_to = 0;
     154                                $post->reply_to = $reply_to;
     155                        }
     156                }
     157        }
     158
    134159        // Only add pagination if query returned results
    135160        if ( (int) $bbp->reply_query->found_posts && (int) $bbp->reply_query->posts_per_page ) {
    136161
     
    161186                        $base = add_query_arg( 'paged', '%#%' );
    162187                }
    163188
    164                 // Add pagination to query object
    165                 $bbp->reply_query->pagination_links = paginate_links(
    166                         apply_filters( 'bbp_replies_pagination', array(
    167                                 'base'      => $base,
    168                                 'format'    => '',
    169                                 'total'     => ceil( (int) $bbp->reply_query->found_posts / (int) $r['posts_per_page'] ),
    170                                 'current'   => (int) $bbp->reply_query->paged,
    171                                 'prev_text' => is_rtl() ? '&rarr;' : '&larr;',
    172                                 'next_text' => is_rtl() ? '&larr;' : '&rarr;',
    173                                 'mid_size'  => 1,
    174                                 'add_args'  => ( bbp_get_view_all() ) ? array( 'view' => 'all' ) : false
    175                         ) )
    176                 );
     189                // Figure out total pages
     190                if ( $r['hierarchical'] ) {
     191                        $walker      = new Walker_Reply;
     192                        $total_pages = ceil( (int) $walker->get_number_of_root_elements( $bbp->reply_query->posts ) / (int) $replies_per_page );
     193                } else {
     194                        $total_pages = ceil( (int) $bbp->reply_query->found_posts / (int) $replies_per_page );
    177195
    178                 // Remove first page from pagination
    179                 if ( $wp_rewrite->using_permalinks() ) {
    180                         $bbp->reply_query->pagination_links = str_replace( $wp_rewrite->pagination_base . '/1/', '', $bbp->reply_query->pagination_links );
    181                 } else {
    182                         $bbp->reply_query->pagination_links = str_replace( '&#038;paged=1', '', $bbp->reply_query->pagination_links );
     196                        // Add pagination to query object
     197                        $bbp->reply_query->pagination_links = paginate_links(
     198                                apply_filters( 'bbp_replies_pagination', array(
     199                                        'base'      => $base,
     200                                        'format'    => '',
     201                                        'total'     => $total_pages,
     202                                        'current'   => (int) $bbp->reply_query->paged,
     203                                        'prev_text' => is_rtl() ? '&rarr;' : '&larr;',
     204                                        'next_text' => is_rtl() ? '&larr;' : '&rarr;',
     205                                        'mid_size'  => 1,
     206                                        'add_args'  => ( bbp_get_view_all() ) ? array( 'view' => 'all' ) : false
     207                                ) )
     208                        );
     209
     210                        // Remove first page from pagination
     211                        if ( $wp_rewrite->using_permalinks() ) {
     212                                $bbp->reply_query->pagination_links = str_replace( $wp_rewrite->pagination_base . '/1/', '', $bbp->reply_query->pagination_links );
     213                        } else {
     214                                $bbp->reply_query->pagination_links = str_replace( '&#038;paged=1', '', $bbp->reply_query->pagination_links );
     215                        }
    183216                }
    184217        }
    185218
     
    386419                // Set needed variables
    387420                $reply_id   = bbp_get_reply_id      ( $reply_id );
    388421                $topic_id   = bbp_get_reply_topic_id( $reply_id );
    389                 $reply_page = ceil( (int) bbp_get_reply_position( $reply_id, $topic_id ) / (int) bbp_get_replies_per_page() );
     422
     423                // Hierarchical reply page
     424                if ( bbp_thread_replies() ) {
     425                        $reply_page = 1;
     426
     427                // Standard reply page
     428                } else {
     429                        $reply_page = ceil( (int) bbp_get_reply_position( $reply_id, $topic_id ) / (int) bbp_get_replies_per_page() );
     430                }
     431
    390432                $reply_hash = '#post-' . $reply_id;
    391433                $topic_link = bbp_get_topic_permalink( $topic_id, $redirect_to );
    392434                $topic_url  = remove_query_arg( 'view', $topic_link );
     
    13771419        }
    13781420
    13791421/**
     1422 * Output the reply's ancestor reply id
     1423 *
     1424 * @since bbPress (r####)
     1425 *
     1426 * @param int $reply_id Optional. Reply id
     1427 * @uses bbp_get_reply_ancestor_id() To get the reply's ancestor id
     1428 */
     1429function bbp_reply_ancestor_id( $reply_id = 0 ) {
     1430        echo bbp_get_reply_ancestor_id( $reply_id );
     1431}
     1432        /**
     1433         * Return the reply's ancestor reply id
     1434         *
     1435         * @since bbPress (r####)
     1436         *
     1437         * @param in $reply_id Reply id
     1438         * @uses bbp_get_reply_id() To get the reply id
     1439         */
     1440        function bbp_get_reply_ancestor_id( $reply_id = 0 ) {
     1441
     1442                // Validation
     1443                $reply_id = bbp_get_reply_id( $reply_id );
     1444                if ( empty( $reply_id ) )
     1445                        return false;
     1446
     1447                // Find highest reply ancestor
     1448                $ancestor_id = $reply_id;
     1449                while ( $parent_id = bbp_get_reply_to( $ancestor_id ) ) {
     1450                        if ( empty( $parent_id ) || $parent_id == $ancestor_id || $parent_id == bbp_get_reply_topic_id( $reply_id ) || $parent_id == $reply_id )
     1451                                break;
     1452                        $ancestor_id = $parent_id;
     1453                }
     1454
     1455                return (int) $ancestor_id;
     1456        }
     1457
     1458/**
     1459 * Output the reply to id of a reply
     1460 *
     1461 * @since bbPress (r####)
     1462 *
     1463 * @param int $reply_id Optional. Reply id
     1464 * @uses bbp_get_reply_to() To get the reply to id
     1465 */
     1466function bbp_reply_to( $reply_id = 0 ) {
     1467        echo bbp_get_reply_to( $reply_id );
     1468}
     1469        /**
     1470         * Return the reply to id of a reply
     1471         *
     1472         * @since bbPress (r####)
     1473         *
     1474         * @param int $reply_id Optional. Reply id
     1475         * @uses bbp_get_reply_id() To get the reply id
     1476         * @uses get_post_meta() To get the reply to id
     1477         * @uses apply_filters() Calls 'bbp_get_reply_to' with the reply to id and
     1478         *                        reply id
     1479         * @return int Reply's reply to id
     1480         */
     1481        function bbp_get_reply_to( $reply_id = 0 ) {
     1482
     1483                // Assume there is no reply_to set
     1484                $reply_to = 0;
     1485
     1486                // Check that reply_id is valid
     1487                if ( $reply_id = bbp_get_reply_id( $reply_id ) )
     1488
     1489                        // Get reply_to value
     1490                        $reply_to = (int) get_post_meta( $reply_id, '_bbp_reply_to', true );
     1491
     1492                return (int) apply_filters( 'bbp_get_reply_to', $reply_to, $reply_id );
     1493        }
     1494
     1495/**
     1496 * Output the link for the reply to
     1497 *
     1498 * @since bbPress (r####)
     1499 *
     1500 * @param array $args
     1501 * @param int $reply
     1502 * @uses bbp_get_reply_to_link() To get the reply to link
     1503 */
     1504function bbp_reply_to_link( $args = array(), $reply = 0 ) {
     1505        echo bbp_get_reply_to_link( $args, $reply );
     1506}
     1507
     1508        /**
     1509         * Return the link for a reply to a reply
     1510         *
     1511         * @since bbPress (r####)
     1512         *
     1513         * @param array $args Arguments
     1514         * @param int $reply_id Reply id
     1515         * @uses bbp_current_user_can_access_create_reply_form() To check permissions
     1516         * @uses bbp_get_reply_id() To validate the reply id
     1517         * @uses bbp_get_reply() To get the reply
     1518         * @uses apply_filters() Calls 'bbp_get_reply_to_link' with the formatted link,
     1519         *                        the arguments array, and the reply
     1520         * @return string Link for a reply to a reply
     1521         */
     1522        function bbp_get_reply_to_link( $args = array(), $reply_id = 0 ) {
     1523
     1524                // Parse arguments against default values
     1525                $r = bbp_parse_args( $args, array(
     1526                        'id'           => 0,
     1527                        'link_before'  => '',
     1528                        'link_after'   => '',
     1529                        'reply_text'   => __( 'Reply', 'bbpress' ),
     1530                        'depth'        => 0,
     1531                        'add_below'    => 'post',
     1532                        'respond_id'   => 'new-reply-' . bbp_get_topic_id(),
     1533                ), 'get_reply_to_link' );
     1534
     1535                $reply = bbp_get_reply( bbp_get_reply_id( (int) $r['id'] ) );
     1536
     1537                // Bail if no reply or user cannot reply
     1538                if ( empty( $reply ) || ! bbp_current_user_can_access_create_reply_form() )
     1539                        return;
     1540
     1541                // Build the URI and return value
     1542                $uri      = remove_query_arg( array( 'bbp_reply_to' ) );
     1543                $uri      = add_query_arg( array( 'bbp_reply_to' => $reply->ID ) );
     1544                $uri      = esc_url( wp_nonce_url( $uri, 'respond_id_' . $reply->ID ) );
     1545                $uri      = $uri . '#new-post';
     1546                $onclick  = 'return addReply.moveForm("' . $r['add_below'] . '-' . $reply->ID . '","' . $reply->ID . '","' . $r['respond_id'] . '","' . $reply->post_parent . '")';
     1547                $r['uri'] = $uri;
     1548                $retval   = $r['link_before'] . '<a href="' . $r['uri'] . '" class="bbp-reply-to-link" onclick=' . "'{$onclick}' >" . $r['reply_text'] . '</a>' . $r['link_after'];
     1549
     1550                return apply_filters( 'bbp_get_reply_spam_link', $retval, $r );
     1551        }
     1552
     1553/**
     1554 * Output the reply to a reply cancellation link
     1555 *
     1556 * @since bbPress (r####)
     1557 *
     1558 * @uses bbp_get_cancel_reply_to_link() To get the reply cancellation link
     1559 */
     1560function bbp_cancel_reply_to_link( $text = '' ) {
     1561        echo bbp_get_cancel_reply_to_link( $text );
     1562}
     1563        /**
     1564         * Return the cancellation link for a reply to a reply
     1565         *
     1566         * @since bbPress (r####)
     1567         *
     1568         * @param string $text The cancel text
     1569         * @uses apply_filters() Calls 'bbp_get_cancel_reply_to_link' with the cancellation
     1570         *                        link and the cancel text
     1571         * @return string The cancellation link
     1572         */
     1573        function bbp_get_cancel_reply_to_link( $text = '' ) {
     1574
     1575                // Bail if not hierarchical or editing a reply
     1576                if ( ! bbp_thread_replies() || bbp_is_reply_edit() )
     1577                        return;
     1578
     1579                // Set default text
     1580                if ( empty( $text ) )
     1581                        $text = __( 'Cancel', 'bbpress' );
     1582
     1583                $reply_to = isset( $_GET['bbp_reply_to'] ) ? (int) $_GET['bbp_reply_to'] : 0;
     1584
     1585                // Set visibility
     1586                $style = !empty( $reply_to ) ? '' : ' style="display:none;"';
     1587                $link  = esc_url( remove_query_arg( array( 'bbp_reply_to', '_wpnonce' ) ) ) . '#post-' . $reply_to;
     1588
     1589                return apply_filters( 'bbp_get_cancel_reply_to_link', '<a rel="nofollow" id="bbp-cancel-reply-to-link" href="' . $link . '"' . $style . '>' . $text . '</a>', $link, $text );
     1590        }
     1591
     1592/**
    13801593 * Output the numeric position of a reply within a topic
    13811594 *
    13821595 * @since bbPress (r2984)
     
    15161729                                'split' => bbp_get_topic_split_link( $r ),
    15171730                                'trash' => bbp_get_reply_trash_link( $r ),
    15181731                                'spam'  => bbp_get_reply_spam_link ( $r ),
     1732                                'reply' => bbp_get_reply_to_link   ( $r )
    15191733                        ), $r['id'] );
    15201734                }
    15211735
     
    20112225                $total_int = (int) $bbp->reply_query->found_posts;
    20122226                $total     = bbp_number_format( $total_int );
    20132227
     2228                // We are threading replies
     2229                if ( bbp_thread_replies() ) {
     2230                        $walker  = new Walker_Reply;
     2231                        $threads = (int) $walker->get_number_of_root_elements( $bbp->reply_query->posts );
     2232
     2233                        // Adjust for topic
     2234                        $threads--;
     2235                        $retstr  = sprintf( _n( 'Viewing %1$d reply thread', 'Viewing %1$d reply threads', $threads, 'bbbpress' ), $threads );
     2236
    20142237                // We are not including the lead topic
    2015                 if ( bbp_show_lead_topic() ) {
     2238                } elseif ( bbp_show_lead_topic() ) {
    20162239
    20172240                        // Several replies in a topic with a single page
    20182241                        if ( empty( $to_num ) ) {
     
    21082331        }
    21092332
    21102333/**
     2334 * Output the value of the reply to field
     2335 *
     2336 * @since bbPress (r####)
     2337 *
     2338 * @uses bbp_get_form_reply_to() To get value of the reply to field
     2339 */
     2340function bbp_form_reply_to() {
     2341        echo bbp_get_form_reply_to();
     2342}
     2343
     2344        /**
     2345         * Return the value of reply to field
     2346         *
     2347         * @since bbPress (r####)
     2348         *
     2349         * @uses bbp_get_reply_id() To validate the reply to
     2350         * @uses apply_filters() Calls 'bbp_get_form_reply_to' with the reply to
     2351         * @return string Value of reply to field
     2352         */
     2353        function bbp_get_form_reply_to() {
     2354
     2355                // Set initial value
     2356                $reply_to = 0;
     2357
     2358                // Get $_REQUEST data
     2359                if ( isset( $_REQUEST['bbp_reply_to'] ) )
     2360                        $reply_to = (int) $_REQUEST['bbp_reply_to'];
     2361
     2362                // If empty, get from meta
     2363                if ( empty( $reply_to ) )
     2364                        $reply_to = bbp_get_reply_to();
     2365
     2366                // Validate
     2367                $reply_to = bbp_get_reply_id( $reply_to );
     2368
     2369                return (int) apply_filters( 'bbp_get_form_reply_to', $reply_to );
     2370        }
     2371
     2372/**
    21112373 * Output checked value of reply log edit field
    21122374 *
    21132375 * @since bbPress (r31301)
  • includes/topics/functions.php

     
    12591259                        bbp_update_reply_topic_id( $reply->ID, $destination_topic->ID                           );
    12601260                        bbp_update_reply_forum_id( $reply->ID, bbp_get_topic_forum_id( $destination_topic->ID ) );
    12611261
     1262                        // Adjust reply to values
     1263                        $reply_to = bbp_get_reply_to( $reply->ID );
     1264                        if ( empty( $reply_to ) )
     1265                                bbp_update_reply_to( $reply->ID, $source_topic->ID );
     1266
    12621267                        // Do additional actions per merged reply
    12631268                        do_action( 'bbp_merged_topic_reply', $reply->ID, $destination_topic->ID );
    12641269                }
     
    15921597                                break;
    15931598                }
    15941599
     1600                // Save reply ids
     1601                $reply_ids = array();
     1602
    15951603                // Change the post_parent of each reply to the destination topic id
    15961604                foreach ( $replies as $reply ) {
    15971605
     
    16111619                        // Update the reply
    16121620                        wp_update_post( $postarr );
    16131621
     1622                        // Gather reply ids
     1623                        $reply_ids[] = $reply->ID;
     1624
    16141625                        // Adjust reply meta values
    16151626                        bbp_update_reply_topic_id( $reply->ID, $destination_topic->ID                           );
    16161627                        bbp_update_reply_forum_id( $reply->ID, bbp_get_topic_forum_id( $destination_topic->ID ) );
    16171628
     1629                        // Adjust reply to values
     1630                        $reply_to = bbp_get_reply_to( $reply->ID );
     1631
     1632                        // Not a reply to a reply that moved over
     1633                        if ( !in_array( $reply_to, $reply_ids ) )
     1634                                bbp_update_reply_to( $reply->ID, 0 );
     1635
     1636                        // New topic from reply can't be a reply to
     1637                        if ( ( $from_reply->ID == $destination_topic->ID && $from_reply->ID == $reply_to ) )
     1638                                bbp_update_reply_to( $reply->ID, 0 );
     1639
    16181640                        // Do additional actions per split reply
    16191641                        do_action( 'bbp_split_topic_reply', $reply->ID, $destination_topic->ID );
    16201642                }
    16211643
     1644                // Remove reply to from new topic
     1645                if ( $from_reply->ID == $destination_topic->ID )
     1646                        delete_post_meta( $from_reply->ID, '_bbp_reply_to' );
     1647
    16221648                // Set the last reply ID and freshness
    16231649                $last_reply_id = $reply->ID;
    16241650                $freshness     = $reply->post_date;
  • includes/topics/template-tags.php

     
    788788        function bbp_get_topic_pagination( $args = '' ) {
    789789                global $wp_rewrite;
    790790
     791                if ( bbp_thread_replies() )
     792                        return;
     793
    791794                // Parse arguments against default values
    792795                $r = bbp_parse_args( $args, array(
    793796                        'topic_id' => bbp_get_topic_id(),
  • templates/default/bbpress/content-single-topic.php

     
    3131
    3232                <?php endif; ?>
    3333
    34                 <?php if ( bbp_has_replies() ) : ?>
     34                <?php if ( bbp_has_replies( array( 'hierarchical' => bbp_thread_replies() ) ) ) : ?>
    3535
    3636                        <?php bbp_get_template_part( 'pagination', 'replies' ); ?>
    3737
  • templates/default/bbpress/form-reply.php

     
    142142
    143143                                                <?php do_action( 'bbp_theme_before_reply_form_submit_button' ); ?>
    144144
     145                                                <?php bbp_cancel_reply_to_link(); ?>
     146
    145147                                                <button type="submit" tabindex="<?php bbp_tab_index(); ?>" id="bbp_reply_submit" name="bbp_reply_submit" class="button submit"><?php _e( 'Submit', 'bbpress' ); ?></button>
    146148
    147149                                                <?php do_action( 'bbp_theme_after_reply_form_submit_button' ); ?>
  • templates/default/bbpress/loop-replies.php

     
    3939
    4040        <li class="bbp-body">
    4141
    42                 <?php while ( bbp_replies() ) : bbp_the_reply(); ?>
     42                <?php if ( bbp_thread_replies() ) : ?>
    4343
    44                         <?php bbp_get_template_part( 'loop', 'single-reply' ); ?>
     44                        <?php bbp_list_replies(); ?>
    4545
    46                 <?php endwhile; ?>
     46                <?php else : ?>
    4747
     48                        <?php while ( bbp_replies() ) : bbp_the_reply(); ?>
     49
     50                                <?php bbp_get_template_part( 'loop', 'single-reply' ); ?>
     51
     52                        <?php endwhile; ?>
     53
     54                <?php endif; ?>
     55
    4856        </li><!-- .bbp-body -->
    4957
    5058        <li class="bbp-footer">
  • templates/default/bbpress/pagination-replies.php

     
    1212<?php do_action( 'bbp_template_before_pagination_loop' ); ?>
    1313
    1414<div class="bbp-pagination">
     15
    1516        <div class="bbp-pagination-count">
    1617
    1718                <?php bbp_topic_pagination_count(); ?>
  • templates/default/bbpress-functions.php

     
    179179                        wp_enqueue_script( 'jquery' );
    180180                }
    181181
    182                 // Topic favorite/subscribe
     182                // Topic-specific scripts
    183183                if ( bbp_is_single_topic() ) {
     184
     185                        // Topic favorite/unsubscribe
    184186                        wp_enqueue_script( 'bbpress-topic', $this->url . 'js/topic.js', array( 'jquery' ), $this->version );
     187
     188                        // Hierarchical replies
     189                        if ( bbp_thread_replies() ) {
     190                                wp_enqueue_script( 'bbpress-reply', $this->url . 'js/reply.js', array(), $this->version );
     191                        }
    185192                }
    186193
    187194                // User Profile edit
  • templates/default/css/bbpress-rtl.css

     
    6565        padding: 0;
    6666}
    6767
     68#bbpress-forums ul.children {
     69        margin-right: 2em;
     70}
     71
    6872#bbpress-forums li {
    6973        margin: 0;
    7074        list-style: none;
     
    350354        overflow-wrap: normal;
    351355}
    352356
     357/* =Reply to
     358-------------------------------------------------------------- */
     359
     360#bbpress-forums div.bbp-reply-to {
     361        margin-right: 130px;
     362        padding: 12px 0px 12px 12px;
     363        text-align: left;
     364}
     365
     366#bbpress-forums div#bbp-cancel-reply-to {
     367        text-align: left;
     368}
     369
    353370/* =Breadcrumb and Tags
    354371-------------------------------------------------------------- */
    355372
  • templates/default/css/bbpress.css

     
    6565        padding: 0;
    6666}
    6767
     68#bbpress-forums ul.children {
     69        margin-left: 2em;
     70}
     71
    6872#bbpress-forums li {
    6973        margin: 0;
    7074        list-style: none;
     
    350354        overflow-wrap: normal;
    351355}
    352356
     357/* =Reply to
     358-------------------------------------------------------------- */
     359
     360#bbpress-forums div.bbp-reply-to {
     361        margin-left: 130px;
     362        padding: 12px 12px 12px 0;
     363        text-align: right;
     364}
     365
     366#bbpress-forums div#bbp-cancel-reply-to {
     367        text-align: right;
     368}
     369
    353370/* =Breadcrumb and Tags
    354371-------------------------------------------------------------- */
    355372
  • templates/default/js/reply.js

     
     1addReply = {
     2        moveForm : function(replyId, parentId, respondId, postId) {
     3                var t = this, div, reply = t.I(replyId), respond = t.I(respondId), cancel = t.I('bbp-cancel-reply-to-link'), parent = t.I('bbp_reply_to'), post = t.I('bbp_topic_id');
     4
     5                if ( ! reply || ! respond || ! cancel || ! parent )
     6                        return;
     7
     8                t.respondId = respondId;
     9                postId = postId || false;
     10
     11                if ( ! t.I('bbp-temp-form-div') ) {
     12                        div = document.createElement('div');
     13                        div.id = 'bbp-temp-form-div';
     14                        div.style.display = 'none';
     15                        respond.parentNode.insertBefore(div, respond);
     16                }
     17
     18                reply.parentNode.insertBefore(respond);
     19                if ( post && postId )
     20                        post.value = postId;
     21                parent.value = parentId;
     22                cancel.style.display = '';
     23
     24                cancel.onclick = function() {
     25                        var t = addReply, temp = t.I('bbp-temp-form-div'), respond = t.I(t.respondId);
     26
     27                        if ( ! temp || ! respond )
     28                                return;
     29
     30                        t.I('bbp_reply_to').value = '0';
     31                        temp.parentNode.insertBefore(respond, temp);
     32                        temp.parentNode.removeChild(temp);
     33                        this.style.display = 'none';
     34                        this.onclick = null;
     35                        return false;
     36                }
     37
     38                try { t.I('bbp_reply_content').focus(); }
     39                catch(e) {}
     40
     41                return false;
     42        },
     43
     44        I : function(e) {
     45                return document.getElementById(e);
     46        }
     47}