Skip to:
Content

bbPress.org

Changeset 6246


Ignore:
Timestamp:
01/16/2017 05:22:53 PM (7 years ago)
Author:
johnjamesjacoby
Message:

Replies: Update bbp_thread_replies() to skip user profile pages.

  • Move from core/options to replies/functions, since this isn't directly an option
  • Add ! bbp_is_single_user_replies() check to force false if so
  • Update threaded replies pagination to re-include verbiage.

Fixes #3002.

Location:
trunk/src/includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/core/options.php

    r6078 r6246  
    272272
    273273/**
    274  * Are replies threaded
    275  *
    276  * @since 2.4.0 bbPress (r4944)
    277  *
    278  * @param bool $default Optional. Default value true
    279  * @uses apply_filters() Calls 'bbp_thread_replies' with the calculated value and
    280  *                        the thread replies depth
    281  * @uses get_option() To get thread replies option
    282  * @return bool Are replies threaded?
    283  */
    284 function bbp_thread_replies() {
    285     $depth  = bbp_thread_replies_depth();
    286     $allow  = bbp_allow_threaded_replies();
    287     $retval = (bool) ( ( $depth >= 2 ) && ( true === $allow ) );
    288 
    289     return (bool) apply_filters( 'bbp_thread_replies', $retval, $depth, $allow );
    290 }
    291 
    292 /**
    293274 * Are threaded replies allowed
    294275 *
  • trunk/src/includes/replies/functions.php

    r6224 r6246  
    25052505
    25062506/**
    2507  * List replies
     2507 * Are replies threaded?
     2508 *
     2509 * @since 2.4.0 bbPress (r4944)
     2510 * @since 2.6.0 bbPress (r6245) Always false on user profile reply pages
     2511 *
     2512 * @param bool $default Optional. Default value true
     2513 * @uses apply_filters() Calls 'bbp_thread_replies' with the calculated value and
     2514 *                        the thread replies depth
     2515 * @uses get_option() To get thread replies option
     2516 * @return bool Are replies threaded?
     2517 */
     2518function bbp_thread_replies() {
     2519    $depth = bbp_thread_replies_depth();
     2520    $allow = bbp_allow_threaded_replies();
     2521
     2522    // Never thread replies on user profile pages. It looks weird, and we know
     2523    // it is undesirable for the majority of installations.
     2524    if ( bbp_is_single_user_replies() ) {
     2525        $retval = false;
     2526    } else {
     2527        $retval = (bool) ( ( $depth >= 2 ) && ( true === $allow ) );
     2528    }
     2529
     2530    return (bool) apply_filters( 'bbp_thread_replies', $retval, $depth, $allow );
     2531}
     2532
     2533/**
     2534 * List threaded replies
    25082535 *
    25092536 * @since 2.4.0 bbPress (r4944)
  • trunk/src/includes/replies/template.php

    r6228 r6246  
    24372437 */
    24382438function bbp_topic_pagination_count() {
    2439     echo bbp_get_topic_pagination_count();
     2439    echo esc_html( bbp_get_topic_pagination_count() );
    24402440}
    24412441    /**
     
    24642464
    24652465        // We are threading replies
    2466         if ( bbp_thread_replies() && bbp_is_single_topic() ) {
    2467             return;
     2466        if ( bbp_thread_replies() ) {
    24682467            $walker  = new BBP_Walker_Reply;
    2469             $threads = (int) $walker->get_number_of_root_elements( $bbp->reply_query->posts );
    2470 
    2471             // Adjust for topic
    2472             $threads--;
     2468            $threads = absint( $walker->get_number_of_root_elements( $bbp->reply_query->posts ) - 1 );
    24732469            $retstr  = sprintf( _n( 'Viewing %1$s reply thread', 'Viewing %1$s reply threads', $threads, 'bbpress' ), bbp_number_format( $threads ) );
    24742470
     
    24992495
    25002496        // Filter and return
    2501         return apply_filters( 'bbp_get_topic_pagination_count', esc_html( $retstr ) );
     2497        return apply_filters( 'bbp_get_topic_pagination_count', $retstr );
    25022498    }
    25032499
Note: See TracChangeset for help on using the changeset viewer.