Skip to:
Content

bbPress.org


Ignore:
Timestamp:
11/16/2025 10:43:01 PM (3 months ago)
Author:
johnjamesjacoby
Message:

Tools - Code Improvement: Updates to the phpcs.xml.dist config file.

This commit implements the WordPress.WP.I18n.MissingTranslatorsComment code sniff, fixes a bunch of whitespace regressions from #3614 and #3613.

Props johnjamesjacoby, sirlouen.

In trunk, for 2.7.

Fixes #3615.

File:
1 edited

Legend:

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

    r7359 r7360  
    2222    echo bbp_get_reply_post_type();
    2323}
    24     /**
    25      * Return the unique id of the custom post type for replies
    26      *
    27      * @since 2.0.0 bbPress (r2857)
    28      *
    29      *                        post type id
    30      * @return string The unique reply post type id
    31      */
    32     function bbp_get_reply_post_type() {
     24
     25/**
     26 * Return the unique id of the custom post type for replies
     27 *
     28 * @since 2.0.0 bbPress (r2857)
     29 *
     30 *                        post type id
     31 * @return string The unique reply post type id
     32 */
     33function bbp_get_reply_post_type() {
    3334
    3435    // Filter & return
    3536    return apply_filters( 'bbp_get_reply_post_type', bbpress()->reply_post_type );
    36     }
     37}
    3738
    3839/**
     
    302303    echo bbp_get_reply_id( $reply_id );
    303304}
    304     /**
    305      * Return the id of the reply in a replies loop
    306      *
    307      * @since 2.0.0 bbPress (r2553)
    308      *
    309      * @param $reply_id Optional. Used to check emptiness
    310      * @return int The reply id
    311      */
    312     function bbp_get_reply_id( $reply_id = 0 ) {
     305
     306/**
     307 * Return the id of the reply in a replies loop
     308 *
     309 * @since 2.0.0 bbPress (r2553)
     310 *
     311 * @param $reply_id Optional. Used to check emptiness
     312 * @return int The reply id
     313 */
     314function bbp_get_reply_id( $reply_id = 0 ) {
    313315    $bbp      = bbpress();
    314316    $wp_query = bbp_get_wp_query();
     
    318320        $bbp_reply_id = $reply_id;
    319321
    320         // Currently inside a replies loop
    321         } elseif ( ! empty( $bbp->reply_query->in_the_loop ) && isset( $bbp->reply_query->post->ID ) ) {
     322    // Currently inside a replies loop
     323    } elseif ( ! empty( $bbp->reply_query->in_the_loop ) && isset( $bbp->reply_query->post->ID ) ) {
    322324        $bbp_reply_id = $bbp->reply_query->post->ID;
    323325
    324         // Currently inside a search loop
    325         } elseif ( ! empty( $bbp->search_query->in_the_loop ) && isset( $bbp->search_query->post->ID ) && bbp_is_reply( $bbp->search_query->post->ID ) ) {
     326    // Currently inside a search loop
     327    } elseif ( ! empty( $bbp->search_query->in_the_loop ) && isset( $bbp->search_query->post->ID ) && bbp_is_reply( $bbp->search_query->post->ID ) ) {
    326328        $bbp_reply_id = $bbp->search_query->post->ID;
    327329
    328         // Currently viewing a forum
    329         } elseif ( ( bbp_is_single_reply() || bbp_is_reply_edit() ) && ! empty( $bbp->current_reply_id ) ) {
     330    // Currently viewing a forum
     331    } elseif ( ( bbp_is_single_reply() || bbp_is_reply_edit() ) && ! empty( $bbp->current_reply_id ) ) {
    330332        $bbp_reply_id = $bbp->current_reply_id;
    331333
    332         // Currently viewing a reply
    333         } elseif ( ( bbp_is_single_reply() || bbp_is_reply_edit() ) && isset( $wp_query->post->ID ) ) {
     334    // Currently viewing a reply
     335    } elseif ( ( bbp_is_single_reply() || bbp_is_reply_edit() ) && isset( $wp_query->post->ID ) ) {
    334336        $bbp_reply_id = $wp_query->post->ID;
    335337
    336         // Fallback
    337         } else {
     338    // Fallback
     339    } else {
    338340        $bbp_reply_id = 0;
    339         }
     341    }
    340342
    341343    // Filter & return
    342344    return (int) apply_filters( 'bbp_get_reply_id', $bbp_reply_id, $reply_id );
    343     }
     345}
    344346
    345347/**
     
    397399    echo esc_url( bbp_get_reply_permalink( $reply_id ) );
    398400}
    399     /**
    400      * Return the link to the reply
    401      *
    402      * @since 2.0.0 bbPress (r2553)
    403      *
    404      * @param int $reply_id Optional. Reply id
    405      *
    406      * @return string Permanent link to reply
    407      */
    408     function bbp_get_reply_permalink( $reply_id = 0 ) {
     401
     402/**
     403 * Return the link to the reply
     404 *
     405 * @since 2.0.0 bbPress (r2553)
     406 *
     407 * @param int $reply_id Optional. Reply id
     408 *
     409 * @return string Permanent link to reply
     410 */
     411function bbp_get_reply_permalink( $reply_id = 0 ) {
    409412    $reply_id = bbp_get_reply_id( $reply_id );
    410413
    411414    // Filter & return
    412415    return apply_filters( 'bbp_get_reply_permalink', get_permalink( $reply_id ), $reply_id );
    413     }
     416}
    414417
    415418/**
     
    423426    echo esc_url( bbp_get_reply_url( $reply_id ) );
    424427}
    425     /**
    426      * Return the paginated url to the reply in the reply loop
    427      *
    428      * @since 2.0.0 bbPress (r2679)
    429      *
    430      * @param int $reply_id Optional. Reply id
    431      * @param string $redirect_to Optional. Pass a redirect value for use with
    432      *                              shortcodes and other fun things.
    433      * @return string Link to reply relative to paginated topic
    434      */
    435     function bbp_get_reply_url( $reply_id = 0, $redirect_to = '' ) {
     428
     429/**
     430 * Return the paginated url to the reply in the reply loop
     431 *
     432 * @since 2.0.0 bbPress (r2679)
     433 *
     434 * @param int $reply_id Optional. Reply id
     435 * @param string $redirect_to Optional. Pass a redirect value for use with
     436 *                              shortcodes and other fun things.
     437 * @return string Link to reply relative to paginated topic
     438 */
     439function bbp_get_reply_url( $reply_id = 0, $redirect_to = '' ) {
    436440
    437441    // Set needed variables
     
    443447        $topic_id = bbp_get_reply_topic_id( $reply_id );
    444448        $topic    = bbp_get_topic( $topic_id );
    445         } elseif ( bbp_is_topic( $reply_id ) ) {
     449    } elseif ( bbp_is_topic( $reply_id ) ) {
    446450        $topic_id = bbp_get_topic_id( $reply_id );
    447451        $topic    = bbp_get_topic( $topic_id );
    448452        $reply_id = $topic_id;
    449         }
     453    }
    450454
    451455    // Hierarchical reply page
     
    453457        $reply_page = 1;
    454458
    455         // Standard reply page
    456         } else {
     459    // Standard reply page
     460    } else {
    457461        $reply_page = ceil( (int) bbp_get_reply_position( $reply_id, $topic_id ) / (int) bbp_get_replies_per_page() );
    458         }
     462    }
    459463
    460464    // Get links & URLS
     
    475479            $url = user_trailingslashit( $topic_url ) . $reply_hash;
    476480
    477             // Unpretty links
    478             } else {
     481        // Unpretty links
     482        } else {
    479483            $url = $topic_url . $reply_hash;
    480             }
    481 
    482         // Include pagination
    483         } else {
     484        }
     485
     486    // Include pagination
     487    } else {
    484488
    485489        // Pretty permalinks
     
    488492            $url = user_trailingslashit( $url ) . $reply_hash;
    489493
    490             // Unpretty links
    491             } else {
     494        // Unpretty links
     495        } else {
    492496            $url = add_query_arg( 'paged', $reply_page, $topic_url ) . $reply_hash;
    493             }
    494497        }
     498    }
    495499
    496500    // Add topic view query arg back to end if it is set
    497501    if ( bbp_get_view_all() ) {
    498502        $url = bbp_add_view_all( $url );
    499         }
     503    }
    500504
    501505    // Filter & return
    502506    return apply_filters( 'bbp_get_reply_url', $url, $reply_id, $redirect_to );
    503     }
     507}
    504508
    505509/**
     
    514518}
    515519
    516     /**
    517     * Return the title of the reply
    518     *
    519     * @since 2.0.0 bbPress (r2553)
    520     *
    521     * @param int $reply_id Optional. Reply id
    522     * @return string Title of reply
    523     */
    524     function bbp_get_reply_title( $reply_id = 0 ) {
     520/**
     521 * Return the title of the reply
     522 *
     523 * @since 2.0.0 bbPress (r2553)
     524 *
     525 * @param int $reply_id Optional. Reply id
     526 * @return string Title of reply
     527 */
     528function bbp_get_reply_title( $reply_id = 0 ) {
    525529    $reply_id = bbp_get_reply_id( $reply_id );
    526530    $title    = get_post_field( 'post_title', $reply_id );
     
    529533    // Filter & return
    530534    return apply_filters( 'bbp_get_reply_title', $title, $reply_id );
    531     }
    532 
    533     /**
    534     * Get empty reply title fallback.
    535     *
    536     * @since 2.5.0 bbPress (r5177)
    537     *
    538     * @param string $post_title Required. Reply Title
    539     * @param int $post_id Required. Reply ID
    540     * @return string Title of reply
    541     */
    542     function bbp_get_reply_title_fallback( $post_title = '', $post_id = 0 ) {
     535}
     536
     537/**
     538 * Get empty reply title fallback.
     539 *
     540 * @since 2.5.0 bbPress (r5177)
     541 *
     542 * @param string $post_title Required. Reply Title
     543 * @param int $post_id Required. Reply ID
     544 * @return string Title of reply
     545 */
     546function bbp_get_reply_title_fallback( $post_title = '', $post_id = 0 ) {
    543547
    544548    // Bail if title not empty, or post is not a reply
    545549    if ( ! empty( $post_title ) || ! bbp_is_reply( $post_id ) ) {
    546550        return $post_title;
    547         }
     551    }
    548552
    549553    // Get reply topic title.
     
    551555
    552556    // Get empty reply title fallback.
    553     $reply_title = sprintf( esc_html__( 'Reply To: %s', 'bbpress' ), $topic_title );
     557    $reply_title = sprintf(
     558        /* translators: %s: Topic title */
     559        esc_html__( 'Reply To: %s', 'bbpress' ),
     560        $topic_title
     561    );
    554562
    555563    // Filter & return
    556564    return apply_filters( 'bbp_get_reply_title_fallback', $reply_title, $post_id, $topic_title );
    557     }
     565}
    558566
    559567/**
     
    567575    echo bbp_get_reply_content( $reply_id );
    568576}
    569     /**
    570      * Return the content of the reply
    571      *
    572      * @since 2.0.0 bbPress (r2780)
    573      *
    574      * @param int $reply_id Optional. reply id
    575      * @return string Content of the reply
    576      */
    577     function bbp_get_reply_content( $reply_id = 0 ) {
     577
     578/**
     579 * Return the content of the reply
     580 *
     581 * @since 2.0.0 bbPress (r2780)
     582 *
     583 * @param int $reply_id Optional. reply id
     584 * @return string Content of the reply
     585 */
     586function bbp_get_reply_content( $reply_id = 0 ) {
    578587    $reply_id = bbp_get_reply_id( $reply_id );
    579588
     
    581590    if ( post_password_required( $reply_id ) ) {
    582591        return get_the_password_form();
    583         }
     592    }
    584593
    585594    $content = get_post_field( 'post_content', $reply_id );
     
    587596    // Filter & return
    588597    return apply_filters( 'bbp_get_reply_content', $content, $reply_id );
    589     }
     598}
    590599
    591600/**
     
    600609    echo bbp_get_reply_excerpt( $reply_id, $length );
    601610}
    602     /**
    603      * Return the excerpt of the reply
    604      *
    605      * @since 2.0.0 bbPress (r2751)
    606      *
    607      * @param int $reply_id Optional. Reply id
    608      * @param int $length Optional. Length of the excerpt. Defaults to 100
    609      *                     letters
    610      * @return string Reply Excerpt
    611      */
    612     function bbp_get_reply_excerpt( $reply_id = 0, $length = 100 ) {
     611
     612/**
     613 * Return the excerpt of the reply
     614 *
     615 * @since 2.0.0 bbPress (r2751)
     616 *
     617 * @param int $reply_id Optional. Reply id
     618 * @param int $length Optional. Length of the excerpt. Defaults to 100
     619 *                     letters
     620 * @return string Reply Excerpt
     621 */
     622function bbp_get_reply_excerpt( $reply_id = 0, $length = 100 ) {
    613623    $reply_id = bbp_get_reply_id( $reply_id );
    614624    $length   = (int) $length;
     
    617627    if ( empty( $excerpt ) ) {
    618628        $excerpt = bbp_get_reply_content( $reply_id );
    619         }
    620 
    621     $excerpt = trim ( strip_tags( $excerpt ) );
     629    }
     630
     631    $excerpt = trim( strip_tags( $excerpt ) );
    622632
    623633    // Multibyte support
    624634    if ( function_exists( 'mb_strlen' ) ) {
    625635        $excerpt_length = mb_strlen( $excerpt );
    626         } else {
     636    } else {
    627637        $excerpt_length = strlen( $excerpt );
    628         }
     638    }
    629639
    630640    if ( ! empty( $length ) && ( $excerpt_length > $length ) ) {
    631641        $excerpt  = mb_substr( $excerpt, 0, $length - 1 );
    632642        $excerpt .= '…';
    633         }
     643    }
    634644
    635645    // Filter & return
    636646    return apply_filters( 'bbp_get_reply_excerpt', $excerpt, $reply_id, $length );
    637     }
     647}
    638648
    639649/**
     
    649659    echo bbp_get_reply_post_date( $reply_id, $humanize, $gmt );
    650660}
    651     /**
    652      * Return the post date and time of a reply
    653      *
    654      * @since 2.2.0 bbPress (r4155)
    655      *
    656      * @param int $reply_id Optional. Reply id.
    657      * @param bool $humanize Optional. Humanize output using time_since
    658      * @param bool $gmt Optional. Use GMT
    659      * @return string
    660      */
    661     function bbp_get_reply_post_date( $reply_id = 0, $humanize = false, $gmt = false ) {
     661
     662/**
     663 * Return the post date and time of a reply
     664 *
     665 * @since 2.2.0 bbPress (r4155)
     666 *
     667 * @param int $reply_id Optional. Reply id.
     668 * @param bool $humanize Optional. Humanize output using time_since
     669 * @param bool $gmt Optional. Use GMT
     670 * @return string
     671 */
     672function bbp_get_reply_post_date( $reply_id = 0, $humanize = false, $gmt = false ) {
    662673    $reply_id = bbp_get_reply_id( $reply_id );
    663674
     
    669680        $result = bbp_get_time_since( $date );
    670681
    671         // August 4, 2012 at 2:37 pm
    672         } else {
     682    // August 4, 2012 at 2:37 pm
     683    } else {
    673684        $date   = get_post_time( get_option( 'date_format' ), $gmt, $reply_id, true );
    674685        $time   = get_post_time( get_option( 'time_format' ), $gmt, $reply_id, true );
     686        /* translators: 1: Date, 2: Time */
    675687        $result = sprintf( _x( '%1$s at %2$s', 'date at time', 'bbpress' ), $date, $time );
    676         }
     688    }
    677689
    678690    // Filter & return
    679691    return apply_filters( 'bbp_get_reply_post_date', $result, $reply_id, $humanize, $gmt, $date, $time );
    680     }
     692}
    681693
    682694/**
     
    713725    echo bbp_get_reply_revision_log( $reply_id );
    714726}
    715     /**
    716      * Return the formatted revision log of the reply
    717      *
    718      * @since 2.0.0 bbPress (r2782)
    719      *
    720      * @param int $reply_id Optional. Reply id
    721      * @return string Revision log of the reply
    722      */
    723     function bbp_get_reply_revision_log( $reply_id = 0 ) {
     727
     728/**
     729 * Return the formatted revision log of the reply
     730 *
     731 * @since 2.0.0 bbPress (r2782)
     732 *
     733 * @param int $reply_id Optional. Reply id
     734 * @return string Revision log of the reply
     735 */
     736function bbp_get_reply_revision_log( $reply_id = 0 ) {
    724737
    725738    // Create necessary variables
     
    729742    if ( bbp_is_topic( $reply_id ) ) {
    730743        return bbp_get_topic_revision_log( $reply_id );
    731         }
     744    }
    732745
    733746    // Get the reply revision log (out of post meta
     
    737750    if ( empty( $reply_id ) || empty( $revision_log ) || ! is_array( $revision_log ) ) {
    738751        return false;
    739         }
     752    }
    740753
    741754    // Get the actual revisions
     
    743756    if ( empty( $revisions ) ) {
    744757        return false;
    745         }
     758    }
    746759
    747760    $r = "\n\n" . '<ul id="bbp-reply-revision-log-' . esc_attr( $reply_id ) . '" class="bbp-reply-revision-log">' . "\n\n";
     
    753766            $author_id = $revision->post_author;
    754767            $reason    = '';
    755             } else {
     768        } else {
    756769            $author_id = $revision_log[ $revision->ID ]['author'];
    757770            $reason    = $revision_log[ $revision->ID ]['reason'];
    758             }
     771        }
    759772
    760773        $author = bbp_get_author_link( array( 'size' => 14, 'link_text' => bbp_get_reply_author_display_name( $revision->ID ), 'post_id' => $revision->ID ) );
     
    763776        $r .= "\t" . '<li id="bbp-reply-revision-log-' . esc_attr( $reply_id ) . '-item-' . esc_attr( $revision->ID ) . '" class="bbp-reply-revision-log-item">' . "\n";
    764777        if ( ! empty( $reason ) ) {
     778            /* translators: 1: Time since modification, 2: Author linked display name, 3: Modification reason */
    765779            $r .= "\t\t" . sprintf( esc_html__( 'This reply was modified %1$s by %2$s. Reason: %3$s', 'bbpress' ), esc_html( $since ), $author, esc_html( $reason ) ) . "\n";
    766             } else {
     780        } else {
     781            /* translators: 1: Time since modification, 2: Author linked display name */
    767782            $r .= "\t\t" . sprintf( esc_html__( 'This reply was modified %1$s by %2$s.', 'bbpress' ), esc_html( $since ), $author ) . "\n";
    768             }
     783        }
     784
    769785        $r .= "\t" . '</li>' . "\n";
    770 
    771         }
     786    }
    772787
    773788    $r .= "\n" . '</ul>' . "\n\n";
     
    775790    // Filter & return
    776791    return apply_filters( 'bbp_get_reply_revision_log', $r, $reply_id );
    777     }
    778         /**
    779          * Return the raw revision log of the reply
    780          *
    781          * @since 2.0.0 bbPress (r2782)
    782          *
    783          * @param int $reply_id Optional. Reply id
    784          * @return string Raw revision log of the reply
    785          */
    786         function bbp_get_reply_raw_revision_log( $reply_id = 0 ) {
     792}
     793
     794/**
     795 * Return the raw revision log of the reply
     796 *
     797 * @since 2.0.0 bbPress (r2782)
     798 *
     799 * @param int $reply_id Optional. Reply id
     800 * @return string Raw revision log of the reply
     801 */
     802function bbp_get_reply_raw_revision_log( $reply_id = 0 ) {
    787803    $reply_id     = bbp_get_reply_id( $reply_id );
    788804    $revision_log = get_post_meta( $reply_id, '_bbp_revision_log', true );
    789805    $revision_log = ! empty( $revision_log )
    790 ? $revision_log
    791 : array();
     806        ? $revision_log
     807        : array();
    792808
    793809    // Filter & return
    794810    return apply_filters( 'bbp_get_reply_raw_revision_log', $revision_log, $reply_id );
    795         }
     811}
    796812
    797813/**
     
    840856    echo bbp_get_reply_status( $reply_id );
    841857}
    842     /**
    843      * Return the status of the reply
    844      *
    845      * @since 2.0.0 bbPress (r2667)
    846      *
    847      * @param int $reply_id Optional. Reply id
    848      * @return string Status of reply
    849      */
    850     function bbp_get_reply_status( $reply_id = 0 ) {
     858
     859/**
     860 * Return the status of the reply
     861 *
     862 * @since 2.0.0 bbPress (r2667)
     863 *
     864 * @param int $reply_id Optional. Reply id
     865 * @return string Status of reply
     866 */
     867function bbp_get_reply_status( $reply_id = 0 ) {
    851868    $reply_id = bbp_get_reply_id( $reply_id );
    852869
    853870    // Filter & return
    854871    return apply_filters( 'bbp_get_reply_status', get_post_status( $reply_id ), $reply_id );
    855     }
     872}
    856873
    857874/**
     
    10021019 */
    10031020function bbp_reply_author( $reply_id = 0 ) {
    1004     echo bbp_get_reply_author( $reply_id );
    1005 }
    1006     /**
    1007      * Deprecated. Use bbp_get_reply_author_display_name() instead.
    1008      *
    1009      * Return the author of the reply
    1010      *
    1011      * @since 2.0.0 bbPress (r2667)
    1012      *
    1013      * @deprecated 2.5.0 bbPress (r5119)
    1014      *
    1015      * @param int $reply_id Optional. Reply id
    1016      * @return string Author of reply
    1017      */
    1018     function bbp_get_reply_author( $reply_id = 0 ) {
     1021    echo bbp_get_reply_author_display_name( $reply_id );
     1022}
     1023
     1024/**
     1025 * Deprecated. Use bbp_get_reply_author_display_name() instead.
     1026 *
     1027 * Return the author of the reply
     1028 *
     1029 * @since 2.0.0 bbPress (r2667)
     1030 *
     1031 * @deprecated 2.5.0 bbPress (r5119)
     1032 *
     1033 * @param int $reply_id Optional. Reply id
     1034 * @return string Author of reply
     1035 */
     1036function bbp_get_reply_author( $reply_id = 0 ) {
    10191037    $reply_id = bbp_get_reply_id( $reply_id );
    10201038
    10211039    if ( ! bbp_is_reply_anonymous( $reply_id ) ) {
    10221040        $author = get_the_author_meta( 'display_name', bbp_get_reply_author_id( $reply_id ) );
    1023         } else {
     1041    } else {
    10241042        $author = get_post_meta( $reply_id, '_bbp_anonymous_name', true );
    1025         }
     1043    }
    10261044
    10271045    // Filter & return
    10281046    return apply_filters( 'bbp_get_reply_author', $author, $reply_id );
    1029     }
     1047}
    10301048
    10311049/**
     
    10391057    echo bbp_get_reply_author_id( $reply_id );
    10401058}
    1041     /**
    1042      * Return the author ID of the reply
    1043      *
    1044      * @since 2.0.0 bbPress (r2667)
    1045      *
    1046      * @param int $reply_id Optional. Reply id
    1047      * @return string Author id of reply
    1048      */
    1049     function bbp_get_reply_author_id( $reply_id = 0 ) {
     1059
     1060/**
     1061 * Return the author ID of the reply
     1062 *
     1063 * @since 2.0.0 bbPress (r2667)
     1064 *
     1065 * @param int $reply_id Optional. Reply id
     1066 * @return string Author id of reply
     1067 */
     1068function bbp_get_reply_author_id( $reply_id = 0 ) {
    10501069    $reply_id  = bbp_get_reply_id( $reply_id );
    10511070    $author_id = get_post_field( 'post_author', $reply_id );
     
    10531072    // Filter & return
    10541073    return (int) apply_filters( 'bbp_get_reply_author_id', $author_id, $reply_id );
    1055     }
     1074}
    10561075
    10571076/**
     
    10651084    echo bbp_get_reply_author_display_name( $reply_id );
    10661085}
    1067     /**
    1068      * Return the author display_name of the reply
    1069      *
    1070      * @since 2.0.0 bbPress (r2667)
    1071      *
    1072      * @param int $reply_id Optional. Reply id
    1073      * @return string The display name of the author of the reply
    1074      */
    1075     function bbp_get_reply_author_display_name( $reply_id = 0 ) {
     1086
     1087/**
     1088 * Return the author display_name of the reply
     1089 *
     1090 * @since 2.0.0 bbPress (r2667)
     1091 *
     1092 * @param int $reply_id Optional. Reply id
     1093 * @return string The display name of the author of the reply
     1094 */
     1095function bbp_get_reply_author_display_name( $reply_id = 0 ) {
    10761096    $reply_id = bbp_get_reply_id( $reply_id );
    10771097
     
    10881108        if ( empty( $author_name ) ) {
    10891109            $author_name = get_the_author_meta( 'user_login', $author_id );
    1090             }
    1091 
    1092         // User does not have an account
    1093         } else {
     1110        }
     1111
     1112    // User does not have an account
     1113    } else {
    10941114        $author_name = get_post_meta( $reply_id, '_bbp_anonymous_name', true );
    1095         }
     1115    }
    10961116
    10971117    // Fallback if nothing could be found
    10981118    if ( empty( $author_name ) ) {
    10991119        $author_name = bbp_get_fallback_display_name( $reply_id );
    1100         }
     1120    }
    11011121
    11021122    // Filter & return
    11031123    return apply_filters( 'bbp_get_reply_author_display_name', $author_name, $reply_id );
    1104     }
     1124}
    11051125
    11061126/**
     
    11151135    echo bbp_get_reply_author_avatar( $reply_id, $size );
    11161136}
    1117     /**
    1118      * Return the author avatar of the reply
    1119      *
    1120      * @since 2.0.0 bbPress (r2667)
    1121      *
    1122      * @param int $reply_id Optional. Reply id
    1123      * @param int $size Optional. Size of the avatar. Defaults to 40
    1124      * @return string Avatar of author of the reply
    1125      */
    1126     function bbp_get_reply_author_avatar( $reply_id = 0, $size = 40 ) {
     1137
     1138/**
     1139 * Return the author avatar of the reply
     1140 *
     1141 * @since 2.0.0 bbPress (r2667)
     1142 *
     1143 * @param int $reply_id Optional. Reply id
     1144 * @param int $size Optional. Size of the avatar. Defaults to 40
     1145 * @return string Avatar of author of the reply
     1146 */
     1147function bbp_get_reply_author_avatar( $reply_id = 0, $size = 40 ) {
    11271148    $reply_id = bbp_get_reply_id( $reply_id );
     1149
    11281150    if ( ! empty( $reply_id ) ) {
     1151
    11291152        // Check for anonymous user
    11301153        if ( ! bbp_is_reply_anonymous( $reply_id ) ) {
    11311154            $author_avatar = get_avatar( bbp_get_reply_author_id( $reply_id ), $size );
    1132             } else {
     1155        } else {
    11331156            $author_avatar = get_avatar( get_post_meta( $reply_id, '_bbp_anonymous_email', true ), $size );
    1134             }
    1135         } else {
     1157        }
     1158    } else {
    11361159        $author_avatar = '';
    1137         }
     1160    }
    11381161
    11391162    // Filter & return
    11401163    return apply_filters( 'bbp_get_reply_author_avatar', $author_avatar, $reply_id, $size );
    1141     }
     1164}
    11421165
    11431166/**
     
    11511174    echo bbp_get_reply_author_link( $args );
    11521175}
    1153     /**
    1154      * Return the author link of the reply
    1155      *
    1156      * @since 2.0.0 bbPress (r2717)
    1157      *
    1158      * @param array $args Optional. If an integer, it is used as reply id.
    1159      * @return string Author link of reply
    1160      */
    1161     function bbp_get_reply_author_link( $args = array() ) {
     1176
     1177/**
     1178 * Return the author link of the reply
     1179 *
     1180 * @since 2.0.0 bbPress (r2717)
     1181 *
     1182 * @param array $args Optional. If an integer, it is used as reply id.
     1183 * @return string Author link of reply
     1184 */
     1185function bbp_get_reply_author_link( $args = array() ) {
    11621186
    11631187    // Parse arguments against default values
    11641188    $r = bbp_parse_args( $args, array(
    1165     'post_id'    => 0,
    1166     'link_title' => '',
    1167     'type'       => 'both',
    1168     'size'       => 80,
    1169     'sep'        => '',
    1170     'show_role'  => false
     1189        'post_id'    => 0,
     1190        'link_title' => '',
     1191        'type'       => 'both',
     1192        'size'       => 80,
     1193        'sep'        => '',
     1194        'show_role'  => false
    11711195    ), 'get_reply_author_link' );
    11721196
    1173 // Default return value
    1174 $author_link = '';
    1175 
    1176 // Used as reply_id
    1177 $reply_id = is_numeric( $args )
    1178 ? bbp_get_reply_id( $args )
    1179 : bbp_get_reply_id( $r['post_id'] );
    1180 
    1181 // Reply ID is good
    1182 if ( ! empty( $reply_id ) ) {
    1183 
    1184     // Get some useful reply information
    1185     $author_url = bbp_get_reply_author_url( $reply_id );
    1186     $anonymous  = bbp_is_reply_anonymous( $reply_id );
    1187 
    1188     // Tweak link title if empty
    1189     if ( empty( $r['link_title'] ) ) {
    1190         $author = bbp_get_reply_author_display_name( $reply_id );
    1191         $title  = empty( $anonymous )
    1192             ? esc_attr__( "View %s's profile",  'bbpress' )
    1193             : esc_attr__( "Visit %s's website", 'bbpress' );
    1194 
    1195         $link_title = sprintf( $title, $author );
     1197    // Default return value
     1198    $author_link = '';
     1199
     1200    // Used as reply_id
     1201    $reply_id = is_numeric( $args )
     1202        ? bbp_get_reply_id( $args )
     1203        : bbp_get_reply_id( $r['post_id'] );
     1204
     1205    // Reply ID is good
     1206    if ( ! empty( $reply_id ) ) {
     1207
     1208        // Get some useful reply information
     1209        $author_url = bbp_get_reply_author_url( $reply_id );
     1210        $anonymous  = bbp_is_reply_anonymous( $reply_id );
     1211
     1212        // Tweak link title if empty
     1213        if ( empty( $r['link_title'] ) ) {
     1214            $author = bbp_get_reply_author_display_name( $reply_id );
     1215            $title  = empty( $anonymous )
     1216                /* translators: %s: Author's display name */
     1217                ? esc_attr__( "View %s's profile",  'bbpress' )
     1218                /* translators: %s: Author's display name */
     1219                : esc_attr__( "Visit %s's website", 'bbpress' );
     1220
     1221            $link_title = sprintf( $title, $author );
    11961222
    11971223        // Use what was passed if not
    11981224        } else {
    1199         $link_title = $r['link_title'];
     1225            $link_title = $r['link_title'];
    12001226        }
    12011227
    1202     // Setup title and author_links array
    1203     $author_links = array();
    1204     $link_title   = ! empty( $link_title )
    1205         ? ' title="' . esc_attr( $link_title ) . '"'
    1206         : '';
    1207 
    1208     // Get avatar (unescaped, because HTML)
    1209     if ( ( 'avatar' === $r['type'] ) || ( 'both' === $r['type'] ) ) {
    1210         $author_links['avatar'] = bbp_get_reply_author_avatar( $reply_id, $r['size'] );
     1228        // Setup title and author_links array
     1229        $author_links = array();
     1230        $link_title   = ! empty( $link_title )
     1231            ? ' title="' . esc_attr( $link_title ) . '"'
     1232            : '';
     1233
     1234        // Get avatar (unescaped, because HTML)
     1235        if ( ( 'avatar' === $r['type'] ) || ( 'both' === $r['type'] ) ) {
     1236            $author_links['avatar'] = bbp_get_reply_author_avatar( $reply_id, $r['size'] );
    12111237        }
    12121238
    1213     // Get display name (escaped, because never HTML)
    1214     if ( ( 'name' === $r['type'] ) || ( 'both' === $r['type'] ) ) {
    1215         $author_links['name'] = esc_html( bbp_get_reply_author_display_name( $reply_id ) );
     1239        // Get display name (escaped, because never HTML)
     1240        if ( ( 'name' === $r['type'] ) || ( 'both' === $r['type'] ) ) {
     1241            $author_links['name'] = esc_html( bbp_get_reply_author_display_name( $reply_id ) );
    12161242        }
    12171243
    1218     // Empty array
    1219     $links  = array();
    1220     $sprint = '<span %1$s>%2$s</span>';
    1221 
    1222     // Wrap each link
    1223     foreach ( $author_links as $link => $link_text ) {
    1224         $link_class = ' class="bbp-author-' . esc_attr( $link ) . '"';
    1225         $links[]    = sprintf( $sprint, $link_class, $link_text );
     1244        // Empty array
     1245        $links  = array();
     1246        $sprint = '<span %1$s>%2$s</span>';
     1247
     1248        // Wrap each link
     1249        foreach ( $author_links as $link => $link_text ) {
     1250            $link_class = ' class="bbp-author-' . esc_attr( $link ) . '"';
     1251            $links[]    = sprintf( $sprint, $link_class, $link_text );
    12261252        }
    12271253
    1228     // Juggle
    1229     $author_links = $links;
    1230     unset( $links );
    1231 
    1232     // Filter sections
    1233     $sections    = apply_filters( 'bbp_get_reply_author_links', $author_links, $r, $args );
    1234 
    1235     // Assemble sections into author link
    1236     $author_link = implode( $r['sep'], $sections );
    1237 
    1238     // Only wrap in link if profile exists
    1239     if ( empty( $anonymous ) && bbp_user_has_profile( bbp_get_reply_author_id( $reply_id ) ) ) {
    1240         $author_link = sprintf( '<a href="%1$s"%2$s%3$s>%4$s</a>', esc_url( $author_url ), $link_title, ' class="bbp-author-link"', $author_link );
     1254        // Juggle
     1255        $author_links = $links;
     1256        unset( $links );
     1257
     1258        // Filter sections
     1259        $sections    = apply_filters( 'bbp_get_reply_author_links', $author_links, $r, $args );
     1260
     1261        // Assemble sections into author link
     1262        $author_link = implode( $r['sep'], $sections );
     1263
     1264        // Only wrap in link if profile exists
     1265        if ( empty( $anonymous ) && bbp_user_has_profile( bbp_get_reply_author_id( $reply_id ) ) ) {
     1266            $author_link = sprintf( '<a href="%1$s"%2$s%3$s>%4$s</a>', esc_url( $author_url ), $link_title, ' class="bbp-author-link"', $author_link );
    12411267        }
    12421268
    1243     // Role is not linked
    1244     if ( true === $r['show_role'] ) {
    1245         $author_link .= bbp_get_reply_author_role( array( 'reply_id' => $reply_id ) );
     1269        // Role is not linked
     1270        if ( true === $r['show_role'] ) {
     1271            $author_link .= bbp_get_reply_author_role( array( 'reply_id' => $reply_id ) );
    12461272        }
    12471273    }
    12481274
    1249 // Filter & return
    1250 return apply_filters( 'bbp_get_reply_author_link', $author_link, $r, $args );
    1251     }
     1275    // Filter & return
     1276    return apply_filters( 'bbp_get_reply_author_link', $author_link, $r, $args );
     1277}
    12521278
    12531279/**
     
    12611287    echo esc_url( bbp_get_reply_author_url( $reply_id ) );
    12621288}
    1263     /**
    1264      * Return the author url of the reply
    1265      *
    1266      * @since 2.0.0 bbPress (r2667)
    1267      *
    1268      * @param int $reply_id Optional. Reply id
    1269      * @return string Author URL of the reply
    1270      */
    1271     function bbp_get_reply_author_url( $reply_id = 0 ) {
     1289
     1290/**
     1291 * Return the author url of the reply
     1292 *
     1293 * @since 2.0.0 bbPress (r2667)
     1294 *
     1295 * @param int $reply_id Optional. Reply id
     1296 * @return string Author URL of the reply
     1297 */
     1298function bbp_get_reply_author_url( $reply_id = 0 ) {
    12721299    $reply_id = bbp_get_reply_id( $reply_id );
    12731300
     
    12751302    if ( ! bbp_is_reply_anonymous( $reply_id ) && bbp_user_has_profile( bbp_get_reply_author_id( $reply_id ) ) ) {
    12761303        $author_url = bbp_get_user_profile_url( bbp_get_reply_author_id( $reply_id ) );
    1277         } else {
     1304    } else {
    12781305        $author_url = get_post_meta( $reply_id, '_bbp_anonymous_website', true );
     1306
    12791307        if ( empty( $author_url ) ) {
    12801308            $author_url = '';
    1281             }
    12821309        }
     1310    }
    12831311
    12841312    // Filter & return
    12851313    return apply_filters( 'bbp_get_reply_author_url', $author_url, $reply_id );
    1286     }
     1314}
    12871315
    12881316/**
     
    12961324    echo bbp_get_reply_author_email( $reply_id );
    12971325}
    1298     /**
    1299      * Return the reply author email address
    1300      *
    1301      * @since 2.0.0 bbPress (r3445)
    1302      *
    1303      * @param int $reply_id Optional. Reply id
    1304      * @return string Reply author email address
    1305      */
    1306     function bbp_get_reply_author_email( $reply_id = 0 ) {
     1326
     1327/**
     1328 * Return the reply author email address
     1329 *
     1330 * @since 2.0.0 bbPress (r3445)
     1331 *
     1332 * @param int $reply_id Optional. Reply id
     1333 * @return string Reply author email address
     1334 */
     1335function bbp_get_reply_author_email( $reply_id = 0 ) {
    13071336    $reply_id = bbp_get_reply_id( $reply_id );
    13081337
     
    13151344        $author_email = ! empty( $user->user_email ) ? $user->user_email : '';
    13161345
    1317         // Anonymous
    1318         } else {
     1346    // Anonymous
     1347    } else {
    13191348
    13201349        // Get email from post meta
     
    13241353        if ( empty( $author_email ) ) {
    13251354            $author_email = '';
    1326             }
    13271355        }
     1356    }
    13281357
    13291358    // Filter & return
    13301359    return apply_filters( 'bbp_get_reply_author_email', $author_email, $reply_id );
    1331     }
     1360}
    13321361
    13331362/**
     
    13411370    echo bbp_get_reply_author_role( $args );
    13421371}
    1343     /**
    1344      * Return the reply author role
    1345      *
    1346      * @since 2.1.0 bbPress (r3860)
    1347      *
    1348      * @param array $args Optional.
    1349      * @return string Reply author role
    1350      */
    1351     function bbp_get_reply_author_role( $args = array() ) {
     1372
     1373/**
     1374 * Return the reply author role
     1375 *
     1376 * @since 2.1.0 bbPress (r3860)
     1377 *
     1378 * @param array $args Optional.
     1379 * @return string Reply author role
     1380 */
     1381function bbp_get_reply_author_role( $args = array() ) {
    13521382
    13531383    // Parse arguments against default values
    13541384    $r = bbp_parse_args( $args, array(
    1355     'reply_id' => 0,
    1356     'class'    => false,
    1357     'before'   => '<div class="bbp-author-role">',
    1358     'after'    => '</div>'
     1385        'reply_id' => 0,
     1386        'class'    => false,
     1387        'before'   => '<div class="bbp-author-role">',
     1388        'after'    => '</div>'
    13591389    ), 'get_reply_author_role' );
    13601390
    1361 $reply_id    = bbp_get_reply_id( $r['reply_id'] );
    1362 $role        = bbp_get_user_display_role( bbp_get_reply_author_id( $reply_id ) );
    1363 
    1364 // Backwards compatibilty with old 'class' argument
    1365 if ( ! empty( $r['class'] ) ) {
    1366     $author_role = sprintf( '%1$s<div class="%2$s">%3$s</div>%4$s', $r['before'], esc_attr( $r['class'] ), esc_html( $role ), $r['after'] );
     1391    $reply_id    = bbp_get_reply_id( $r['reply_id'] );
     1392    $role        = bbp_get_user_display_role( bbp_get_reply_author_id( $reply_id ) );
     1393
     1394    // Backwards compatibilty with old 'class' argument
     1395    if ( ! empty( $r['class'] ) ) {
     1396        $author_role = sprintf( '%1$s<div class="%2$s">%3$s</div>%4$s', $r['before'], esc_attr( $r['class'] ), esc_html( $role ), $r['after'] );
    13671397
    13681398    // Simpler before & after arguments
    13691399    // https://bbpress.trac.wordpress.org/ticket/2557
    13701400    } else {
    1371     $author_role = $r['before'] . $role . $r['after'];
    1372     }
    1373 
    1374 // Filter & return
    1375 return apply_filters( 'bbp_get_reply_author_role', $author_role, $r, $args );
    1376     }
     1401        $author_role = $r['before'] . $role . $r['after'];
     1402    }
     1403
     1404    // Filter & return
     1405    return apply_filters( 'bbp_get_reply_author_role', $author_role, $r, $args );
     1406}
    13771407
    13781408/**
     
    13861416    echo bbp_get_reply_topic_title( $reply_id );
    13871417}
    1388     /**
    1389      * Return the topic title a reply belongs to
    1390      *
    1391      * @since 2.0.0 bbPress (r2553)
    1392      *
    1393      * @param int $reply_id Optional. Reply id
    1394      * @return string The topic title of the reply
    1395      */
    1396     function bbp_get_reply_topic_title( $reply_id = 0 ) {
     1418
     1419/**
     1420 * Return the topic title a reply belongs to
     1421 *
     1422 * @since 2.0.0 bbPress (r2553)
     1423 *
     1424 * @param int $reply_id Optional. Reply id
     1425 * @return string The topic title of the reply
     1426 */
     1427function bbp_get_reply_topic_title( $reply_id = 0 ) {
    13971428    $reply_id = bbp_get_reply_id( $reply_id );
    13981429    $topic_id = bbp_get_reply_topic_id( $reply_id );
     
    14011432    // Filter & return
    14021433    return apply_filters( 'bbp_get_reply_topic_title', $title, $reply_id );
    1403     }
     1434}
    14041435
    14051436/**
     
    14131444    echo bbp_get_reply_topic_id( $reply_id );
    14141445}
    1415     /**
    1416      * Return the topic id a reply belongs to
    1417      *
    1418      * @since 2.0.0 bbPress (r2553)
    1419      *
    1420      * @param int $reply_id Optional. Reply id
    1421      * @return int The topic id of the reply
    1422      */
    1423     function bbp_get_reply_topic_id( $reply_id = 0 ) {
     1446
     1447/**
     1448 * Return the topic id a reply belongs to
     1449 *
     1450 * @since 2.0.0 bbPress (r2553)
     1451 *
     1452 * @param int $reply_id Optional. Reply id
     1453 * @return int The topic id of the reply
     1454 */
     1455function bbp_get_reply_topic_id( $reply_id = 0 ) {
    14241456    $reply_id = bbp_get_reply_id( $reply_id );
    14251457    $topic_id = (int) get_post_field( 'post_parent', $reply_id );
     
    14281460    if ( empty( $topic_id ) ) {
    14291461        $topic_id = (int) get_post_meta( $reply_id, '_bbp_topic_id', true );
    1430         }
     1462    }
    14311463
    14321464    // Filter
    14331465    if ( ! empty( $topic_id ) ) {
    14341466        $topic_id = (int) bbp_get_topic_id( $topic_id );
    1435         }
     1467    }
    14361468
    14371469    // Filter & return
    14381470    return (int) apply_filters( 'bbp_get_reply_topic_id', $topic_id, $reply_id );
    1439     }
     1471}
    14401472
    14411473/**
     
    14491481    echo bbp_get_reply_forum_id( $reply_id );
    14501482}
    1451     /**
    1452      * Return the forum id a reply belongs to
    1453      *
    1454      * @since 2.0.0 bbPress (r2679)
    1455      *
    1456      * @param int $reply_id Optional. Reply id
    1457      *
    1458      * @return int The forum id of the reply
    1459      */
    1460     function bbp_get_reply_forum_id( $reply_id = 0 ) {
     1483
     1484/**
     1485 * Return the forum id a reply belongs to
     1486 *
     1487 * @since 2.0.0 bbPress (r2679)
     1488 *
     1489 * @param int $reply_id Optional. Reply id
     1490 *
     1491 * @return int The forum id of the reply
     1492 */
     1493function bbp_get_reply_forum_id( $reply_id = 0 ) {
    14611494    $reply_id = bbp_get_reply_id( $reply_id );
    14621495    $topic_id = bbp_get_reply_topic_id( $reply_id );
     
    14661499    if ( empty( $forum_id ) ) {
    14671500        $forum_id = (int) get_post_meta( $reply_id, '_bbp_forum_id', true );
    1468         }
     1501    }
    14691502
    14701503    // Filter
    14711504    if ( ! empty( $forum_id ) ) {
    14721505        $forum_id = (int) bbp_get_forum_id( $forum_id );
    1473         }
     1506    }
    14741507
    14751508    // Filter & return
    14761509    return (int) apply_filters( 'bbp_get_reply_forum_id', $forum_id, $reply_id );
    1477     }
     1510}
    14781511
    14791512/**
     
    14871520    echo bbp_get_reply_ancestor_id( $reply_id );
    14881521}
    1489     /**
    1490      * Return the ancestor reply id of a reply
    1491      *
    1492      * @since 2.4.0 bbPress (r4944)
    1493      *
    1494      * @param in $reply_id Reply id
    1495      */
    1496     function bbp_get_reply_ancestor_id( $reply_id = 0 ) {
     1522
     1523/**
     1524 * Return the ancestor reply id of a reply
     1525 *
     1526 * @since 2.4.0 bbPress (r4944)
     1527 *
     1528 * @param in $reply_id Reply id
     1529 */
     1530function bbp_get_reply_ancestor_id( $reply_id = 0 ) {
    14971531
    14981532    // Validation
     
    15001534    if ( empty( $reply_id ) ) {
    15011535        return false;
    1502         }
     1536    }
    15031537
    15041538    // Find highest reply ancestor
     
    15071541        if ( empty( $parent_id ) || ( $parent_id === $ancestor_id ) || ( bbp_get_reply_topic_id( $reply_id ) === $parent_id ) || ( $parent_id === $reply_id ) ) {
    15081542            break;
    1509             }
     1543        }
     1544
    15101545        $ancestor_id = $parent_id;
    1511         }
     1546    }
    15121547
    15131548    return (int) $ancestor_id;
    1514     }
     1549}
    15151550
    15161551/**
     
    15241559    echo bbp_get_reply_to( $reply_id );
    15251560}
    1526     /**
    1527      * Return the reply to id of a reply
    1528      *
    1529      * @since 2.4.0 bbPress (r4944)
    1530      *
    1531      * @param int $reply_id Optional. Reply id
    1532      * @return int The parent reply id of the reply
    1533      */
    1534     function bbp_get_reply_to( $reply_id = 0 ) {
     1561
     1562/**
     1563 * Return the reply to id of a reply
     1564 *
     1565 * @since 2.4.0 bbPress (r4944)
     1566 *
     1567 * @param int $reply_id Optional. Reply id
     1568 * @return int The parent reply id of the reply
     1569 */
     1570function bbp_get_reply_to( $reply_id = 0 ) {
    15351571
    15361572    // Assume there is no reply_to set
     
    15431579    if ( ! empty( $reply_id ) ) {
    15441580        $reply_to = (int) get_post_meta( $reply_id, '_bbp_reply_to', true );
    1545         }
     1581    }
    15461582
    15471583    // Filter & return
    15481584    return (int) apply_filters( 'bbp_get_reply_to', $reply_to, $reply_id );
    1549     }
     1585}
    15501586
    15511587/**
     
    15601596}
    15611597
    1562     /**
    1563     * Return the link for a reply to a reply
    1564     *
    1565     * @since 2.4.0 bbPress (r4944)
    1566     *
    1567     * @param array $args Arguments
    1568     * @return string Link for a reply to a reply
    1569     */
    1570     function bbp_get_reply_to_link( $args = array() ) {
     1598/**
     1599 * Return the link for a reply to a reply
     1600 *
     1601 * @since 2.4.0 bbPress (r4944)
     1602 *
     1603 * @param array $args Arguments
     1604 * @return string Link for a reply to a reply
     1605 */
     1606function bbp_get_reply_to_link( $args = array() ) {
    15711607
    15721608    // Parse arguments against default values
    15731609    $r = bbp_parse_args( $args, array(
    1574     'id'           => 0,
    1575     'link_before' => '',
    1576     'link_after'   => '',
    1577     'reply_text'   => esc_html_x( 'Reply', 'verb', 'bbpress' ),
    1578     'depth'        => 0,
    1579     'add_below'    => 'post',
    1580     'respond_id'   => 'new-reply-' . bbp_get_topic_id(),
     1610        'id'          => 0,
     1611        'link_before' => '',
     1612        'link_after'  => '',
     1613        'reply_text'  => esc_html_x( 'Reply', 'verb', 'bbpress' ),
     1614        'depth'       => 0,
     1615        'add_below'   => 'post',
     1616        'respond_id'  => 'new-reply-' . bbp_get_topic_id(),
    15811617    ), 'get_reply_to_link' );
    15821618
    1583 // Get the reply to use it's ID and post_parent
    1584 $reply    = bbp_get_reply( $r['id'] );
    1585 $topic_id = bbp_get_reply_topic_id( $reply->ID );
    1586 
    1587 // Bail if no reply or user cannot reply
    1588 if ( empty( $reply ) || empty( $topic_id ) || bbp_is_single_reply() || ! bbp_current_user_can_access_create_reply_form() ) {
    1589     return;
    1590     }
    1591 
    1592 // Build the URI and return value
    1593 $uri = bbp_get_reply_url( $reply->ID );
    1594 $uri = strtok( $uri, '#' );
    1595 $uri = add_query_arg( array( 'bbp_reply_to' => $reply->ID ), $uri );
    1596 $uri = wp_nonce_url( $uri, 'respond_id_' . $reply->ID );
    1597 $uri = $uri . '#new-post';
    1598 
    1599 // Only add onclick if replies are threaded
    1600 if ( bbp_thread_replies() ) {
    1601 
    1602     // Array of classes to pass to moveForm
    1603     $move_form = array(
    1604         $r['add_below'] . '-' . $reply->ID,
    1605         $reply->ID,
    1606         $r['respond_id'],
    1607         $reply->post_parent
    1608     );
    1609 
    1610     // Build the onclick
    1611     $onclick = ' onclick="return addReply.moveForm(\'' . implode( "','", $move_form ) . '\');"';
     1619    // Get the reply to use it's ID and post_parent
     1620    $reply    = bbp_get_reply( $r['id'] );
     1621    $topic_id = bbp_get_reply_topic_id( $reply->ID );
     1622
     1623    // Bail if no reply or user cannot reply
     1624    if ( empty( $reply ) || empty( $topic_id ) || bbp_is_single_reply() || ! bbp_current_user_can_access_create_reply_form() ) {
     1625        return;
     1626    }
     1627
     1628    // Build the URI and return value
     1629    $uri = bbp_get_reply_url( $reply->ID );
     1630    $uri = strtok( $uri, '#' );
     1631    $uri = add_query_arg( array( 'bbp_reply_to' => $reply->ID ), $uri );
     1632    $uri = wp_nonce_url( $uri, 'respond_id_' . $reply->ID );
     1633    $uri = $uri . '#new-post';
     1634
     1635    // Only add onclick if replies are threaded
     1636    if ( bbp_thread_replies() ) {
     1637
     1638        // Array of classes to pass to moveForm
     1639        $move_form = array(
     1640            $r['add_below'] . '-' . $reply->ID,
     1641            $reply->ID,
     1642            $r['respond_id'],
     1643            $reply->post_parent
     1644        );
     1645
     1646        // Build the onclick
     1647        $onclick = ' onclick="return addReply.moveForm(\'' . implode( "','", $move_form ) . '\');"';
    16121648
    16131649    // No onclick if replies are not threaded
    16141650    } else {
    1615     $onclick = '';
    1616     }
    1617 
    1618 // Add $uri to the array, to be passed through the filter
    1619 $r['uri'] = $uri;
    1620 $retval   = $r['link_before'] . '<a role="button" href="' . esc_url( $r['uri'] ) . '" class="bbp-reply-to-link"' . $onclick . '>' . $r['reply_text'] . '</a>' . $r['link_after'];
    1621 
    1622 // Filter & return
    1623 return apply_filters( 'bbp_get_reply_to_link', $retval, $r, $args );
    1624     }
     1651        $onclick = '';
     1652    }
     1653
     1654    // Add $uri to the array, to be passed through the filter
     1655    $r['uri'] = $uri;
     1656    $retval   = $r['link_before'] . '<a role="button" href="' . esc_url( $r['uri'] ) . '" class="bbp-reply-to-link"' . $onclick . '>' . $r['reply_text'] . '</a>' . $r['link_after'];
     1657
     1658    // Filter & return
     1659    return apply_filters( 'bbp_get_reply_to_link', $retval, $r, $args );
     1660}
    16251661
    16261662/**
     
    16321668    echo bbp_get_cancel_reply_to_link( $text );
    16331669}
    1634     /**
    1635      * Return the cancellation link for a reply to a reply
    1636      *
    1637      * @since 2.4.0 bbPress (r4944)
    1638      *
    1639      * @param string $text The cancel text
    1640      * @return string The cancellation link
    1641      */
    1642     function bbp_get_cancel_reply_to_link( $text = '' ) {
     1670
     1671/**
     1672 * Return the cancellation link for a reply to a reply
     1673 *
     1674 * @since 2.4.0 bbPress (r4944)
     1675 *
     1676 * @param string $text The cancel text
     1677 * @return string The cancellation link
     1678 */
     1679function bbp_get_cancel_reply_to_link( $text = '' ) {
    16431680
    16441681    // Bail if not hierarchical or editing a reply
    16451682    if ( ! bbp_thread_replies() || bbp_is_reply_edit() ) {
    16461683        return;
    1647         }
     1684    }
    16481685
    16491686    // Set default text
    16501687    if ( empty( $text ) ) {
    16511688        $text = esc_html__( 'Cancel', 'bbpress' );
    1652         }
     1689    }
    16531690
    16541691    // Replying to...
    16551692    $reply_to = isset( $_GET['bbp_reply_to'] )
    1656     ? (int) $_GET['bbp_reply_to']
    1657     : 0;
     1693        ? (int) $_GET['bbp_reply_to']
     1694        : 0;
    16581695
    16591696    // Set visibility
     
    16641701    // Filter & return
    16651702    return apply_filters( 'bbp_get_cancel_reply_to_link', $retval, $link, $text );
    1666     }
     1703}
    16671704
    16681705/**
     
    16771714    echo bbp_get_reply_position( $reply_id, $topic_id );
    16781715}
    1679     /**
    1680      * Return the numeric position of a reply within a topic
    1681      *
    1682      * @since 2.0.0 bbPress (r2984)
    1683      *
    1684      * @param int $reply_id Optional. Reply id
    1685      * @param int $topic_id Optional. Topic id
    1686      * @return int Reply position
    1687      */
    1688     function bbp_get_reply_position( $reply_id = 0, $topic_id = 0 ) {
     1716
     1717/**
     1718 * Return the numeric position of a reply within a topic
     1719 *
     1720 * @since 2.0.0 bbPress (r2984)
     1721 *
     1722 * @param int $reply_id Optional. Reply id
     1723 * @param int $topic_id Optional. Topic id
     1724 * @return int Reply position
     1725 */
     1726function bbp_get_reply_position( $reply_id = 0, $topic_id = 0 ) {
    16891727
    16901728    // Get required data
     
    17081746            if ( ! empty( $reply_position ) ) {
    17091747                bbp_update_reply_position( $reply_id, $reply_position );
    1710                 }
     1748            }
    17111749
    17121750            // Topic's position is always 0
    17131751            } else {
    1714             $reply_position = 0;
     1752                $reply_position = 0;
    17151753            }
    17161754        }
     
    17191757    if ( ! bbp_show_lead_topic() ) {
    17201758        $reply_position++;
    1721         }
     1759    }
    17221760
    17231761    // Filter & return
    17241762    return (int) apply_filters( 'bbp_get_reply_position', $reply_position, $reply_id, $topic_id );
    1725     }
     1763}
    17261764
    17271765/** Reply Admin Links *********************************************************/
     
    17371775    echo bbp_get_reply_admin_links( $args );
    17381776}
    1739     /**
    1740      * Return admin links for reply
    1741      *
    1742      * @since 2.0.0 bbPress (r2667)
    1743      *
    1744      * @param array $args This function supports these arguments:
    1745      *  - id: Optional. Reply id
    1746      *  - before: HTML before the links. Defaults to
    1747      *             '<span class="bbp-admin-links">'
    1748      *  - after: HTML after the links. Defaults to '</span>'
    1749      *  - sep: Separator. Defaults to ' | '
    1750      *  - links: Array of the links to display. By default, edit, trash,
    1751      *            spam, reply move, and topic split links are displayed
    1752      * @return string Reply admin links
    1753      */
    1754     function bbp_get_reply_admin_links( $args = array() ) {
     1777
     1778/**
     1779 * Return admin links for reply
     1780 *
     1781 * @since 2.0.0 bbPress (r2667)
     1782 *
     1783 * @param array $args This function supports these arguments:
     1784 *  - id: Optional. Reply id
     1785 *  - before: HTML before the links. Defaults to
     1786 *             '<span class="bbp-admin-links">'
     1787 *  - after: HTML after the links. Defaults to '</span>'
     1788 *  - sep: Separator. Defaults to ' | '
     1789 *  - links: Array of the links to display. By default, edit, trash,
     1790 *            spam, reply move, and topic split links are displayed
     1791 * @return string Reply admin links
     1792 */
     1793function bbp_get_reply_admin_links( $args = array() ) {
    17551794
    17561795    // Parse arguments against default values
    17571796    $r = bbp_parse_args( $args, array(
    1758     'id'     => 0,
    1759     'before' => '<span class="bbp-admin-links">',
    1760     'after'  => '</span>',
    1761     'sep'    => ' | ',
    1762     'links'  => array()
     1797        'id'     => 0,
     1798        'before' => '<span class="bbp-admin-links">',
     1799        'after'  => '</span>',
     1800        'sep'    => ' | ',
     1801        'links'  => array()
    17631802    ), 'get_reply_admin_links' );
    17641803
    1765 $r['id'] = bbp_get_reply_id( $r['id'] );
    1766 
    1767 // If post is a topic, return the topic admin links instead
    1768 if ( bbp_is_topic( $r['id'] ) ) {
    1769     return bbp_get_topic_admin_links( $args );
    1770     }
    1771 
    1772 // If post is not a reply, return
    1773 if ( ! bbp_is_reply( $r['id'] ) ) {
    1774     return;
    1775     }
    1776 
    1777 // If topic is trashed, do not show admin links
    1778 if ( bbp_is_topic_trash( bbp_get_reply_topic_id( $r['id'] ) ) ) {
    1779     return;
    1780     }
    1781 
    1782 // If no links were passed, default to the standard
    1783 if ( empty( $r['links'] ) ) {
    1784     $r['links'] = apply_filters( 'bbp_reply_admin_links', array(
    1785         'edit'    => bbp_get_reply_edit_link   ( $r ),
    1786         'move'    => bbp_get_reply_move_link   ( $r ),
    1787         'split'   => bbp_get_topic_split_link  ( $r ),
    1788         'trash'   => bbp_get_reply_trash_link  ( $r ),
    1789         'spam'    => bbp_get_reply_spam_link   ( $r ),
    1790         'approve' => bbp_get_reply_approve_link( $r ),
    1791         'reply'   => bbp_get_reply_to_link     ( $r )
    1792     ), $r['id'] );
    1793 }
    1794 
    1795 // See if links need to be unset
    1796 $reply_status = bbp_get_reply_status( $r['id'] );
    1797 if ( in_array( $reply_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id(), bbp_get_pending_status_id() ), true ) ) {
    1798 
    1799     // Spam link shouldn't be visible on trashed topics
    1800     if ( bbp_get_trash_status_id() === $reply_status ) {
    1801         unset( $r['links']['spam'] );
     1804    $r['id'] = bbp_get_reply_id( $r['id'] );
     1805
     1806    // If post is a topic, return the topic admin links instead
     1807    if ( bbp_is_topic( $r['id'] ) ) {
     1808        return bbp_get_topic_admin_links( $args );
     1809    }
     1810
     1811    // If post is not a reply, return
     1812    if ( ! bbp_is_reply( $r['id'] ) ) {
     1813        return;
     1814    }
     1815
     1816    // If topic is trashed, do not show admin links
     1817    if ( bbp_is_topic_trash( bbp_get_reply_topic_id( $r['id'] ) ) ) {
     1818        return;
     1819    }
     1820
     1821    // If no links were passed, default to the standard
     1822    if ( empty( $r['links'] ) ) {
     1823        $r['links'] = apply_filters( 'bbp_reply_admin_links', array(
     1824            'edit'    => bbp_get_reply_edit_link   ( $r ),
     1825            'move'    => bbp_get_reply_move_link   ( $r ),
     1826            'split'   => bbp_get_topic_split_link  ( $r ),
     1827            'trash'   => bbp_get_reply_trash_link  ( $r ),
     1828            'spam'    => bbp_get_reply_spam_link   ( $r ),
     1829            'approve' => bbp_get_reply_approve_link( $r ),
     1830            'reply'   => bbp_get_reply_to_link     ( $r )
     1831        ), $r['id'] );
     1832    }
     1833
     1834    // See if links need to be unset
     1835    $reply_status = bbp_get_reply_status( $r['id'] );
     1836    if ( in_array( $reply_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id(), bbp_get_pending_status_id() ), true ) ) {
     1837
     1838        // Spam link shouldn't be visible on trashed topics
     1839        if ( bbp_get_trash_status_id() === $reply_status ) {
     1840            unset( $r['links']['spam'] );
    18021841
    18031842        // Trash link shouldn't be visible on spam topics
    18041843        } elseif ( bbp_get_spam_status_id() === $reply_status ) {
    1805         unset( $r['links']['trash'] );
     1844            unset( $r['links']['trash'] );
    18061845        }
    18071846    }
    18081847
    1809 // Process the admin links
    1810 $links  = implode( $r['sep'], array_filter( $r['links'] ) );
    1811 $retval = $r['before'] . $links . $r['after'];
    1812 
    1813 // Filter & return
    1814 return apply_filters( 'bbp_get_reply_admin_links', $retval, $r, $args );
    1815     }
     1848    // Process the admin links
     1849    $links  = implode( $r['sep'], array_filter( $r['links'] ) );
     1850    $retval = $r['before'] . $links . $r['after'];
     1851
     1852    // Filter & return
     1853    return apply_filters( 'bbp_get_reply_admin_links', $retval, $r, $args );
     1854}
    18161855
    18171856/**
     
    18261865}
    18271866
    1828     /**
    1829     * Return the edit link of the reply
    1830     *
    1831     * @since 2.0.0 bbPress (r2740)
    1832     *
    1833     * @param array $args This function supports these arguments:
    1834     *  - id: Reply id
    1835     *  - link_before: HTML before the link
    1836     *  - link_after: HTML after the link
    1837     *  - edit_text: Edit text. Defaults to 'Edit'
    1838     * @return string Reply edit link
    1839     */
    1840     function bbp_get_reply_edit_link( $args = array() ) {
     1867/**
     1868 * Return the edit link of the reply
     1869 *
     1870 * @since 2.0.0 bbPress (r2740)
     1871 *
     1872 * @param array $args This function supports these arguments:
     1873 *  - id: Reply id
     1874 *  - link_before: HTML before the link
     1875 *  - link_after: HTML after the link
     1876 *  - edit_text: Edit text. Defaults to 'Edit'
     1877 * @return string Reply edit link
     1878 */
     1879function bbp_get_reply_edit_link( $args = array() ) {
    18411880
    18421881    // Parse arguments against default values
    18431882    $r = bbp_parse_args( $args, array(
    1844     'id'           => 0,
    1845     'link_before'  => '',
    1846     'link_after'   => '',
    1847     'edit_text'    => esc_html__( 'Edit', 'bbpress' )
     1883        'id'           => 0,
     1884        'link_before'  => '',
     1885        'link_after'   => '',
     1886        'edit_text'    => esc_html__( 'Edit', 'bbpress' )
    18481887    ), 'get_reply_edit_link' );
    18491888
    1850 // Get reply
    1851 $reply = bbp_get_reply( $r['id'] );
    1852 
    1853 // Bypass check if user has caps
    1854 if ( ! current_user_can( 'edit_others_replies' ) ) {
    1855 
    1856     // User cannot edit or it is past the lock time
    1857     if ( empty( $reply ) || ! current_user_can( 'edit_reply', $reply->ID ) || bbp_past_edit_lock( $reply->post_date_gmt ) ) {
     1889    // Get reply
     1890    $reply = bbp_get_reply( $r['id'] );
     1891
     1892    // Bypass check if user has caps
     1893    if ( ! current_user_can( 'edit_others_replies' ) ) {
     1894
     1895        // User cannot edit or it is past the lock time
     1896        if ( empty( $reply ) || ! current_user_can( 'edit_reply', $reply->ID ) || bbp_past_edit_lock( $reply->post_date_gmt ) ) {
     1897            return;
     1898        }
     1899    }
     1900
     1901    // Get uri
     1902    $uri = bbp_get_reply_edit_url( $r['id'] );
     1903
     1904    // Bail if no uri
     1905    if ( empty( $uri ) ) {
    18581906        return;
    1859         }
    1860     }
    1861 
    1862 // Get uri
    1863 $uri = bbp_get_reply_edit_url( $r['id'] );
    1864 
    1865 // Bail if no uri
    1866 if ( empty( $uri ) ) {
    1867     return;
    1868     }
    1869 
    1870 $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-reply-edit-link">' . $r['edit_text'] . '</a>' . $r['link_after'];
    1871 
    1872 // Filter & return
    1873 return apply_filters( 'bbp_get_reply_edit_link', $retval, $r, $args );
    1874     }
     1907    }
     1908
     1909    $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-reply-edit-link">' . $r['edit_text'] . '</a>' . $r['link_after'];
     1910
     1911    // Filter & return
     1912    return apply_filters( 'bbp_get_reply_edit_link', $retval, $r, $args );
     1913}
    18751914
    18761915/**
     
    18841923    echo esc_url( bbp_get_reply_edit_url( $reply_id ) );
    18851924}
    1886     /**
    1887      * Return URL to the reply edit page
    1888      *
    1889      * @since 2.0.0 bbPress (r2753)
    1890      *
    1891      * @param int $reply_id Optional. Reply id
    1892      * @return string Reply edit url
    1893      */
    1894     function bbp_get_reply_edit_url( $reply_id = 0 ) {
     1925
     1926/**
     1927 * Return URL to the reply edit page
     1928 *
     1929 * @since 2.0.0 bbPress (r2753)
     1930 *
     1931 * @param int $reply_id Optional. Reply id
     1932 * @return string Reply edit url
     1933 */
     1934function bbp_get_reply_edit_url( $reply_id = 0 ) {
    18951935
    18961936    // Bail if no reply
     
    18981938    if ( empty( $reply ) ) {
    18991939        return;
    1900         }
     1940    }
    19011941
    19021942    $reply_link = bbp_remove_view_all( bbp_get_reply_permalink( $reply_id ) );
     
    19081948        $url = user_trailingslashit( $url );
    19091949
    1910         // Unpretty permalinks
    1911         } else {
     1950    // Unpretty permalinks
     1951    } else {
    19121952        $url = add_query_arg( array(
    1913         bbp_get_reply_post_type() => $reply->post_name,
    1914         bbp_get_edit_rewrite_id() => '1'
     1953            bbp_get_reply_post_type() => $reply->post_name,
     1954            bbp_get_edit_rewrite_id() => '1'
    19151955        ), $reply_link );
    1916         }
     1956    }
    19171957
    19181958    // Maybe add view all
     
    19211961    // Filter & return
    19221962    return apply_filters( 'bbp_get_reply_edit_url', $url, $reply_id );
    1923     }
     1963}
    19241964
    19251965/**
     
    19341974}
    19351975
    1936     /**
    1937     * Return the trash link of the reply
    1938     *
    1939     * @since 2.0.0 bbPress (r2740)
    1940     *
    1941     * @param array $args This function supports these arguments:
    1942     *  - id: Reply id
    1943     *  - link_before: HTML before the link
    1944     *  - link_after: HTML after the link
    1945     *  - sep: Separator
    1946     *  - trash_text: Trash text
    1947     *  - restore_text: Restore text
    1948     *  - delete_text: Delete text
    1949     * @return string Reply trash link
    1950     */
    1951     function bbp_get_reply_trash_link( $args = array() ) {
     1976/**
     1977 * Return the trash link of the reply
     1978 *
     1979 * @since 2.0.0 bbPress (r2740)
     1980 *
     1981 * @param array $args This function supports these arguments:
     1982 *  - id: Reply id
     1983 *  - link_before: HTML before the link
     1984 *  - link_after: HTML after the link
     1985 *  - sep: Separator
     1986 *  - trash_text: Trash text
     1987 *  - restore_text: Restore text
     1988 *  - delete_text: Delete text
     1989 * @return string Reply trash link
     1990 */
     1991function bbp_get_reply_trash_link( $args = array() ) {
    19521992
    19531993    // Parse arguments against default values
    19541994    $r = bbp_parse_args( $args, array(
    1955     'id'           => 0,
    1956     'link_before'  => '',
    1957     'link_after'   => '',
    1958     'sep'          => ' | ',
    1959     'trash_text'   => esc_html__( 'Trash',   'bbpress' ),
    1960     'restore_text' => esc_html__( 'Restore', 'bbpress' ),
    1961     'delete_text'  => esc_html__( 'Delete',  'bbpress' )
     1995        'id'           => 0,
     1996        'link_before'  => '',
     1997        'link_after'   => '',
     1998        'sep'          => ' | ',
     1999        'trash_text'   => esc_html__( 'Trash',   'bbpress' ),
     2000        'restore_text' => esc_html__( 'Restore', 'bbpress' ),
     2001        'delete_text'  => esc_html__( 'Delete',  'bbpress' )
    19622002    ), 'get_reply_trash_link' );
    19632003
    1964 // Get reply
    1965 $reply = bbp_get_reply( $r['id'] );
    1966 
    1967 // Bail if no reply or current user cannot delete
    1968 if ( empty( $reply ) || ! current_user_can( 'delete_reply', $reply->ID ) ) {
    1969     return;
    1970     }
    1971 
    1972 $actions    = array();
    1973 $trash_days = bbp_get_trash_days( bbp_get_reply_post_type() );
    1974 
    1975 // Trashed
    1976 if ( bbp_is_reply_trash( $reply->ID ) ) {
    1977     $actions['untrash'] = '<a title="' . esc_attr__( 'Restore this item from the Trash', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_reply_trash', 'sub_action' => 'untrash', 'reply_id' => $reply->ID ) ), 'untrash-' . $reply->post_type . '_' . $reply->ID ) ) . '" class="bbp-reply-restore-link">' . $r['restore_text'] . '</a>';
     2004    // Get reply
     2005    $reply = bbp_get_reply( $r['id'] );
     2006
     2007    // Bail if no reply or current user cannot delete
     2008    if ( empty( $reply ) || ! current_user_can( 'delete_reply', $reply->ID ) ) {
     2009        return;
     2010    }
     2011
     2012    $actions    = array();
     2013    $trash_days = bbp_get_trash_days( bbp_get_reply_post_type() );
     2014
     2015    // Trashed
     2016    if ( bbp_is_reply_trash( $reply->ID ) ) {
     2017        $actions['untrash'] = '<a title="' . esc_attr__( 'Restore this item from the Trash', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_reply_trash', 'sub_action' => 'untrash', 'reply_id' => $reply->ID ) ), 'untrash-' . $reply->post_type . '_' . $reply->ID ) ) . '" class="bbp-reply-restore-link">' . $r['restore_text'] . '</a>';
    19782018
    19792019    // Trash
    19802020    } elseif ( ! empty( $trash_days ) ) {
    1981     $actions['trash']   = '<a title="' . esc_attr__( 'Move this item to the Trash',      'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_reply_trash', 'sub_action' => 'trash',   'reply_id' => $reply->ID ) ), 'trash-'   . $reply->post_type . '_' . $reply->ID ) ) . '" class="bbp-reply-trash-link">'   . $r['trash_text']   . '</a>';
    1982     }
    1983 
    1984 // No trash
    1985 if ( bbp_is_reply_trash( $reply->ID ) || empty( $trash_days ) ) {
    1986     $actions['delete']  = '<a title="' . esc_attr__( 'Delete this item permanently',     'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_reply_trash', 'sub_action' => 'delete',  'reply_id' => $reply->ID ) ), 'delete-'  . $reply->post_type . '_' . $reply->ID ) ) . '" onclick="return confirm(\'' . esc_js( __( 'Are you sure you want to delete that permanently?', 'bbpress' ) ) . '\' );" class="bbp-reply-delete-link">' . $r['delete_text'] . '</a>';
    1987     }
    1988 
    1989 // Process the admin links
    1990 $retval = $r['link_before'] . implode( $r['sep'], $actions ) . $r['link_after'];
    1991 
    1992 // Filter & return
    1993 return apply_filters( 'bbp_get_reply_trash_link', $retval, $r, $args );
    1994     }
     2021        $actions['trash']   = '<a title="' . esc_attr__( 'Move this item to the Trash',      'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_reply_trash', 'sub_action' => 'trash',   'reply_id' => $reply->ID ) ), 'trash-'   . $reply->post_type . '_' . $reply->ID ) ) . '" class="bbp-reply-trash-link">'   . $r['trash_text']   . '</a>';
     2022    }
     2023
     2024    // No trash
     2025    if ( bbp_is_reply_trash( $reply->ID ) || empty( $trash_days ) ) {
     2026        $actions['delete']  = '<a title="' . esc_attr__( 'Delete this item permanently',     'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_reply_trash', 'sub_action' => 'delete',  'reply_id' => $reply->ID ) ), 'delete-'  . $reply->post_type . '_' . $reply->ID ) ) . '" onclick="return confirm(\'' . esc_js( __( 'Are you sure you want to delete that permanently?', 'bbpress' ) ) . '\' );" class="bbp-reply-delete-link">' . $r['delete_text'] . '</a>';
     2027    }
     2028
     2029    // Process the admin links
     2030    $retval = $r['link_before'] . implode( $r['sep'], $actions ) . $r['link_after'];
     2031
     2032    // Filter & return
     2033    return apply_filters( 'bbp_get_reply_trash_link', $retval, $r, $args );
     2034}
    19952035
    19962036/**
     
    20052045}
    20062046
    2007     /**
    2008     * Return the spam link of the reply
    2009     *
    2010     * @since 2.0.0 bbPress (r2740)
    2011     *
    2012     * @param array $args This function supports these arguments:
    2013     *  - id: Reply id
    2014     *  - link_before: HTML before the link
    2015     *  - link_after: HTML after the link
    2016     *  - spam_text: Spam text
    2017     *  - unspam_text: Unspam text
    2018     * @return string Reply spam link
    2019     */
    2020     function bbp_get_reply_spam_link( $args = array() ) {
     2047/**
     2048 * Return the spam link of the reply
     2049 *
     2050 * @since 2.0.0 bbPress (r2740)
     2051 *
     2052 * @param array $args This function supports these arguments:
     2053 *  - id: Reply id
     2054 *  - link_before: HTML before the link
     2055 *  - link_after: HTML after the link
     2056 *  - spam_text: Spam text
     2057 *  - unspam_text: Unspam text
     2058 * @return string Reply spam link
     2059 */
     2060function bbp_get_reply_spam_link( $args = array() ) {
    20212061
    20222062    // Parse arguments against default values
    20232063    $r = bbp_parse_args( $args, array(
    2024     'id'           => 0,
    2025     'link_before'  => '',
    2026     'link_after'   => '',
    2027     'spam_text'    => esc_html__( 'Spam',   'bbpress' ),
    2028     'unspam_text'  => esc_html__( 'Unspam', 'bbpress' )
     2064        'id'           => 0,
     2065        'link_before'  => '',
     2066        'link_after'   => '',
     2067        'spam_text'    => esc_html__( 'Spam',   'bbpress' ),
     2068        'unspam_text'  => esc_html__( 'Unspam', 'bbpress' )
    20292069    ), 'get_reply_spam_link' );
    20302070
    2031 // Get reply
    2032 $reply = bbp_get_reply( $r['id'] );
    2033 
    2034 // Bail if no reply or current user cannot moderate
    2035 if ( empty( $reply ) || ! current_user_can( 'moderate', $reply->ID ) ) {
    2036     return;
    2037     }
    2038 
    2039 $display = bbp_is_reply_spam( $reply->ID ) ? $r['unspam_text'] : $r['spam_text'];
    2040 $uri     = add_query_arg( array( 'action' => 'bbp_toggle_reply_spam', 'reply_id' => $reply->ID ) );
    2041 $uri     = wp_nonce_url( $uri, 'spam-reply_' . $reply->ID );
    2042 $retval  = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-reply-spam-link">' . $display . '</a>' . $r['link_after'];
    2043 
    2044 // Filter & return
    2045 return apply_filters( 'bbp_get_reply_spam_link', $retval, $r, $args );
    2046     }
     2071    // Get reply
     2072    $reply = bbp_get_reply( $r['id'] );
     2073
     2074    // Bail if no reply or current user cannot moderate
     2075    if ( empty( $reply ) || ! current_user_can( 'moderate', $reply->ID ) ) {
     2076        return;
     2077    }
     2078
     2079    $display = bbp_is_reply_spam( $reply->ID ) ? $r['unspam_text'] : $r['spam_text'];
     2080    $uri     = add_query_arg( array( 'action' => 'bbp_toggle_reply_spam', 'reply_id' => $reply->ID ) );
     2081    $uri     = wp_nonce_url( $uri, 'spam-reply_' . $reply->ID );
     2082    $retval  = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-reply-spam-link">' . $display . '</a>' . $r['link_after'];
     2083
     2084    // Filter & return
     2085    return apply_filters( 'bbp_get_reply_spam_link', $retval, $r, $args );
     2086}
    20472087
    20482088/**
     
    20592099}
    20602100
    2061     /**
    2062     * Get move reply link
    2063     *
    2064     * Return the move link of the reply
    2065     *
    2066     * @since 2.3.0 bbPress (r4521)
    2067     *
    2068     * @param array $args This function supports these arguments:
    2069     *  - id: Reply id
    2070     *  - link_before: HTML before the link
    2071     *  - link_after: HTML after the link
    2072     *  - move_text: Move text
    2073     *  - move_title: Move title attribute
    2074     * @return string Reply move link
    2075     */
    2076     function bbp_get_reply_move_link( $args = array() ) {
     2101/**
     2102 * Get move reply link
     2103 *
     2104 * Return the move link of the reply
     2105 *
     2106 * @since 2.3.0 bbPress (r4521)
     2107 *
     2108 * @param array $args This function supports these arguments:
     2109 *  - id: Reply id
     2110 *  - link_before: HTML before the link
     2111 *  - link_after: HTML after the link
     2112 *  - move_text: Move text
     2113 *  - move_title: Move title attribute
     2114 * @return string Reply move link
     2115 */
     2116function bbp_get_reply_move_link( $args = array() ) {
    20772117
    20782118    // Parse arguments against default values
    20792119    $r = bbp_parse_args( $args, array(
    2080     'id'          => 0,
    2081     'link_before' => '',
    2082     'link_after'  => '',
    2083     'split_text'  => esc_html__( 'Move',            'bbpress' ),
    2084     'split_title' => esc_attr__( 'Move this reply', 'bbpress' )
     2120        'id'          => 0,
     2121        'link_before' => '',
     2122        'link_after'  => '',
     2123        'split_text'  => esc_html__( 'Move',            'bbpress' ),
     2124        'split_title' => esc_attr__( 'Move this reply', 'bbpress' )
    20852125    ), 'get_reply_move_link' );
    20862126
    2087 // Get IDs
    2088 $reply_id = bbp_get_reply_id( $r['id'] );
    2089 $topic_id = bbp_get_reply_topic_id( $reply_id );
    2090 
    2091 // Bail if no reply ID or user cannot moderate
    2092 if ( empty( $reply_id ) || ! current_user_can( 'moderate', $topic_id ) ) {
    2093     return;
    2094     }
    2095 
    2096 $uri = add_query_arg( array(
    2097 'action'   => 'move',
    2098 'reply_id' => $reply_id
    2099 ), bbp_get_reply_edit_url( $reply_id ) );
    2100 
    2101 $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" title="' . $r['split_title'] . '" class="bbp-reply-move-link">' . $r['split_text'] . '</a>' . $r['link_after'];
    2102 
    2103 // Filter & return
    2104 return apply_filters( 'bbp_get_reply_move_link', $retval, $r, $args );
    2105     }
     2127    // Get IDs
     2128    $reply_id = bbp_get_reply_id( $r['id'] );
     2129    $topic_id = bbp_get_reply_topic_id( $reply_id );
     2130
     2131    // Bail if no reply ID or user cannot moderate
     2132    if ( empty( $reply_id ) || ! current_user_can( 'moderate', $topic_id ) ) {
     2133        return;
     2134    }
     2135
     2136    $uri = add_query_arg( array(
     2137        'action'   => 'move',
     2138        'reply_id' => $reply_id
     2139    ), bbp_get_reply_edit_url( $reply_id ) );
     2140
     2141    $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" title="' . $r['split_title'] . '" class="bbp-reply-move-link">' . $r['split_text'] . '</a>' . $r['link_after'];
     2142
     2143    // Filter & return
     2144    return apply_filters( 'bbp_get_reply_move_link', $retval, $r, $args );
     2145}
    21062146
    21072147/**
     
    21182158}
    21192159
    2120     /**
    2121     * Get split topic link
    2122     *
    2123     * Return the split link of the topic (but is bundled with each reply)
    2124     *
    2125     * @since 2.0.0 bbPress (r2756)
    2126     *
    2127     * @param array $args This function supports these arguments:
    2128     *  - id: Reply id
    2129     *  - link_before: HTML before the link
    2130     *  - link_after: HTML after the link
    2131     *  - split_text: Split text
    2132     *  - split_title: Split title attribute
    2133     * @return string Topic split link
    2134     */
    2135     function bbp_get_topic_split_link( $args = array() ) {
     2160/**
     2161 * Get split topic link
     2162 *
     2163 * Return the split link of the topic (but is bundled with each reply)
     2164 *
     2165 * @since 2.0.0 bbPress (r2756)
     2166 *
     2167 * @param array $args This function supports these arguments:
     2168 *  - id: Reply id
     2169 *  - link_before: HTML before the link
     2170 *  - link_after: HTML after the link
     2171 *  - split_text: Split text
     2172 *  - split_title: Split title attribute
     2173 * @return string Topic split link
     2174 */
     2175function bbp_get_topic_split_link( $args = array() ) {
    21362176
    21372177    // Parse arguments against default values
    21382178    $r = bbp_parse_args( $args, array(
    2139     'id'          => 0,
    2140     'link_before' => '',
    2141     'link_after'  => '',
    2142     'split_text'  => esc_html__( 'Split',                           'bbpress' ),
    2143     'split_title' => esc_attr__( 'Split the topic from this reply', 'bbpress' )
     2179        'id'          => 0,
     2180        'link_before' => '',
     2181        'link_after'  => '',
     2182        'split_text'  => esc_html__( 'Split',                           'bbpress' ),
     2183        'split_title' => esc_attr__( 'Split the topic from this reply', 'bbpress' )
    21442184    ), 'get_topic_split_link' );
    21452185
    2146 // Get IDs
    2147 $reply_id = bbp_get_reply_id( $r['id'] );
    2148 $topic_id = bbp_get_reply_topic_id( $reply_id );
    2149 
    2150 // Bail if no reply/topic ID, or user cannot moderate
    2151 if ( empty( $reply_id ) || empty( $topic_id ) || ! current_user_can( 'moderate', $topic_id ) ) {
    2152     return;
    2153     }
    2154 
    2155 $uri = add_query_arg( array(
    2156 'action'   => 'split',
    2157 'reply_id' => $reply_id
    2158 ), bbp_get_topic_edit_url( $topic_id ) );
    2159 
    2160 $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" title="' . $r['split_title'] . '" class="bbp-topic-split-link">' . $r['split_text'] . '</a>' . $r['link_after'];
    2161 
    2162 // Filter & return
    2163 return apply_filters( 'bbp_get_topic_split_link', $retval, $r, $args );
    2164     }
     2186    // Get IDs
     2187    $reply_id = bbp_get_reply_id( $r['id'] );
     2188    $topic_id = bbp_get_reply_topic_id( $reply_id );
     2189
     2190    // Bail if no reply/topic ID, or user cannot moderate
     2191    if ( empty( $reply_id ) || empty( $topic_id ) || ! current_user_can( 'moderate', $topic_id ) ) {
     2192        return;
     2193    }
     2194
     2195    $uri = add_query_arg( array(
     2196        'action'   => 'split',
     2197        'reply_id' => $reply_id
     2198    ), bbp_get_topic_edit_url( $topic_id ) );
     2199
     2200    $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" title="' . $r['split_title'] . '" class="bbp-topic-split-link">' . $r['split_text'] . '</a>' . $r['link_after'];
     2201
     2202    // Filter & return
     2203    return apply_filters( 'bbp_get_topic_split_link', $retval, $r, $args );
     2204}
    21652205
    21662206/**
     
    21752215}
    21762216
    2177     /**
    2178     * Return the approve link of the reply
    2179     *
    2180     * @since 2.6.0 bbPress (r5507)
    2181     *
    2182     * @param array $args This function supports these args:
    2183     *  - id: Optional. Reply id
    2184     *  - link_before: Before the link
    2185     *  - link_after: After the link
    2186     *  - sep: Separator between links
    2187     *  - approve_text: Approve text
    2188     *  - unapprove_text: Unapprove text
    2189     * @return string Reply approve link
    2190     */
    2191     function bbp_get_reply_approve_link( $args = array() ) {
     2217/**
     2218 * Return the approve link of the reply
     2219 *
     2220 * @since 2.6.0 bbPress (r5507)
     2221 *
     2222 * @param array $args This function supports these args:
     2223 *  - id: Optional. Reply id
     2224 *  - link_before: Before the link
     2225 *  - link_after: After the link
     2226 *  - sep: Separator between links
     2227 *  - approve_text: Approve text
     2228 *  - unapprove_text: Unapprove text
     2229 * @return string Reply approve link
     2230 */
     2231function bbp_get_reply_approve_link( $args = array() ) {
    21922232
    21932233    // Parse arguments against default values
    21942234    $r = bbp_parse_args( $args, array(
    2195     'id'             => 0,
    2196     'link_before'    => '',
    2197     'link_after'     => '',
    2198     'sep'            => ' | ',
    2199     'approve_text'   => _x( 'Approve',   'Pending Status', 'bbpress' ),
    2200     'unapprove_text' => _x( 'Unapprove', 'Pending Status', 'bbpress' )
     2235        'id'             => 0,
     2236        'link_before'    => '',
     2237        'link_after'     => '',
     2238        'sep'            => ' | ',
     2239        'approve_text'   => _x( 'Approve',   'Pending Status', 'bbpress' ),
     2240        'unapprove_text' => _x( 'Unapprove', 'Pending Status', 'bbpress' )
    22012241    ), 'get_reply_approve_link' );
    22022242
    2203 // Get reply
    2204 $reply = bbp_get_reply( $r['id'] );
    2205 
    2206 // Bail if no reply or current user cannot moderate
    2207 if ( empty( $reply ) || ! current_user_can( 'moderate', $reply->ID ) ) {
    2208     return;
    2209     }
    2210 
    2211 $display = bbp_is_reply_pending( $reply->ID ) ? $r['approve_text'] : $r['unapprove_text'];
    2212 $uri     = add_query_arg( array( 'action' => 'bbp_toggle_reply_approve', 'reply_id' => $reply->ID ) );
    2213 $uri     = wp_nonce_url( $uri, 'approve-reply_' . $reply->ID );
    2214 $retval  = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-reply-approve-link">' . $display . '</a>' . $r['link_after'];
    2215 
    2216 // Filter & return
    2217 return apply_filters( 'bbp_get_reply_approve_link', $retval, $r, $args );
    2218     }
     2243    // Get reply
     2244    $reply = bbp_get_reply( $r['id'] );
     2245
     2246    // Bail if no reply or current user cannot moderate
     2247    if ( empty( $reply ) || ! current_user_can( 'moderate', $reply->ID ) ) {
     2248        return;
     2249    }
     2250
     2251    $display = bbp_is_reply_pending( $reply->ID ) ? $r['approve_text'] : $r['unapprove_text'];
     2252    $uri     = add_query_arg( array( 'action' => 'bbp_toggle_reply_approve', 'reply_id' => $reply->ID ) );
     2253    $uri     = wp_nonce_url( $uri, 'approve-reply_' . $reply->ID );
     2254    $retval  = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-reply-approve-link">' . $display . '</a>' . $r['link_after'];
     2255
     2256    // Filter & return
     2257    return apply_filters( 'bbp_get_reply_approve_link', $retval, $r, $args );
     2258}
    22192259
    22202260/**
     
    22292269    echo bbp_get_reply_class( $reply_id, $classes );
    22302270}
    2231     /**
    2232      * Return the row class of a reply
    2233      *
    2234      * @since 2.0.0 bbPress (r2678)
    2235      *
    2236      * @param int $reply_id Optional. Reply ID
    2237      * @param array Extra classes you can pass when calling this function
    2238      * @return string Row class of the reply
    2239      */
    2240     function bbp_get_reply_class( $reply_id = 0, $classes = array() ) {
     2271
     2272/**
     2273 * Return the row class of a reply
     2274 *
     2275 * @since 2.0.0 bbPress (r2678)
     2276 *
     2277 * @param int $reply_id Optional. Reply ID
     2278 * @param array Extra classes you can pass when calling this function
     2279 * @return string Row class of the reply
     2280 */
     2281function bbp_get_reply_class( $reply_id = 0, $classes = array() ) {
    22412282    $bbp       = bbpress();
    22422283    $reply_id  = bbp_get_reply_id( $reply_id );
     
    22472288    $classes   = array_filter( (array) $classes );
    22482289    $count     = isset( $bbp->reply_query->current_post )
    2249     ? (int) $bbp->reply_query->current_post
    2250     : 1;
     2290        ? (int) $bbp->reply_query->current_post
     2291        : 1;
    22512292
    22522293    //  Stripes
    22532294    $even_odd = ( $count % 2 )
    2254     ? 'even'
    2255     : 'odd';
     2295        ? 'even'
     2296        : 'odd';
    22562297
    22572298    // Forum moderator replied to topic
    22582299    $forum_moderator = ( bbp_is_user_forum_moderator( $author_id, $forum_id ) === $author_id )
    2259     ? 'forum-mod'
    2260     : '';
     2300        ? 'forum-mod'
     2301        : '';
    22612302
    22622303    // Topic author replied to others
    22632304    $topic_author = ( bbp_get_topic_author_id( $topic_id ) === $author_id )
    2264     ? 'topic-author'
    2265     : '';
     2305        ? 'topic-author'
     2306        : '';
    22662307
    22672308    // Get reply classes
    22682309    $reply_classes = array(
    2269     'loop-item-'          . $count,
    2270     'user-id-'            . $author_id,
    2271     'bbp-parent-forum-'   . $forum_id,
    2272     'bbp-parent-topic-'   . $topic_id,
    2273     'bbp-reply-position-' . $reply_pos,
    2274     $even_odd,
    2275     $topic_author,
    2276     $forum_moderator
     2310        'loop-item-'          . $count,
     2311        'user-id-'            . $author_id,
     2312        'bbp-parent-forum-'   . $forum_id,
     2313        'bbp-parent-topic-'   . $topic_id,
     2314        'bbp-reply-position-' . $reply_pos,
     2315        $even_odd,
     2316        $topic_author,
     2317        $forum_moderator
    22772318    );
    22782319
     
    22862327    // Return
    22872328    return 'class="' . implode( ' ', $new_classes ) . '"';
    2288     }
     2329}
    22892330
    22902331/** Pagination ****************************************************************/
     
    23432384    echo bbp_get_topic_pagination_count();
    23442385}
    2345     /**
    2346      * Return the topic pagination count
    2347      *
    2348      * @since 2.0.0 bbPress (r2519)
    2349      *
    2350      * @return string Topic pagination count
    2351      */
    2352     function bbp_get_topic_pagination_count() {
     2386
     2387/**
     2388 * Return the topic pagination count
     2389 *
     2390 * @since 2.0.0 bbPress (r2519)
     2391 *
     2392 * @return string Topic pagination count
     2393 */
     2394function bbp_get_topic_pagination_count() {
    23532395    $bbp = bbpress();
    23542396
     
    23622404    $start_int = intval( ( $bbp->reply_query->paged - 1 ) * $ppp_int ) + 1;
    23632405    $to_int    = intval( ( $start_int + ( $ppp_int - 1 ) > $total_int )
    2364     ? $total_int
    2365     : $start_int + ( $ppp_int - 1 ) );
    2366 
    2367 // Format numbers for display
    2368 $count_num = bbp_number_format( $count_int );
    2369 $total_num = bbp_number_format( $total_int );
    2370 $from_num  = bbp_number_format( $start_int );
    2371 $to_num    = bbp_number_format( $to_int    );
    2372 
    2373 // We are threading replies
    2374 if ( bbp_thread_replies() ) {
    2375     $walker  = new BBP_Walker_Reply();
    2376     $threads = absint( $walker->get_number_of_root_elements( $bbp->reply_query->posts ) - 1 );
    2377     $retstr  = sprintf( _n( 'Viewing %1$s reply thread', 'Viewing %1$s reply threads', $threads, 'bbpress' ), bbp_number_format( $threads ) );
     2406        ? $total_int
     2407        : $start_int + ( $ppp_int - 1 ) );
     2408
     2409    // Format numbers for display
     2410    $count_num = bbp_number_format( $count_int );
     2411    $total_num = bbp_number_format( $total_int );
     2412    $from_num  = bbp_number_format( $start_int );
     2413    $to_num    = bbp_number_format( $to_int    );
     2414
     2415    // We are threading replies
     2416    if ( bbp_thread_replies() ) {
     2417        $walker  = new BBP_Walker_Reply();
     2418        $threads = absint( $walker->get_number_of_root_elements( $bbp->reply_query->posts ) - 1 );
     2419        /* translators: %s: Number of reply threads */
     2420        $retstr  = sprintf( _n( 'Viewing %1$s reply thread', 'Viewing %1$s reply threads', $threads, 'bbpress' ), bbp_number_format( $threads ) );
    23782421
    23792422    // We are not including the lead topic
    23802423    } elseif ( bbp_show_lead_topic() ) {
    23812424
    2382     // Several replies in a topic with a single page
    2383     if ( empty( $to_num ) ) {
    2384         $retstr = sprintf( _n( 'Viewing %1$s reply', 'Viewing %1$s replies', $total_int, 'bbpress' ), $total_num );
     2425        // Several replies in a topic with a single page
     2426        if ( empty( $to_num ) ) {
     2427            /* translators: %1$s: Number of replies */
     2428            $retstr = sprintf( _n( 'Viewing %1$s reply', 'Viewing %1$s replies', $total_int, 'bbpress' ), $total_num );
    23852429
    23862430        // Several replies in a topic with several pages
    23872431        } else {
    2388         $retstr = sprintf( _n( 'Viewing %2$s replies (of %4$s total)', 'Viewing %1$s replies - %2$s through %3$s (of %4$s total)', $count_int, 'bbpress' ), $count_num, $from_num, $to_num, $total_num );  //phpcs:ignore
     2432            /* translators: 1: Number of replies being viewed, 2: Starting reply number, 3: Ending reply number, 4: Total replies */
     2433            $retstr = sprintf( _n( 'Viewing %2$s replies (of %4$s total)', 'Viewing %1$s replies - %2$s through %3$s (of %4$s total)', $count_int, 'bbpress' ), $count_num, $from_num, $to_num, $total_num );  //phpcs:ignore
    23892434        }
    23902435
     
    23922437    } else {
    23932438
    2394 // Several posts in a topic with a single page
    2395 if ( empty( $to_num ) ) {
     2439        // Several posts in a topic with a single page
     2440        if ( empty( $to_num ) ) {
     2441            /* translators: %1$s: Number of posts */
    23962442            $retstr = sprintf( _n( 'Viewing %1$s post', 'Viewing %1$s posts', $total_int, 'bbpress' ), $total_num );
    23972443
    2398             // Several posts in a topic with several pages
    2399     } else {
    2400                     $retstr = sprintf( _n( 'Viewing %2$s post (of %4$s total)', 'Viewing %1$s posts - %2$s through %3$s (of %4$s total)', $count_int, 'bbpress' ), $count_num, $from_num, $to_num, $total_num );  //phpcs:ignore
     2444        // Several posts in a topic with several pages
     2445        } else {
     2446            /* translators: 1: Number of posts being viewed, 2: Starting post number, 3: Ending post number, 4: Total posts */
     2447            $retstr = sprintf( _n( 'Viewing %2$s post (of %4$s total)', 'Viewing %1$s posts - %2$s through %3$s (of %4$s total)', $count_int, 'bbpress' ), $count_num, $from_num, $to_num, $total_num );  //phpcs:ignore
    24012448        }
    24022449    }
    24032450
    2404 // Escape results of _n()
    2405 $retstr = esc_html( $retstr );
    2406 
    2407 // Filter & return
    2408 return apply_filters( 'bbp_get_topic_pagination_count', $retstr );
    2409     }
     2451    // Escape results of _n()
     2452    $retstr = esc_html( $retstr );
     2453
     2454    // Filter & return
     2455    return apply_filters( 'bbp_get_topic_pagination_count', $retstr );
     2456}
    24102457
    24112458/**
     
    24172464    echo bbp_get_topic_pagination_links();
    24182465}
    2419     /**
    2420      * Return topic pagination links
    2421      *
    2422      * @since 2.0.0 bbPress (r2519)
    2423      *
    2424      * @return string Topic pagination links
    2425      */
    2426     function bbp_get_topic_pagination_links() {
     2466
     2467/**
     2468 * Return topic pagination links
     2469 *
     2470 * @since 2.0.0 bbPress (r2519)
     2471 *
     2472 * @return string Topic pagination links
     2473 */
     2474function bbp_get_topic_pagination_links() {
    24272475    $bbp = bbpress();
    24282476
    24292477    if ( ! isset( $bbp->reply_query->pagination_links ) || empty( $bbp->reply_query->pagination_links ) ) {
    24302478        return false;
    2431         }
     2479    }
    24322480
    24332481    // Filter & return
    24342482    return apply_filters( 'bbp_get_topic_pagination_links', $bbp->reply_query->pagination_links );
    2435     }
     2483}
    24362484
    24372485/** Forms *********************************************************************/
     
    24452493    echo bbp_get_form_reply_content();
    24462494}
    2447     /**
    2448      * Return the value of reply content field
    2449      *
    2450      * @since 2.0.0 bbPress (r3130)
    2451      *
    2452      * @return string Value of reply content field
    2453      */
    2454     function bbp_get_form_reply_content() {
     2495
     2496/**
     2497 * Return the value of reply content field
     2498 *
     2499 * @since 2.0.0 bbPress (r3130)
     2500 *
     2501 * @return string Value of reply content field
     2502 */
     2503function bbp_get_form_reply_content() {
    24552504
    24562505    // Get _POST data
     
    24582507        $reply_content = wp_unslash( $_POST['bbp_reply_content'] );
    24592508
    2460         // Get edit data
    2461         } elseif ( bbp_is_reply_edit() ) {
     2509    // Get edit data
     2510    } elseif ( bbp_is_reply_edit() ) {
    24622511        $reply_content = bbp_get_global_post_field( 'post_content', 'raw' );
    24632512
    2464         // No data
    2465         } else {
     2513    // No data
     2514    } else {
    24662515        $reply_content = '';
    2467         }
     2516    }
    24682517
    24692518    // Filter & return
    24702519    return apply_filters( 'bbp_get_form_reply_content', $reply_content );
    2471     }
     2520}
    24722521
    24732522/**
     
    24802529}
    24812530
    2482     /**
    2483     * Return the value of reply to field
    2484     *
    2485     * @since 2.4.0 bbPress (r4944)
    2486     *
    2487     * @return string Value of reply to field
    2488     */
    2489     function bbp_get_form_reply_to() {
     2531/**
     2532 * Return the value of reply to field
     2533 *
     2534 * @since 2.4.0 bbPress (r4944)
     2535 *
     2536 * @return string Value of reply to field
     2537 */
     2538function bbp_get_form_reply_to() {
    24902539
    24912540    // Set initial value
     
    24952544    if ( isset( $_REQUEST['bbp_reply_to'] ) ) {
    24962545        $reply_to = bbp_validate_reply_to( $_REQUEST['bbp_reply_to'] );
    2497         }
     2546    }
    24982547
    24992548    // If empty, get from meta
    25002549    if ( empty( $reply_to ) ) {
    25012550        $reply_to = bbp_get_reply_to();
    2502         }
     2551    }
    25032552
    25042553    // Filter & return
    25052554    return apply_filters( 'bbp_get_form_reply_to', $reply_to );
    2506     }
     2555}
    25072556
    25082557/**
     
    25172566    echo bbp_get_reply_to_dropdown( $reply_id );
    25182567}
    2519     /**
    2520      * Return a select box allowing to pick which topic/reply a reply belongs.
    2521      *
    2522      * @since 2.6.0 bbPress (r5387)
    2523      *
    2524      * @param int $reply_id
    2525      *
    2526      * @return string The dropdown
    2527      */
    2528     function bbp_get_reply_to_dropdown( $reply_id = 0 ) {
     2568
     2569/**
     2570 * Return a select box allowing to pick which topic/reply a reply belongs.
     2571 *
     2572 * @since 2.6.0 bbPress (r5387)
     2573 *
     2574 * @param int $reply_id
     2575 *
     2576 * @return string The dropdown
     2577 */
     2578function bbp_get_reply_to_dropdown( $reply_id = 0 ) {
    25292579
    25302580    // Validate the reply data
     
    25352585    // Get the replies
    25362586    $posts = get_posts( array(
    2537     'post_type'   => bbp_get_reply_post_type(),
    2538     'post_status' => bbp_get_public_status_id(),
    2539     'post_parent' => $topic_id,
    2540     'numberposts' => -1,
    2541     'orderby'     => 'menu_order',
    2542     'order'       => 'ASC',
     2587        'post_type'   => bbp_get_reply_post_type(),
     2588        'post_status' => bbp_get_public_status_id(),
     2589        'post_parent' => $topic_id,
     2590        'numberposts' => -1,
     2591        'orderby'     => 'menu_order',
     2592        'order'       => 'ASC',
    25432593    ) );
    25442594
    2545 // Append `reply_to` for each reply so it can be walked
    2546 foreach ( $posts as &$post ) {
    2547 
    2548     // Check for reply post type
    2549     $_reply_to = bbp_get_reply_to( $post->ID );
    2550 
    2551     // Make sure it's a reply to a reply
    2552     if ( empty( $_reply_to ) || ( $topic_id === $_reply_to ) ) {
    2553         $_reply_to = 0;
     2595    // Append `reply_to` for each reply so it can be walked
     2596    foreach ( $posts as &$post ) {
     2597
     2598        // Check for reply post type
     2599        $_reply_to = bbp_get_reply_to( $post->ID );
     2600
     2601        // Make sure it's a reply to a reply
     2602        if ( empty( $_reply_to ) || ( $topic_id === $_reply_to ) ) {
     2603            $_reply_to = 0;
    25542604        }
    25552605
    2556     // Add reply_to to the post object so we can walk it later
    2557     $post->reply_to = $_reply_to;
    2558     }
    2559 
    2560 // Default "None" text
    2561 $show_none = ( 0 === $reply_id )
    2562 ? esc_attr_x( 'None', 'Default reply to dropdown text', 'bbpress' )
    2563 : sprintf( esc_attr__( '%1$s - %2$s', 'bbpress' ), $topic_id, bbp_get_topic_title( $topic_id ) );
    2564 
    2565 // Get the dropdown and return it
    2566 $retval = bbp_get_dropdown( array(
    2567 'show_none'    => $show_none,
    2568 'select_id'    => 'bbp_reply_to',
    2569 'select_class' => 'bbp_dropdown',
    2570 'exclude'      => $reply_id,
    2571 'selected'     => $reply_to,
    2572 'post_parent'  => $topic_id,
    2573 'post_type'    => bbp_get_reply_post_type(),
    2574 'max_depth'    => bbp_thread_replies_depth(),
    2575 'page'         => 1,
    2576 'per_page'     => -1,
    2577 'walker'       => new BBP_Walker_Reply_Dropdown(),
    2578 'posts'        => $posts
    2579 ) );
    2580 
    2581 // Filter & return
    2582 return apply_filters( 'bbp_get_reply_to_dropdown', $retval, $reply_id, $reply_to, $topic_id );
    2583     }
     2606        // Add reply_to to the post object so we can walk it later
     2607        $post->reply_to = $_reply_to;
     2608    }
     2609
     2610    // Default "None" text
     2611    $show_none = ( 0 === $reply_id )
     2612        ? esc_attr_x( 'None', 'Default reply to dropdown text', 'bbpress' )
     2613        /* translators: 1: Topic ID, 2: Topic title */
     2614        : sprintf( esc_attr__( '%1$s - %2$s', 'bbpress' ), $topic_id, bbp_get_topic_title( $topic_id ) );
     2615
     2616    // Get the dropdown and return it
     2617    $retval = bbp_get_dropdown(
     2618        array(
     2619            'show_none'    => $show_none,
     2620            'select_id'    => 'bbp_reply_to',
     2621            'select_class' => 'bbp_dropdown',
     2622            'exclude'      => $reply_id,
     2623            'selected'     => $reply_to,
     2624            'post_parent'  => $topic_id,
     2625            'post_type'    => bbp_get_reply_post_type(),
     2626            'max_depth'    => bbp_thread_replies_depth(),
     2627            'page'         => 1,
     2628            'per_page'     => -1,
     2629            'walker'       => new BBP_Walker_Reply_Dropdown(),
     2630            'posts'        => $posts
     2631        )
     2632    );
     2633
     2634    // Filter & return
     2635    return apply_filters( 'bbp_get_reply_to_dropdown', $retval, $reply_id, $reply_to, $topic_id );
     2636}
    25842637
    25852638/**
     
    25912644    echo bbp_get_form_reply_log_edit();
    25922645}
    2593     /**
    2594      * Return checked value of reply log edit field
    2595      *
    2596      * @since 2.0.0 bbPress (r3130)
    2597      *
    2598      * @return string Reply log edit checked value
    2599      */
    2600     function bbp_get_form_reply_log_edit() {
     2646
     2647/**
     2648 * Return checked value of reply log edit field
     2649 *
     2650 * @since 2.0.0 bbPress (r3130)
     2651 *
     2652 * @return string Reply log edit checked value
     2653 */
     2654function bbp_get_form_reply_log_edit() {
    26012655
    26022656    // Get _POST data
     
    26042658        $reply_revision = (bool) $_POST['bbp_log_reply_edit'];
    26052659
    2606         // No data
    2607         } else {
     2660    // No data
     2661    } else {
    26082662        $reply_revision = true;
    2609         }
     2663    }
    26102664
    26112665    // Get checked output
     
    26142668    // Filter & return
    26152669    return apply_filters( 'bbp_get_form_reply_log_edit', $checked, $reply_revision );
    2616     }
     2670}
    26172671
    26182672/**
     
    26242678    echo bbp_get_form_reply_edit_reason();
    26252679}
    2626     /**
    2627      * Return the value of the reply edit reason
    2628      *
    2629      * @since 2.0.0 bbPress (r3130)
    2630      *
    2631      * @return string Reply edit reason value
    2632      */
    2633     function bbp_get_form_reply_edit_reason() {
     2680
     2681/**
     2682 * Return the value of the reply edit reason
     2683 *
     2684 * @since 2.0.0 bbPress (r3130)
     2685 *
     2686 * @return string Reply edit reason value
     2687 */
     2688function bbp_get_form_reply_edit_reason() {
    26342689
    26352690    // Get _POST data
     
    26372692        $reply_edit_reason = wp_unslash( $_POST['bbp_reply_edit_reason'] );
    26382693
    2639         // No data
    2640         } else {
     2694    // No data
     2695    } else {
    26412696        $reply_edit_reason = '';
    2642         }
     2697    }
    26432698
    26442699    // Filter & return
    26452700    return apply_filters( 'bbp_get_form_reply_edit_reason', $reply_edit_reason );
    2646     }
     2701}
    26472702
    26482703/**
     
    26602715    echo bbp_get_form_reply_status_dropdown( $args );
    26612716}
    2662     /**
    2663      * Returns reply status dropdown
    2664      *
    2665      * This dropdown is only intended to be seen by users with the 'moderate'
    2666      * capability. Because of this, no additional capability checks are performed
    2667      * within this function to check available reply statuses.
    2668      *
    2669      * @since 2.6.0 bbPress (r5399)
    2670      *
    2671      * @param $args This function supports these arguments:
    2672      *  - select_id: Select id. Defaults to bbp_reply_status
    2673      *  - tab: Deprecated. Tabindex
    2674      *  - reply_id: Reply id
    2675      *  - selected: Override the selected option
    2676      */
    2677     function bbp_get_form_reply_status_dropdown( $args = array() ) {
     2717
     2718/**
     2719 * Returns reply status dropdown
     2720 *
     2721 * This dropdown is only intended to be seen by users with the 'moderate'
     2722 * capability. Because of this, no additional capability checks are performed
     2723 * within this function to check available reply statuses.
     2724 *
     2725 * @since 2.6.0 bbPress (r5399)
     2726 *
     2727 * @param $args This function supports these arguments:
     2728 *  - select_id: Select id. Defaults to bbp_reply_status
     2729 *  - tab: Deprecated. Tabindex
     2730 *  - reply_id: Reply id
     2731 *  - selected: Override the selected option
     2732 */
     2733function bbp_get_form_reply_status_dropdown( $args = array() ) {
    26782734
    26792735    // Parse arguments against default values
    26802736    $r = bbp_parse_args( $args, array(
    2681     'select_id'    => 'bbp_reply_status',
    2682     'select_class' => 'bbp_dropdown',
    2683     'tab'          => false,
    2684     'reply_id'     => 0,
    2685     'selected'     => false
     2737        'select_id'    => 'bbp_reply_status',
     2738        'select_class' => 'bbp_dropdown',
     2739        'tab'          => false,
     2740        'reply_id'     => 0,
     2741        'selected'     => false
    26862742    ), 'reply_status_dropdown' );
    26872743
    2688 // No specific selected value passed
    2689 if ( empty( $r['selected'] ) ) {
    2690 
    2691     // Post value is passed
    2692     if ( bbp_is_reply_form_post_request() && isset( $_POST[ $r['select_id'] ] ) ) {
    2693         $r['selected'] = sanitize_key( $_POST[ $r['select_id'] ] );
     2744    // No specific selected value passed
     2745    if ( empty( $r['selected'] ) ) {
     2746
     2747        // Post value is passed
     2748        if ( bbp_is_reply_form_post_request() && isset( $_POST[ $r['select_id'] ] ) ) {
     2749            $r['selected'] = sanitize_key( $_POST[ $r['select_id'] ] );
    26942750
    26952751        // No Post value was passed
    26962752        } else {
    26972753
    2698         // Edit reply
    2699         if ( bbp_is_reply_edit() ) {
    2700             $r['reply_id'] = bbp_get_reply_id( $r['reply_id'] );
    2701             $r['selected'] = bbp_get_reply_status( $r['reply_id'] );
     2754            // Edit reply
     2755            if ( bbp_is_reply_edit() ) {
     2756                $r['reply_id'] = bbp_get_reply_id( $r['reply_id'] );
     2757                $r['selected'] = bbp_get_reply_status( $r['reply_id'] );
    27022758
    27032759            // New reply
    27042760            } else {
    2705             $r['selected'] = bbp_get_public_status_id();
     2761                $r['selected'] = bbp_get_public_status_id();
    27062762            }
    2707             }
    2708     }
    2709 
    2710 // Start an output buffer, we'll finish it after the select loop
    2711 ob_start(); ?>
    2712 
    2713         <select name="<?php echo esc_attr( $r['select_id'] ); ?>" id="<?php echo esc_attr( $r['select_id'] ); ?>_select" class="<?php echo esc_attr( $r['select_class'] ); ?>"<?php bbp_tab_index_attribute( $r['tab'] ); ?>>
    2714 
    2715             <?php foreach ( bbp_get_reply_statuses( $r['reply_id'] ) as $key => $label ) : ?>
    2716 
    2717                 <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $r['selected'] ); ?>><?php echo esc_html( $label ); ?></option>
    2718 
    2719             <?php endforeach; ?>
    2720 
    2721         </select>
    2722 
    2723         <?php
    2724 
    2725         // Filter & return
    2726         return apply_filters( 'bbp_get_form_reply_status_dropdown', ob_get_clean(), $r, $args );
    2727     }
     2763        }
     2764    }
     2765
     2766    // Start an output buffer, we'll finish it after the select loop
     2767    ob_start(); ?>
     2768
     2769    <select name="<?php echo esc_attr( $r['select_id'] ); ?>" id="<?php echo esc_attr( $r['select_id'] ); ?>_select" class="<?php echo esc_attr( $r['select_class'] ); ?>"<?php bbp_tab_index_attribute( $r['tab'] ); ?>>
     2770
     2771        <?php foreach ( bbp_get_reply_statuses( $r['reply_id'] ) as $key => $label ) : ?>
     2772
     2773            <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $r['selected'] ); ?>><?php echo esc_html( $label ); ?></option>
     2774
     2775        <?php endforeach; ?>
     2776
     2777    </select>
     2778
     2779    <?php
     2780
     2781    // Filter & return
     2782    return apply_filters( 'bbp_get_form_reply_status_dropdown', ob_get_clean(), $r, $args );
     2783}
    27282784
    27292785/**
Note: See TracChangeset for help on using the changeset viewer.