Skip to:
Content

bbPress.org

Changeset 7360


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.

Location:
trunk
Files:
51 edited

Legend:

Unmodified
Added
Removed
  • trunk/.gitignore

    r7353 r7360  
    1515/phpunit.xml
    1616/pnpm-lock.yaml
    17 .phpunit.result.cache
    1817
    1918# Output directory.
  • trunk/phpcs.xml.dist

    r7359 r7360  
    492492    </rule>
    493493
    494     <rule ref="WordPress.Arrays.ArrayIndentation.CloseBraceNotAligned">
    495         <exclude-pattern>/src/*</exclude-pattern>
    496     </rule>
    497 
    498494    <rule ref="WordPress.Arrays.ArrayIndentation.ItemNotAligned">
    499495        <exclude-pattern>/src/*</exclude-pattern>
     
    549545
    550546    <rule ref="WordPress.Files.FileName.InvalidClassFileName">
    551         <exclude-pattern>/src/*</exclude-pattern>
     547    <exclude-pattern>/src/*</exclude-pattern>
    552548    </rule>
    553549
     
    565561
    566562    <rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound">
    567         <exclude-pattern>/src/*</exclude-pattern>
     563    <exclude-pattern>/src/*</exclude-pattern>
    568564    </rule>
    569565
     
    680676    </rule>
    681677
    682     <rule ref="WordPress.WP.I18n.MissingTranslatorsComment">
    683         <exclude-pattern>/src/*</exclude-pattern>
    684     </rule>
    685 
    686     <rule ref="WordPress.WP.I18n.NonSingularStringLiteralText">
    687         <exclude-pattern>/src/*</exclude-pattern>
    688     </rule>
    689 
    690     <rule ref="WordPress.WP.PostsPerPage.posts_per_page_posts_per_page">
    691         <exclude-pattern>/src/*</exclude-pattern>
    692     </rule>
    693 
    694     <rule ref="WordPress.WhiteSpace.ControlStructureSpacing.ExtraSpaceAfterOpenParenthesis">
    695         <exclude-pattern>/src/*</exclude-pattern>
    696     </rule>
    697 
    698     <rule ref="WordPress.WhiteSpace.ControlStructureSpacing.ExtraSpaceBeforeCloseParenthesis">
    699         <exclude-pattern>/src/*</exclude-pattern>
    700     </rule>
    701 
    702     <rule ref="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceAfterOpenParenthesis">
    703         <exclude-pattern>/src/*</exclude-pattern>
    704     </rule>
    705 
    706     <rule ref="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceBeforeCloseParenthesis">
    707         <exclude-pattern>/src/*</exclude-pattern>
    708     </rule>
    709 
    710     <rule ref="WordPress.WhiteSpace.OperatorSpacing.NoSpaceAfter">
    711         <exclude-pattern>/src/*</exclude-pattern>
    712     </rule>
    713 
    714     <rule ref="WordPress.WhiteSpace.OperatorSpacing.NoSpaceBefore">
    715         <exclude-pattern>/src/*</exclude-pattern>
    716     </rule>
    717 
    718     <rule ref="WordPress.WhiteSpace.OperatorSpacing.SpacingAfter">
    719         <exclude-pattern>/src/*</exclude-pattern>
    720     </rule>
    721 
    722     <rule ref="WordPress.WhiteSpace.OperatorSpacing.SpacingBefore">
    723         <exclude-pattern>/src/*</exclude-pattern>
    724     </rule>
    725 
    726678</ruleset>
  • trunk/src/bbpress.php

    r7351 r7360  
    599599            apply_filters( 'bbp_register_closed_post_status', array(
    600600                'label'                     => _x( 'Closed', 'post', 'bbpress' ),
     601                /* translators: %s: Number of closed items */
    601602                'label_count'               => _nx_noop( 'Closed <span class="count">(%s)</span>', 'Closed <span class="count">(%s)</span>', 'post', 'bbpress' ),
    602603                'public'                    => true,
     
    612613            apply_filters( 'bbp_register_spam_post_status', array(
    613614                'label'                     => _x( 'Spam', 'post', 'bbpress' ),
     615                /* translators: %s: Number of spammed items */
    614616                'label_count'               => _nx_noop( 'Spam <span class="count">(%s)</span>', 'Spam <span class="count">(%s)</span>', 'post', 'bbpress' ),
    615617                'protected'                 => true,
     
    626628            apply_filters( 'bbp_register_orphan_post_status', array(
    627629                'label'                     => _x( 'Orphan', 'post', 'bbpress' ),
     630                /* translators: %s: Number of orphaned items */
    628631                'label_count'               => _nx_noop( 'Orphan <span class="count">(%s)</span>', 'Orphans <span class="count">(%s)</span>', 'post', 'bbpress' ),
    629632                'protected'                 => true,
     
    640643            apply_filters( 'bbp_register_hidden_post_status', array(
    641644                'label'                     => _x( 'Hidden', 'post', 'bbpress' ),
     645                /* translators: %s: Number of hidden items */
    642646                'label_count'               => _nx_noop( 'Hidden <span class="count">(%s)</span>', 'Hidden <span class="count">(%s)</span>', 'post', 'bbpress' ),
    643647                'private'                   => true,
  • trunk/src/includes/admin/classes/class-bbp-admin.php

    r7357 r7360  
    261261            $bbp_dashicon = '<span class="bbpress-logo-icon"></span>';
    262262            $message      = $bbp_dashicon . sprintf(
    263                 esc_html__( 'bbPress requires a manual database upgrade. %1$s or %1$s.', 'bbpress' ),
     263                /* translators: 1: "Learn More" link, 2: "Hide For Now" link */
     264                esc_html__( 'bbPress requires a manual database upgrade. %1$s or %2$s.', 'bbpress' ),
    264265                $upgrade_link,
    265266                $dismiss_link
     
    10331034        if ( ! empty( $topics ) ) {
    10341035            foreach ( (array) $topics as $post ) {
     1036                /* translators: 1: Topic ID, 2: Topic title */
    10351037                printf( esc_html__( '%1$s - %2$s', 'bbpress' ), bbp_get_topic_id( $post->ID ), bbp_get_topic_title( $post->ID ) . "\n" );
    10361038            }
     
    11131115        if ( ! empty( $users_query->results ) ) {
    11141116            foreach ( (array) $users_query->results as $user ) {
     1117                /* translators: 1: User ID, 2: User nicename */
    11151118                printf( esc_html__( '%1$s - %2$s', 'bbpress' ), bbp_get_user_id( $user->ID ), bbp_get_user_nicename( $user->ID, array( 'force' => $user->user_nicename ) ) . "\n" );
    11161119            }
     
    11311134        list( $display_version ) = explode( '-', bbp_get_version() ); ?>
    11321135
    1133         <h1 class="wp-heading-inline"><?php printf( esc_html__( 'Welcome to bbPress %s', 'bbpress' ), $display_version ); ?></h1>
     1136        <h1 class="wp-heading-inline">
     1137            <?php
     1138            printf(
     1139                /* translators: %s: bbPress version number */
     1140                esc_html__( 'Welcome to bbPress %s', 'bbpress' ), $display_version
     1141            );
     1142            ?>
     1143        </h1>
    11341144        <hr class="wp-header-end">
    11351145        <div class="about-text"><?php printf( esc_html__( 'bbPress is fun to use, contains no artificial colors or preservatives, and is absolutely wonderful in every environment. Your community is going to love using it.', 'bbpress' ), $display_version ); ?></div>
     
    14671477                            // Site errored out, no response?
    14681478                            if ( is_wp_error( $response ) ) {
    1469                                 wp_die( sprintf( esc_html__( 'Warning! Problem updating %1$s. Your server may not be able to connect to sites running on it. Error message: %2$s', 'bbpress' ), $site_url, '<em>' . $response->get_error_message() . '</em>' ) );
     1479                                wp_die(
     1480                                    sprintf(
     1481                                        /* translators: 1: Site URL, 2: Error message */
     1482                                        esc_html__( 'Warning! Problem updating %1$s. Your server may not be able to connect to sites running on it. Error message: %2$s', 'bbpress' ),
     1483                                        $site_url,
     1484                                        '<em>' . $response->get_error_message() . '</em>'
     1485                                    )
     1486                                );
    14701487                            }
    14711488
  • trunk/src/includes/admin/classes/class-bbp-converter.php

    r7357 r7360  
    177177                'status_stopped'      => esc_html__( 'Stopped',               'bbpress' ),
    178178                'status_starting'     => esc_html__( 'Starting',              'bbpress' ),
     179                /* translators: %s: Current step number or name */
    179180                'status_up_next'      => esc_html__( 'Doing step %s...',      'bbpress' ),
     181                /* translators: %s: Number of seconds until next action */
    180182                'status_counting'     => esc_html__( 'Next in %s seconds...', 'bbpress' )
    181183            )
     
    515517            } else {
    516518                $this->bump_start();
    517                 $this->converter_response( sprintf( esc_html__( 'Deleting previously converted data (%1$s through %2$s)', 'bbpress' ), $this->start, $this->max ) );
     519                $this->converter_response(
     520                    sprintf(
     521                        /* translators: 1: Start number, 2: End number */
     522                        esc_html__( 'Deleting previously converted data (%1$s through %2$s)', 'bbpress' ), $this->start, $this->max
     523                    )
     524                );
    518525            }
    519526
     
    541548            } else {
    542549                $this->bump_start();
     550                /* translators: 1: Start user number, 2: End user number, 3: Total number of users */
    543551                $this->converter_response( sprintf( esc_html__( 'Converting users (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) );
    544552            }
     
    564572            } else {
    565573                $this->bump_start();
     574                /* translators: 1: Start password number, 2: End password number */
    566575                $this->converter_response( sprintf( esc_html__( 'Delete default WordPress user passwords (%1$s through %2$s)', 'bbpress' ), $this->start, $this->max ) );
    567576            }
     
    586595        } else {
    587596            $this->bump_start();
     597            /* translators: 1: Start forum number, 2: End forum number, 3: Total number of forums */
    588598            $this->converter_response( sprintf( esc_html__( 'Converting forums (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) );
    589599        }
     
    604614        } else {
    605615            $this->bump_start();
     616            /* translators: 1: Start forum number, 2: End forum number, 3: Total number of forums */
    606617            $this->converter_response( sprintf( esc_html__( 'Calculating forum hierarchy (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) );
    607618        }
     
    622633        } else {
    623634            $this->bump_start();
     635            /* translators: 1: Start forum subscription number, 2: End forum subscription number, 3: Total number of forum subscriptions */
    624636            $this->converter_response( sprintf( esc_html__( 'Converting forum subscriptions (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) );
    625637        }
     
    640652        } else {
    641653            $this->bump_start();
     654            /* translators: 1: Start topic number, 2: End topic number, 3: Total number of topics */
    642655            $this->converter_response( sprintf( esc_html__( 'Converting topics (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) );
    643656        }
     
    658671        } else {
    659672            $this->bump_start();
     673            /* translators: 1: Start anonymous topic author number, 2: End anonymous topic author number, 3: Total number of anonymous topic authors */
    660674            $this->converter_response( sprintf( esc_html__( 'Converting anonymous topic authors (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) );
    661675        }
     
    676690        } else {
    677691            $this->bump_start();
     692            /* translators: 1: Start sticky topic number, 2: End sticky topic number, 3: Total number of sticky topics */
    678693            $this->converter_response( sprintf( esc_html__( 'Calculating topic stickies (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) );
    679694        }
     
    694709        } else {
    695710            $this->bump_start();
     711            /* translators: 1: Start super sticky topic number, 2: End super sticky topic number, 3: Total number of super sticky topics */
    696712            $this->converter_response( sprintf( esc_html__( 'Calculating topic super stickies (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) );
    697713        }
     
    712728        } else {
    713729            $this->bump_start();
     730            /* translators: 1: Start closed topic number, 2: End closed topic number, 3: Total number of closed topics */
    714731            $this->converter_response( sprintf( esc_html__( 'Calculating closed topics (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) );
    715732        }
     
    730747        } else {
    731748            $this->bump_start();
     749            /* translators: 1: Start topic tag number, 2: End topic tag number, 3: Total number of topic tags */
    732750            $this->converter_response( sprintf( esc_html__( 'Converting topic tags (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) );
    733751        }
     
    748766        } else {
    749767            $this->bump_start();
     768            /* translators: 1: Start topic subscription number, 2: End topic subscription number, 3: Total number of topic subscriptions */
    750769            $this->converter_response( sprintf( esc_html__( 'Converting topic subscriptions (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) );
    751770        }
     
    766785        } else {
    767786            $this->bump_start();
     787            /* translators: 1: Start favorite number, 2: End favorite number, 3: Total number of favorites */
    768788            $this->converter_response( sprintf( esc_html__( 'Converting favorites (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) );
    769789        }
     
    784804        } else {
    785805            $this->bump_start();
     806            /* translators: 1: Start reply number, 2: End reply number, 3: Total number of replies */
    786807            $this->converter_response( sprintf( esc_html__( 'Converting replies (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) );
    787808        }
     
    802823        } else {
    803824            $this->bump_start();
     825            /* translators: 1: Start anonymous reply author number, 2: End anonymous reply author number, 3: Total number of anonymous reply authors */
    804826            $this->converter_response( sprintf( esc_html__( 'Converting anonymous reply authors (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) );
    805827        }
     
    820842        } else {
    821843            $this->bump_start();
     844            /* translators: 1: Start threaded reply number, 2: End threaded reply number, 3: Total number of threaded replies */
    822845            $this->converter_response( sprintf( esc_html__( 'Calculating threaded replies parents (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) );
    823846        }
  • trunk/src/includes/admin/converters/Kunena1.php

    r7352 r7360  
    453453     * as one value. Array values are auto sanitized by WordPress.
    454454     */
    455     public function callback_savepass($field, $row) {
    456         $pass_array = array('hash' => $field, 'salt' => $row['salt']);
     455    public function callback_savepass( $field, $row ) {
     456        $pass_array = array(
     457            'hash' => $field,
     458            'salt' => $row['salt']
     459        );
    457460        return $pass_array;
    458461    }
     
    462465     * to a pass the user has typed in.
    463466     */
    464     public function authenticate_pass($password, $serialized_pass) {
    465         $pass_array = unserialize($serialized_pass);
    466         return ( md5(md5($password) . $pass_array['salt']) == $pass_array['hash'] );
     467    public function authenticate_pass( $password, $serialized_pass ) {
     468        $pass_array = unserialize( $serialized_pass );
     469
     470        return ( md5( md5( $password ) . $pass_array['salt'] ) == $pass_array['hash'] );
    467471    }
    468472
  • trunk/src/includes/admin/converters/Kunena2.php

    r7352 r7360  
    484484     * as one value. Array values are auto sanitized by WordPress.
    485485     */
    486     public function callback_savepass($field, $row) {
    487         $pass_array = array('hash' => $field, 'salt' => $row['salt']);
     486    public function callback_savepass( $field, $row ) {
     487        $pass_array = array(
     488            'hash' => $field,
     489            'salt' => $row['salt']
     490        );
    488491        return $pass_array;
    489492    }
     
    493496     * to a pass the user has typed in.
    494497     */
    495     public function authenticate_pass($password, $serialized_pass) {
    496         $pass_array = unserialize($serialized_pass);
    497         return ( md5(md5($password) . $pass_array['salt']) == $pass_array['hash'] );
     498    public function authenticate_pass( $password, $serialized_pass ) {
     499        $pass_array = unserialize( $serialized_pass );
     500        return ( md5( md5( $password ) . $pass_array['salt'] ) == $pass_array['hash'] );
    498501    }
    499502    /**
  • trunk/src/includes/admin/converters/phpBB.php

    r7357 r7360  
    793793        }
    794794
    795         $output = substr($setting, 0, 12);
    796         $output .= $this->_hash_encode64($hash, 16, $itoa64);
     795        $output = substr( $setting, 0, 12 );
     796        $output .= $this->_hash_encode64( $hash, 16, $itoa64 );
    797797
    798798        return $output;
  • trunk/src/includes/admin/forums.php

    r7352 r7360  
    449449            case 'opened' :
    450450                $message = ( true === $is_failure )
     451                    /* translators: %1$s: Forum title */
    451452                    ? sprintf( esc_html__( 'There was a problem opening the forum "%1$s".', 'bbpress' ), $forum_title )
     453                    /* translators: %1$s: Forum title */
    452454                    : sprintf( esc_html__( 'Forum "%1$s" successfully opened.',             'bbpress' ), $forum_title );
    453455                break;
     
    455457            case 'closed' :
    456458                $message = ( true === $is_failure )
     459                    /* translators: %1$s: Forum title */
    457460                    ? sprintf( esc_html__( 'There was a problem closing the forum "%1$s".', 'bbpress' ), $forum_title )
     461                    /* translators: %1$s: Forum title */
    458462                    : sprintf( esc_html__( 'Forum "%1$s" successfully closed.',             'bbpress' ), $forum_title );
    459463                break;
     
    723727
    724728            // Restored from revision
    725             // translators: %s: date and time of the revision
     729            /* translators: %s: date and time of the revision */
    726730            5 => isset( $_GET['revision'] )
     731                /* translators: %s: Date and time of the revision */
    727732                ? sprintf( esc_html__( 'Forum restored to revision from %s', 'bbpress' ), wp_post_revision_title( (int) $_GET['revision'], false ) )
    728733                : false,
     
    751756                '%1$s <a target="_blank" href="%2$s">%3$s</a>',
    752757                sprintf(
     758                    /* translators: %s: Publish box date format, see http://php.net/date */
    753759                    esc_html__( 'Forum scheduled for: %s.', 'bbpress' ),
    754                     // translators: Publish box date format, see http://php.net/date
    755760                    '<strong>' . date_i18n( __( 'M j, Y @ G:i', 'bbpress' ), strtotime( $post_date ) ) . '</strong>'
    756761                ),
  • trunk/src/includes/admin/metaboxes.php

    r7357 r7360  
    4141    if ( isset( $r['user_count'] ) ) {
    4242        $link       = admin_url( 'users.php' );
     43        /* translators: %s: Number of users */
    4344        $text       = sprintf( _n( '%s User', '%s Users', $r['user_count_int'], 'bbpress' ), $r['user_count'] );
    4445        $elements[] = current_user_can( 'edit_users' )
     
    5051    if ( isset( $r['forum_count'] ) ) {
    5152        $link       = add_query_arg( array( 'post_type' => bbp_get_forum_post_type() ), admin_url( 'edit.php' ) );
     53        /* translators: %s: Number of forums */
    5254        $text       = sprintf( _n( '%s Forum', '%s Forums', $r['forum_count_int'], 'bbpress' ), $r['forum_count'] );
    5355        $elements[] = current_user_can( 'publish_forums' )
     
    5961    if ( isset( $r['topic_count'] ) ) {
    6062        $link       = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit.php' ) );
     63        /* translators: %s: Number of topics */
    6164        $text       = sprintf( _n( '%s Topic', '%s Topics', $r['topic_count_int'], 'bbpress' ), $r['topic_count'] );
    6265        $elements[] = current_user_can( 'publish_topics' )
     
    6871    if ( isset( $r['reply_count'] ) ) {
    6972        $link       = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), admin_url( 'edit.php' ) );
     73        /* translators: %s: Number of replies */
    7074        $text       = sprintf( _n( '%s Reply', '%s Replies', $r['reply_count_int'], 'bbpress' ), $r['reply_count'] );
    7175        $elements[] = current_user_can( 'publish_replies' )
     
    7781    if ( bbp_allow_topic_tags() && isset( $r['topic_tag_count'] ) ) {
    7882        $link       = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit-tags.php' ) );
     83        /* translators: %s: Number of topic tags */
    7984        $text       = sprintf( _n( '%s Topic Tag', '%s Topic Tags', $r['topic_tag_count_int'], 'bbpress' ), $r['topic_tag_count'] );
    8085        $elements[] = current_user_can( 'manage_topic_tags' )
     
    283288
    284289        <span id="wp-version-message">
    285             <?php printf( __( 'You are using <span class="b">bbPress %s</span>.', 'bbpress' ), bbp_get_version() ); ?>
     290            <?php
     291            printf(
     292                /* translators: %s: bbPress version */
     293                __( 'You are using <span class="b">bbPress %s</span>.', 'bbpress' ), bbp_get_version()
     294            );
     295            ?>
    286296        </span>
    287297
  • trunk/src/includes/admin/replies.php

    r7357 r7360  
    249249     */
    250250    public function bulk_post_updated_messages( $bulk_messages, $bulk_counts ) {
     251        /* translators: %s: Number of replies */
    251252        $bulk_messages['reply']['updated'] = _n( '%s reply updated.', '%s replies updated.', $bulk_counts['updated'], 'bbpress');
    252253        $bulk_messages['reply']['locked']  = ( 1 === $bulk_counts['locked'] )
    253254            ? __( '1 reply not updated, somebody is editing it.', 'bbpress' )
     255            /* translators: %s: Number of replies */
    254256            : _n( '%s reply not updated, somebody is editing it.', '%s replies not updated, somebody is editing them.', $bulk_counts['locked'], 'bbpress' );
    255257
     
    560562            case 'spammed' :
    561563                $message = ( true === $is_failure )
     564                    /* translators: %s: Reply title */
    562565                    ? sprintf( esc_html__( 'There was a problem marking the reply "%1$s" as spam.', 'bbpress' ), $reply_title )
     566                    /* translators: %s: Reply title */
    563567                    : sprintf( esc_html__( 'Reply "%1$s" successfully marked as spam.',             'bbpress' ), $reply_title );
    564568                break;
     
    566570            case 'unspammed' :
    567571                $message = ( true === $is_failure  )
     572                    /* translators: %s: Reply title */
    568573                    ? sprintf( esc_html__( 'There was a problem unmarking the reply "%1$s" as spam.', 'bbpress' ), $reply_title )
     574                    /* translators: %s: Reply title */
    569575                    : sprintf( esc_html__( 'Reply "%1$s" successfully unmarked as spam.',             'bbpress' ), $reply_title );
    570576                break;
     
    572578            case 'approved' :
    573579                $message = ( true === $is_failure  )
     580                    /* translators: %s: Reply title */
    574581                    ? sprintf( esc_html__( 'There was a problem approving the reply "%1$s".', 'bbpress' ), $reply_title )
     582                    /* translators: %s: Reply title */
    575583                    : sprintf( esc_html__( 'Reply "%1$s" successfully approved.',             'bbpress' ), $reply_title );
    576584                break;
     
    578586            case 'unapproved' :
    579587                $message = ( true === $is_failure )
     588                    /* translators: %s: Reply title */
    580589                    ? sprintf( esc_html__( 'There was a problem unapproving the reply "%1$s".', 'bbpress' ), $reply_title )
     590                    /* translators: %s: Reply title */
    581591                    : sprintf( esc_html__( 'Reply "%1$s" successfully unapproved.',             'bbpress' ), $reply_title );
    582592                break;
     
    794804
    795805        // Reply view links to topic
    796         $actions['view'] = '<a href="' . esc_url( $view_link ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;', 'bbpress' ), bbp_get_reply_title( $reply->ID ) ) ) . '" rel="permalink">' . esc_html__( 'View', 'bbpress' ) . '</a>';
     806        $view_title = sprintf(
     807            /* translators: %s: Reply title */
     808            __( 'View &#8220;%s&#8221;', 'bbpress' ),
     809            bbp_get_reply_title( $reply->ID )
     810        );
     811
     812        $actions['view'] = sprintf(
     813            '<a href="%1$s" title="%2$s" rel="permalink">%3$s</a>',
     814            esc_url( $view_link ),
     815            esc_attr( $view_title ),
     816            esc_html__( 'View', 'bbpress' )
     817        );
    797818
    798819        // User cannot view replies in trash
     
    887908
    888909        // Show the forums dropdown
    889         bbp_dropdown( array(
    890             'selected'  => $selected,
    891             'show_none' => esc_html__( 'In all forums', 'bbpress' )
    892         ) );
     910        bbp_dropdown(
     911            array(
     912                'selected'  => $selected,
     913                'show_none' => esc_html__( 'In all forums', 'bbpress' )
     914            )
     915        );
    893916    }
    894917
     
    9841007
    9851008            // Restored from revision
    986             // translators: %s: date and time of the revision
     1009            /* translators: %s: date and time of the revision */
    9871010            5 => isset( $_GET['revision'] )
     1011                    /* translators: %s: Date and time of the revision */
    9881012                    ? sprintf( esc_html__( 'Reply restored to revision from %s', 'bbpress' ), wp_post_revision_title( (int) $_GET['revision'], false ) )
    9891013                    : false,
     
    10121036                '%1$s <a target="_blank" href="%2$s">%3$s</a>',
    10131037                sprintf(
     1038                    /* translators: Publish box date format, see http://php.net/date */
    10141039                    esc_html__( 'Reply scheduled for: %s.', 'bbpress' ),
    1015                     // translators: Publish box date format, see http://php.net/date
    10161040                    '<strong>' . date_i18n( __( 'M j, Y @ G:i', 'bbpress' ), strtotime( $post_date ) ) . '</strong>'
    10171041                ),
  • trunk/src/includes/admin/settings.php

    r7357 r7360  
    676676    <label for="_bbp_allow_content_edit">
    677677        <input name="_bbp_allow_content_edit" id="_bbp_allow_content_edit" type="checkbox" value="1" <?php checked( bbp_allow_content_edit( true ) ); bbp_maybe_admin_setting_disabled( '_bbp_allow_content_edit' ); ?> />
    678         <?php printf( esc_html__( 'Allow users to edit their content for %s minutes after posting', 'bbpress' ), $select ); ?>
     678        <?php
     679        printf(
     680            /* translators: %s: Total minutes to edit a post */
     681            esc_html__( 'Allow users to edit their content for %s minutes after posting', 'bbpress' ),
     682            $select
     683        );
     684        ?>
    679685    </label>
    680686    <p class="description"><?php esc_html_e( 'If checked, setting to "0 minutes" allows editing forever.', 'bbpress' ); ?></p>
     
    701707    <label for="_bbp_allow_content_throttle">
    702708        <input name="_bbp_allow_content_throttle" id="_bbp_allow_content_throttle" type="checkbox" value="1" <?php checked( bbp_allow_content_throttle( true ) ); bbp_maybe_admin_setting_disabled( '_bbp_allow_content_throttle' ); ?> />
    703         <?php printf( esc_html__( 'Allow flood protection by throttling users for %s seconds after posting', 'bbpress' ), $select ); ?>
     709        <?php
     710        printf(
     711            /* translators: %s: Total seconds to throttle a user */
     712            esc_html__( 'Allow flood protection by throttling users for %s seconds after posting', 'bbpress' ),
     713            $select
     714        );
     715        ?>
    704716    </label>
    705717    <p class="description"><?php esc_html_e( 'Use this to discourage users from spamming your forums.', 'bbpress' ); ?></p>
     
    751763    <label for="_bbp_allow_global_access">
    752764        <input name="_bbp_allow_global_access" id="_bbp_allow_global_access" type="checkbox" value="1" <?php checked( bbp_allow_global_access( true ) ); bbp_maybe_admin_setting_disabled( '_bbp_allow_global_access' ); ?> />
    753         <?php printf( esc_html__( 'Automatically give registered visitors the %s forum role', 'bbpress' ), $select ); ?>
     765        <?php
     766        printf(
     767            /* translators: %s: Default role name */
     768            esc_html__( 'Automatically give registered visitors the %s forum role', 'bbpress' ),
     769            $select
     770        );
     771        ?>
    754772    </label>
    755773    <p class="description"><?php esc_html_e( 'Uncheck this to manually assign all user access to your forums.', 'bbpress' ); ?></p>
     
    902920
    903921    <label for="_bbp_allow_threaded_replies">
    904         <input name="_bbp_allow_threaded_replies" id="_bbp_allow_threaded_replies" type="checkbox" value="1" <?php checked( '1', bbp_allow_threaded_replies( false ) ); bbp_maybe_admin_setting_disabled( '_bbp_allow_threaded_replies' ); ?> />
    905         <?php printf( esc_html__( 'Enable threaded (nested) replies %s levels deep', 'bbpress' ), $select ); ?>
     922        <input name="_bbp_allow_threaded_replies" id="_bbp_allow_threaded_replies" type="checkbox" value="1"
     923            <?php
     924            checked( '1', bbp_allow_threaded_replies( false ) );
     925            bbp_maybe_admin_setting_disabled( '_bbp_allow_threaded_replies' );
     926            ?>
     927        />
     928        <?php
     929        printf(
     930            /* translators: %s: Depth level input field HTML */
     931            esc_html__( 'Enable threaded (nested) replies %s levels deep', 'bbpress' ),
     932            $select
     933        );
     934        ?>
    906935    </label>
    907936
     
    11681197    if ( ! empty( $forum_archive ) ) : ?>
    11691198
    1170         <p class="description"><?php printf( esc_html__( 'This setting will be ignored because %s was found in your theme.', 'bbpress' ), '<code>' . $forum_archive . '</code>' ); ?></p>
     1199        <p class="description">
     1200            <?php
     1201            printf(
     1202                /* translators: %s: Forum archive template file path */
     1203                esc_html__( 'This setting will be ignored because %s was found in your theme.', 'bbpress' ),
     1204                '<code>' . $forum_archive . '</code>'
     1205            );
     1206            ?>
     1207        </p>
    11711208
    11721209    <?php endif;
     
    14431480
    14441481    // Output the dropdown for all forums
    1445     $select = bbp_get_dropdown( array(
    1446         'selected'           => $group_root,
    1447         'show_none'          => esc_html__( '&mdash; No parent &mdash;', 'bbpress' ),
    1448         'orderby'            => 'title',
    1449         'order'              => 'ASC',
    1450         'select_id'          => '_bbp_group_forums_root_id',
    1451         'disable_categories' => false,
    1452         'disabled'           => '_bbp_group_forums_root_id'
    1453     ) );
     1482    $select = bbp_get_dropdown(
     1483        array(
     1484            'selected'           => $group_root,
     1485            'show_none'          => esc_html__( '&mdash; No parent &mdash;', 'bbpress' ),
     1486            'orderby'            => 'title',
     1487            'order'              => 'ASC',
     1488            'select_id'          => '_bbp_group_forums_root_id',
     1489            'disable_categories' => false,
     1490            'disabled'           => '_bbp_group_forums_root_id'
     1491        )
     1492    );
    14541493
    14551494    // Check cap one time
     
    14681507        // Button & text
    14691508        $button = '<a href="' . esc_url( $new_url ) . '">' . esc_html__( 'create a new one', 'bbpress' ) . '</a>';
    1470         $text   = esc_html__( 'Use %s to contain your group forums, or %s', 'bbpress' ); //phpcs:ignore
     1509        /* translators: 1: Forum select dropdown HTML, 2: Create new forum link HTML */
     1510        $text   = esc_html__( 'Use %1$s to contain your group forums, or %2$s', 'bbpress' );
    14711511    } else {
     1512        /* translators: %s: Forum select dropdown HTML */
    14721513        $text = esc_html__( 'Use %s to contain your group forums', 'bbpress' );
    14731514    }
     
    15841625function bbp_converter_setting_callback_dbserver() {
    15851626?>
    1586 
    1587     <input name="_bbp_converter_db_server" id="_bbp_converter_db_server" type="text" class="code" value="<?php bbp_form_option( '_bbp_converter_db_server', 'localhost' ); ?>" <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_db_server' ); ?> />
    1588     <p class="description"><?php printf( esc_html__( 'Use default %s if same server, or IP or hostname', 'bbpress' ), '<code>localhost</code>' ); ?></p>
    1589 
    1590 <?php
     1627    <input name="_bbp_converter_db_server"
     1628           id="_bbp_converter_db_server"
     1629           type="text"
     1630           class="code"
     1631           value="<?php bbp_form_option( '_bbp_converter_db_server', 'localhost' ); ?>"
     1632           <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_db_server' ); ?>
     1633    />
     1634    <p class="description">
     1635        <?php
     1636        printf(
     1637            /* translators: %s: Default value wrapped in code tags */
     1638            esc_html__( 'Use default %s if same server, or IP or hostname', 'bbpress' ),
     1639            '<code>localhost</code>'
     1640        );
     1641        ?>
     1642    </p>
     1643    <?php
    15911644}
    15921645
     
    15971650 */
    15981651function bbp_converter_setting_callback_dbport() {
    1599 ?>
    1600 
    1601     <input name="_bbp_converter_db_port" id="_bbp_converter_db_port" type="text" class="code" value="<?php bbp_form_option( '_bbp_converter_db_port', '3306' ); ?>" <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_db_port' ); ?> />
    1602     <p class="description"><?php printf( esc_html__( 'Use default %s if unsure', 'bbpress' ), '<code>3306</code>' ); ?></p>
    1603 
    1604 <?php
     1652    ?>
     1653    <input name="_bbp_converter_db_port"
     1654           id="_bbp_converter_db_port"
     1655           type="text"
     1656           class="code"
     1657           value="<?php bbp_form_option( '_bbp_converter_db_port', '3306' ); ?>"
     1658           <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_db_port' ); ?>
     1659    />
     1660    <p class="description">
     1661        <?php
     1662
     1663        printf(
     1664            /* translators: %s: Default port number wrapped in code tags */
     1665            esc_html__( 'Use default %s if unsure', 'bbpress' ),
     1666            '<code>3306</code>'
     1667        );
     1668        ?>
     1669    </p>
     1670    <?php
    16051671}
    16061672
     
    16751741
    16761742    <input name="_bbp_converter_db_prefix" id="_bbp_converter_db_prefix" type="text" class="code" value="<?php bbp_form_option( '_bbp_converter_db_prefix' ); ?>" <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_db_prefix' ); ?> />
    1677     <p class="description"><?php printf( esc_html__( 'Use %s if converting from BuddyPress Legacy', 'bbpress' ), '<code>wp_bb_</code>' ); ?></p>
     1743    <p class="description">
     1744        <?php printf(
     1745            /* translators: %s: Database prefix example wrapped in code tags */
     1746            esc_html__( 'Use %s if converting from BuddyPress Legacy', 'bbpress' ), '<code>wp_bb_</code>' );
     1747        ?>
     1748    </p>
    16781749
    16791750<?php
     
    17861857    // Starting or continuing?
    17871858    $status_text = ! empty( $step )
     1859        /* translators: %s: Current step number */
    17881860        ? sprintf( esc_html__( 'Up next: step %s', 'bbpress' ), $step )
    17891861        : esc_html__( 'Ready', 'bbpress' );
     
    17961868    // Starting or continuing?
    17971869    $progress_text = ! empty( $step )
     1870        /* translators: 1: Current step number, 2: Total number of steps */
    17981871        ? sprintf( esc_html__( 'Previously stopped at step %1$d of %2$d', 'bbpress' ), $step, $max )
    17991872        : esc_html__( 'Ready to go.', 'bbpress' ); ?>
     
    19642037    echo bbp_get_form_option( $option, $default, $slug );
    19652038}
    1966     /**
    1967      * Return settings API option
    1968      *
    1969      * @since 2.0.0 bbPress (r3203)
    1970      *
    1971      * @param string $option
    1972      * @param string $default
    1973      * @param bool   $is_slug
    1974      *
    1975      * @return mixed
    1976      */
    1977     function bbp_get_form_option( $option, $default = '', $is_slug = false ) {
    1978 
    1979         // Get the option and sanitize it
    1980         $value = get_option( $option, $default );
    1981 
    1982         // Slug?
    1983         if ( true === $is_slug ) {
    1984             $value = esc_attr( apply_filters( 'editable_slug', $value ) );
    1985 
    1986         // Not a slug
    1987         } else {
    1988             $value = esc_attr( $value );
    1989         }
    1990 
    1991         // Fallback to default, unless numeric (allow zero)
    1992         if ( empty( $value ) && ! is_numeric( $value ) ) {
    1993             $value = $default;
    1994         }
    1995 
    1996         // Filter & return
    1997         return apply_filters( 'bbp_get_form_option', $value, $option, $default, $is_slug );
     2039
     2040/**
     2041 * Return settings API option
     2042 *
     2043 * @since 2.0.0 bbPress (r3203)
     2044 *
     2045 * @param string $option
     2046 * @param string $default
     2047 * @param bool   $is_slug
     2048 *
     2049 * @return mixed
     2050 */
     2051function bbp_get_form_option( $option, $default = '', $is_slug = false ) {
     2052
     2053    // Get the option and sanitize it
     2054    $value = get_option( $option, $default );
     2055
     2056    // Slug?
     2057    if ( true === $is_slug ) {
     2058        $value = esc_attr( apply_filters( 'editable_slug', $value ) );
     2059
     2060    // Not a slug
     2061    } else {
     2062        $value = esc_attr( $value );
    19982063    }
     2064
     2065    // Fallback to default, unless numeric (allow zero)
     2066    if ( empty( $value ) && ! is_numeric( $value ) ) {
     2067        $value = $default;
     2068    }
     2069
     2070    // Filter & return
     2071    return apply_filters( 'bbp_get_form_option', $value, $option, $default, $is_slug );
     2072}
    19992073
    20002074/**
     
    20732147                foreach ( $bp->pages as $page => $page_data ) {
    20742148                    $page_base    = $page . '_base';
     2149                    /* translators: %s: BuddyPress page title */
    20752150                    $page_title   = sprintf( esc_html__( '%s page', 'bbpress' ), $page_data->title );
    20762151                    $core_slugs[ $page_base ] = array(
     
    20942169
    20952170        // Compare
    2096         if ( ( $slug !== $key ) && ( $slug_check === $this_slug ) ) : ?>
    2097 
    2098             <span class="attention"><?php printf( esc_html__( 'Possible %1$s conflict: %2$s', 'bbpress' ), $value['context'], '<strong>' . $value['name'] . '</strong>' ); ?></span>
    2099 
    2100         <?php endif;
     2171        if ( ( $slug !== $key ) && ( $slug_check === $this_slug ) ) :
     2172            ?>
     2173            <span class="attention">
     2174                <?php
     2175                printf(
     2176                    /* translators: 1: Context (e.g., "BuddyPress"), 2: Name of the conflicting item */
     2177                    esc_html__( 'Possible %1$s conflict: %2$s', 'bbpress' ),
     2178                    $value['context'],
     2179                    '<strong>' . $value['name'] . '</strong>'
     2180                );
     2181                ?>
     2182            </span>
     2183            <?php
     2184        endif;
    21012185    }
    21022186}
  • trunk/src/includes/admin/tools/common.php

    r7006 r7360  
    7474}
    7575
    76     /**
    77     * Return the URL to run a specific repair tool
    78     *
    79     * @since 2.6.0 bbPress (r5885)
    80     *
    81     * @param string $component
    82     */
    83     function bbp_get_admin_repair_tool_run_url( $component = array() ) {
    84 
    85         // Page
    86         $page = ( 'repair' === $component['type'] )
    87             ? 'bbp-repair'
    88             : 'bbp-upgrade';
    89 
    90         // Arguments
    91         $args = array(
    92             'page'    => $page,
    93             'action'  => 'run',
    94             'checked' => array( $component['id'] )
    95         );
    96 
    97         // Url
    98         $nonced = wp_nonce_url( bbp_get_admin_repair_tool_page_url( $args ), 'bbpress-do-counts' );
    99 
    100         // Filter & return
    101         return apply_filters( 'bbp_get_admin_repair_tool_run_url', $nonced, $component );
    102     }
     76/**
     77 * Return the URL to run a specific repair tool
     78 *
     79 * @since 2.6.0 bbPress (r5885)
     80 *
     81 * @param string $component
     82 */
     83function bbp_get_admin_repair_tool_run_url( $component = array() ) {
     84
     85    // Page
     86    $page = ( 'repair' === $component['type'] )
     87        ? 'bbp-repair'
     88        : 'bbp-upgrade';
     89
     90    // Arguments
     91    $args = array(
     92        'page'    => $page,
     93        'action'  => 'run',
     94        'checked' => array( $component['id'] )
     95    );
     96
     97    // Url
     98    $nonced = wp_nonce_url( bbp_get_admin_repair_tool_page_url( $args ), 'bbpress-do-counts' );
     99
     100    // Filter & return
     101    return apply_filters( 'bbp_get_admin_repair_tool_run_url', $nonced, $component );
     102}
    103103
    104104/**
     
    253253 */
    254254function bbp_admin_repair_list_search_form() {
    255     ?>
     255?>
    256256
    257257    <p class="search-box">
     
    798798    // Create the "All" link
    799799    $current = empty( $selected ) ? 'current' : '';
    800     $links[] = $r['link_before'] . '<a href="' . esc_url( $tools_url ) . '" class="' . esc_attr( $current ) . '">' . sprintf( esc_html__( 'All %s', 'bbpress' ), $r['count_before'] . count( $tools ) . $r['count_after'] ) . '</a>' . $r['link_after'];
     800
     801    $all_text = sprintf(
     802        /* translators: %s: Number of items */
     803        esc_html__( 'All %s', 'bbpress' ),
     804        $r['count_before'] . count( $tools ) . $r['count_after']
     805    );
     806
     807    $links[] = sprintf(
     808        '%1$s<a href="%2$s" class="%3$s">%4$s</a>%5$s',
     809        $r['link_before'],
     810        esc_url( $tools_url ),
     811        esc_attr( $current ),
     812        $all_text,
     813        $r['link_after']
     814    );
    801815
    802816    // Loop through overheads and created links
     
    922936    // Define links
    923937    $links = array(
    924         $r['link_before'] . '<a href="' . esc_url( $tools_url  ) . '" class="' . esc_attr( $all_current     ) . '">' . sprintf( esc_html__( 'All %s',     'bbpress' ), $all_count     ) . '</a>' . $r['link_after'],
    925         $r['link_before'] . '<a href="' . esc_url( $filter_url ) . '" class="' . esc_attr( $pending_current ) . '">' . sprintf( esc_html__( 'Pending %s', 'bbpress' ), $pending_count ) . '</a>' . $r['link_after']
     938        $r['link_before'] . '<a href="' . esc_url( $tools_url  ) . '" class="' . esc_attr( $all_current     ) . '">' .
     939            sprintf(
     940                /* translators: %s: Number of items */
     941                esc_html__( 'All %s', 'bbpress' ),
     942                $all_count
     943            ) .
     944        '</a>' . $r['link_after'],
     945
     946        $r['link_before'] . '<a href="' . esc_url( $filter_url ) . '" class="' . esc_attr( $pending_current ) . '">' .
     947            sprintf(
     948                /* translators: %s: Number of pending items */
     949                esc_html__( 'Pending %s', 'bbpress' ),
     950                $pending_count
     951            ) .
     952        '</a>' . $r['link_after']
    926953    );
    927954
  • trunk/src/includes/admin/tools/repair.php

    r7357 r7360  
    8484                        </td>
    8585                        <th scope="col" id="description" class="manage-column column-primary column-description sortable <?php echo ( 'priority' === $orderby ) ? esc_attr( $order ) : 'asc'; ?>">
    86                             <a href="
    87                                 <?php
     86                            <a href="<?php
     87
    8888                                echo esc_url(
    8989                                    bbp_get_admin_repair_tool_page_url(
     
    9494                                    )
    9595                                );
     96
    9697                                ?>">
    9798                                <span>
    98                                     <?php
    99                                     esc_html_e( 'Description', 'bbpress' );
    100                                     ?>
     99                                    <?php esc_html_e( 'Description', 'bbpress' ); ?>
    101100                                </span>
    102101                                <span class="sorting-indicator"></span>
     102                            </a>
    103103                        </th>
    104104                        <th scope="col" id="components" class="manage-column column-components">
     
    106106                        </th>
    107107                        <th scope="col" id="overhead" class="manage-column column-overhead sortable <?php echo ( 'overhead' === $orderby ) ? esc_attr( $order ) : 'asc'; ?>">
    108                             <a href="
    109                                 <?php
    110                                 echo esc_url( 
    111                                     bbp_get_admin_repair_tool_page_url( 
     108                            <a href="<?php
     109
     110                                echo esc_url(
     111                                    bbp_get_admin_repair_tool_page_url(
    112112                                        array(
    113113                                            'orderby' => 'overhead',
    114114                                            'order'   => $new_order
    115                                         )
    116                                     )
    117                                 );
     115                                        )
     116                                    )
     117                                );
     118
    118119                                ?>">
    119120                                <span>
    120                                     <?php
    121                                     esc_html_e( 'Overhead', 'bbpress' );
    122                                     ?>
     121                                    <?php esc_html_e( 'Overhead', 'bbpress' ); ?>
    123122                                </span>
    124123                                <span class="sorting-indicator"></span>
     124                            </a>
    125125                        </th>
    126126                    </tr>
     
    138138                                    <input type="checkbox" name="checked[]" value="<?php echo esc_attr( $item['id'] ); ?>" id="<?php echo esc_attr( str_replace( '_', '-', $item['id'] ) ); ?>">
    139139                                </th>
    140                                 <td class="bbp-tool-title column-primary column-description" data-colname="<?php esc_html_e( 'Description', 'bbpress' ); ?>">
    141                                     <strong><?php echo esc_html( $item['title'] ); ?></strong><?php
    142 
    143                                         // Optional description
    144                                         if ( ! empty( $item['description'] ) ) :
    145                                             echo '<p class="description">' . esc_html( $item['description'] ) . '</p>';
    146                                         endif;
    147 
    148                                     ?><div class="row-actions hide-if-no-js">
     140                                <td class="bbp-tool-title column-primary column-description"
     141                                    data-colname="<?php esc_html_e( 'Description', 'bbpress' ); ?>">
     142                                    <strong><?php echo esc_html( $item['title'] ); ?></strong>
     143
     144                                    <?php if ( ! empty( $item['description'] ) ) : ?>
     145                                        <p class="description"><?php echo esc_html( $item['description'] ); ?></p>
     146                                    <?php endif; ?>
     147
     148                                    <div class="row-actions hide-if-no-js">
    149149                                        <span class="run">
    150                                             <a href="<?php bbp_admin_repair_tool_run_url( $item ); ?>" aria-label="<?php printf( esc_html__( 'Run %s', 'bbpress' ), $item['title'] ); ?>" id="<?php echo esc_attr( $item['id'] ); ?>" ><?php esc_html_e( 'Run', 'bbpress' ); ?></a>
     150                                            <a href="<?php bbp_admin_repair_tool_run_url( $item ); ?>"
     151                                                id="<?php echo esc_attr( $item['id'] ); ?>"
     152                                                aria-label="<?php
     153                                                printf(
     154                                                    /* translators: %s: Repair tool title */
     155                                                    esc_html__( 'Run %s', 'bbpress' ),
     156                                                    $item['title']
     157                                                );
     158                                            ?>">
     159                                                <?php esc_html_e( 'Run', 'bbpress' ); ?>
     160                                            </a>
    151161                                        </span>
    152162                                    </div>
     163
    153164                                    <button type="button" class="toggle-row">
    154                                         <span class="screen-reader-text"><?php esc_html_e( 'Show more details', 'bbpress' ); ?></span>
     165                                        <span class="screen-reader-text">
     166                                            <?php esc_html_e( 'Show more details', 'bbpress' ); ?>
     167                                        </span>
    155168                                    </button>
    156169                                </td>
     
    225238    // Define variables
    226239    $bbp_db    = bbp_db();
     240    /* translators: %s: Status of the counting process */
    227241    $statement = esc_html__( 'Counting the number of replies in each topic&hellip; %s', 'bbpress' );
    228242    $result    = esc_html__( 'Failed!', 'bbpress' );
     
    274288    // Define variables
    275289    $bbp_db    = bbp_db();
     290    /* translators: %s: Status of the counting process */
    276291    $statement = esc_html__( 'Counting the number of voices in each topic&hellip; %s', 'bbpress' );
    277292    $result    = esc_html__( 'Failed!', 'bbpress' );
     
    326341    // Define variables
    327342    $bbp_db    = bbp_db();
     343    /* translators: %s: Status of the counting process */
    328344    $statement = esc_html__( 'Counting the number of pending, spammed, and trashed replies in each topic&hellip; %s', 'bbpress' );
    329345    $result    = esc_html__( 'Failed!', 'bbpress' );
     
    360376    // Define variables
    361377    $bbp_db    = bbp_db();
     378    /* translators: %s: Status of the counting process */
    362379    $statement = esc_html__( 'Counting the number of topics in each forum&hellip; %s', 'bbpress' );
    363380    $result    = esc_html__( 'Failed!', 'bbpress' );
     
    391408
    392409    // Define variables
     410    /* translators: %s: Status of the counting process */
    393411    $statement = esc_html__( 'Counting the number of topics in each topic-tag&hellip; %s', 'bbpress' );
    394412    $result    = esc_html__( 'Failed!', 'bbpress' );
     
    436454    // Define variables
    437455    $bbp_db    = bbp_db();
     456    /* translators: %s: Status of the counting process */
    438457    $statement = esc_html__( 'Counting the number of replies in each forum&hellip; %s', 'bbpress' );
    439458    $result    = esc_html__( 'Failed!', 'bbpress' );
     
    478497    // Define variables
    479498    $bbp_db    = bbp_db();
     499    /* translators: %s: Status of the counting process */
    480500    $statement = esc_html__( 'Counting the number of pending, spammed, and trashed replies in each forum&hellip; %s', 'bbpress' );
    481501    $result    = esc_html__( 'Failed!', 'bbpress' );
     
    519539    // Define variables
    520540    $bbp_db      = bbp_db();
     541    /* translators: %s: Status of the counting process */
    521542    $statement   = esc_html__( 'Counting the number of topics each user has created&hellip; %s', 'bbpress' );
    522543    $result      = esc_html__( 'Failed!', 'bbpress' );
     
    569590    // Define variables
    570591    $bbp_db      = bbp_db();
     592    /* translators: %s: Status of the counting process */
    571593    $statement   = esc_html__( 'Counting the number of topics to which each user has replied&hellip; %s', 'bbpress' );
    572594    $result      = esc_html__( 'Failed!', 'bbpress' );
     
    619641    // Define variables
    620642    $bbp_db    = bbp_db();
     643    /* translators: %s: Status of the repair process */
    621644    $statement = esc_html__( 'Removing unpublished topics from user favorites&hellip; %s', 'bbpress' );
    622645    $result    = esc_html__( 'Failed!', 'bbpress' );
     
    689712    // Define variables
    690713    $bbp_db    = bbp_db();
     714    /* translators: %s: Status of the repair process */
    691715    $statement = esc_html__( 'Removing trashed topics from user subscriptions&hellip; %s', 'bbpress' );
    692716    $result    = esc_html__( 'Failed!', 'bbpress' );
     
    758782    // Define variables
    759783    $bbp_db    = bbp_db();
     784    /* translators: %s: Status of the repair process */
    760785    $statement = esc_html__( 'Removing trashed forums from user subscriptions&hellip; %s', 'bbpress' );
    761786    $result    = esc_html__( 'Failed!', 'bbpress' );
     
    824849 */
    825850function bbp_admin_repair_user_roles() {
    826 
     851    /* translators: %s: Status of the repair process */
    827852    $statement    = esc_html__( 'Remapping forum role for each user on this site&hellip; %s', 'bbpress' );
    828853    $changed      = 0;
     
    922947        }
    923948    }
    924 
     949    /* translators: %s: Number of updated users */
    925950    $result = sprintf( esc_html__( 'Complete! %s users updated.', 'bbpress' ), bbp_number_format( $changed ) );
    926951
     
    939964    // Define variables
    940965    $bbp_db    = bbp_db();
     966    /* translators: %s: Status of the repair process */
    941967    $statement = esc_html__( 'Recomputing latest post in every topic and forum&hellip; %s', 'bbpress' );
    942968    $result    = esc_html__( 'Failed!', 'bbpress' );
     
    10601086    // Define variables
    10611087    $bbp_db    = bbp_db();
     1088    /* translators: %s: Status of the repair process */
    10621089    $statement = esc_html__( 'Repairing the sticky topic to the parent forum relationships&hellip; %s', 'bbpress' );
    10631090    $result    = esc_html__( 'Failed!', 'bbpress' );
     
    11251152    // Define variables
    11261153    $bbp_db        = bbp_db();
     1154    /* translators: %s: Status of the repair process */
    11271155    $statement     = esc_html__( 'Repairing closed topics&hellip; %s', 'bbpress' );
    11281156    $result        = esc_html__( 'No closed topics to repair.',        'bbpress' );
     
    11561184
    11571185    // Complete results
     1186    /* translators: %d: Number of repaired topics */
    11581187    $result = sprintf( _n( 'Complete! %d closed topic repaired.', 'Complete! %d closed topics repaired.', $changed, 'bbpress' ), $changed );
    11591188
     
    11691198 */
    11701199function bbp_admin_repair_forum_visibility() {
     1200    /* translators: %s: Status of the repair process */
    11711201    $statement = esc_html__( 'Recalculating forum visibility&hellip; %s', 'bbpress' );
    11721202
     
    11921222    // Define variables
    11931223    $bbp_db    = bbp_db();
     1224    /* translators: %s: Status of the repair process */
    11941225    $statement = esc_html__( 'Recalculating the forum for each post&hellip; %s', 'bbpress' );
    11951226    $result    = esc_html__( 'Failed!', 'bbpress' );
     
    12541285    // Define variables
    12551286    $bbp_db    = bbp_db();
     1287    /* translators: %s: Status of the repair process */
    12561288    $statement = esc_html__( 'Recalculating the topic for each post&hellip; %s', 'bbpress' );
    12571289    $result    = esc_html__( 'Failed!', 'bbpress' );
     
    13051337    // Define variables
    13061338    $bbp_db    = bbp_db();
     1339    /* translators: %s: Status of the repair process */
    13071340    $statement = esc_html__( 'Recalculating reply menu order&hellip; %s', 'bbpress' );
    13081341    $result    = esc_html__( 'No reply positions to recalculate.',         'bbpress' );
  • trunk/src/includes/admin/tools/reset.php

    r7006 r7360  
    180180        $messages[] = bbp_admin_reset_query_feedback( array(
    181181            'query'   => "DELETE FROM `{$bbp_db->posts}` WHERE `post_type` IN ('{$fpt}', '{$tpt}', '{$rpt}')",
     182            /* translators: %s: Status of the deletion process */
    182183            'message' => esc_html__( 'Removing Forums, Topics, and Replies&hellip; %s', 'bbpress' )
    183184        ) );
     
    188189            $messages[] = bbp_admin_reset_query_feedback( array(
    189190                'query'   => "DELETE FROM `{$bbp_db->postmeta}` WHERE `post_id` IN ('{$sql_meta}')",
     191                /* translators: %s: Status of the meta deletion process */
    190192                'message' => esc_html__( 'Removing Forum, Topic, and Reply Meta Data&hellip; %s', 'bbpress' )
    191193            ) );
     
    197199            $messages[] = bbp_admin_reset_query_feedback( array(
    198200                'query'   => "DELETE FROM `{$bbp_db->posts}` WHERE `post_parent` IN ('{$sql_meta}') AND `post_type` = 'revision'",
     201                /* translators: %s: Status of the revision deletion process */
    199202                'message' => esc_html__( 'Removing Revision Data&hellip; %s', 'bbpress' )
    200203            ) );
     
    202205    }
    203206
    204     /** Topic Tags ************************************************************/
     207    // Topic Tags
    205208
    206209    $messages[] = bbp_admin_reset_query_feedback( array(
    207210        'query'   => "DELETE a,b,c FROM `{$bbp_db->terms}` AS a LEFT JOIN `{$bbp_db->term_taxonomy}` AS c ON a.term_id = c.term_id LEFT JOIN `{$bbp_db->term_relationships}` AS b ON b.term_taxonomy_id = c.term_taxonomy_id WHERE c.taxonomy = 'topic-tag'",
     211        /* translators: %s: Status of the tag deletion process */
    208212        'message' => esc_html__( 'Deleting Topic Tags&hellip; %s', 'bbpress' )
    209213    ) );
    210214
    211     /** User ******************************************************************/
     215    // User
    212216
    213217    // First, if we're deleting previously imported users, delete them now
     
    225229            $messages[] = bbp_admin_reset_query_feedback( array(
    226230                'query'   => "DELETE FROM `{$bbp_db->users}` WHERE `ID` IN ('{$sql_meta}')",
     231                /* translators: %s: Status of the user deletion process */
    227232                'message' => esc_html__( 'Deleting Imported Users&hellip; %s', 'bbpress' )
    228233            ) );
     
    231236            $messages[] = bbp_admin_reset_query_feedback( array(
    232237                'query'   => "DELETE FROM `{$bbp_db->usermeta}` WHERE `user_id` IN ('{$sql_meta}')",
     238                /* translators: %s: Status of the user meta deletion process */
    233239                'message' => esc_html__( 'Deleting Imported User Meta&hellip; %s', 'bbpress' )
    234240            ) );
     
    239245    $messages[] = bbp_admin_reset_query_feedback( array(
    240246        'query'   => "DELETE FROM `{$bbp_db->usermeta}` WHERE `meta_key` LIKE '%%_bbp_%%'",
     247        /* translators: %s: Status of the user meta deletion process */
    241248        'message' => esc_html__( 'Deleting bbPress Specific User Meta&hellip; %s', 'bbpress' )
    242249    ) );
    243250
    244     /** Converter *************************************************************/
     251    // Converter
    245252
    246253    $table_name = $bbp_db->prefix . 'bbp_converter_translator';
     
    248255        $messages[] = bbp_admin_reset_query_feedback( array(
    249256            'query'   => "DROP TABLE {$table_name}",
     257            /* translators: %s: Status of the table deletion process */
    250258            'message' => esc_html__( 'Dropping Conversion Table&hellip; %s', 'bbpress' )
    251259        ) );
    252260    }
    253261
    254     /** Options ***************************************************************/
     262    // Options
    255263
    256264    bbp_delete_options();
    257265    $messages[] = esc_html__( 'Deleting Settings&hellip; Success!', 'bbpress' );
    258266
    259     /** Roles *****************************************************************/
     267    // Roles
    260268
    261269    bbp_remove_roles();
     
    263271    $messages[] = esc_html__( 'Removing Roles and Capabilities&hellip; Success!', 'bbpress' );
    264272
    265     /** Output ****************************************************************/
     273    // Output
    266274
    267275    if ( count( $messages ) ) {
  • trunk/src/includes/admin/tools/upgrade.php

    r7357 r7360  
    157157                                    ?><div class="row-actions hide-if-no-js">
    158158                                        <span class="run">
    159                                             <a href="<?php bbp_admin_repair_tool_run_url( $item ); ?>" aria-label="<?php printf( esc_html__( 'Run %s', 'bbpress' ), $item['title'] ); ?>" id="<?php echo esc_attr( $item['id'] ); ?>" ><?php esc_html_e( 'Run', 'bbpress' ); ?></a>
     159                                            <a href="<?php bbp_admin_repair_tool_run_url( $item ); ?>"
     160                                            id="<?php echo esc_attr( $item['id'] ); ?>"
     161                                            aria-label="<?php
     162                                            printf(
     163                                                /* translators: %s: Repair tool title */
     164                                                esc_html__( 'Run %s', 'bbpress' ),
     165                                                $item['title']
     166                                            );
     167                                            ?>">
     168                                                <?php esc_html_e( 'Run', 'bbpress' ); ?>
     169                                            </a>
    160170                                        </span>
    161171                                    </div>
     
    242252    // Define variables
    243253    $bbp_db    = bbp_db();
     254    /* translators: %s: Status of the upgrade process */
    244255    $statement = esc_html__( 'Upgrading user engagements&hellip; %s', 'bbpress' );
    245256    $result    = esc_html__( 'No engagements to upgrade.',            'bbpress' );
     
    276287
    277288    // Complete results
     289    /* translators: %d: Number of upgraded engagements */
    278290    $result = sprintf( _n( 'Complete! %d engagement upgraded.', 'Complete! %d engagements upgraded.', $engagements, 'bbpress' ), bbp_number_format( $engagements ) );
    279291
     
    294306    // Define variables
    295307    $bbp_db    = bbp_db();
     308    /* translators: %s: Status of the upgrade process */
    296309    $statement = esc_html__( 'Upgrading BuddyPress group-forum relationships&hellip; %s', 'bbpress' );
    297310    $g_count   = 0;
     
    415428
    416429    // Complete results
    417     $result = sprintf( esc_html__( 'Complete! %1$s groups updated; %2$s forums updated; %3$s forum statuses synced.', 'bbpress' ), bbp_number_format( $g_count ), bbp_number_format( $f_count ), bbp_number_format( $s_count ) );
     430    $result = sprintf(
     431        /* translators: %1$s: Number of groups updated; %2$s: Number of forums updated; %3$s: Number of forum statuses synced */
     432        esc_html__( 'Complete! %1$s groups updated; %2$s forums updated; %3$s forum statuses synced.', 'bbpress' ),
     433        bbp_number_format( $g_count ),
     434        bbp_number_format( $f_count ),
     435        bbp_number_format( $s_count )
     436    );
    418437    return array( 0, sprintf( $statement, $result ) );
    419438}
     
    430449    // Define variables
    431450    $bbp_db    = bbp_db();
     451    /* translators: %s: Status of the upgrade process */
    432452    $statement = esc_html__( 'Upgrading user favorites&hellip; %s', 'bbpress' );
    433453    $result    = esc_html__( 'No favorites to upgrade.',            'bbpress' );
     
    474494
    475495    // Complete results
     496    /* translators: %d: Number of upgraded favorites */
    476497    $result = sprintf( _n( 'Complete! %d favorite upgraded.', 'Complete! %d favorites upgraded.', $total, 'bbpress' ), bbp_number_format( $total ) );
    477498
     
    490511    // Define variables
    491512    $bbp_db    = bbp_db();
     513    /* translators: %s: Status of the upgrade process */
    492514    $statement = esc_html__( 'Upgrading user topic subscriptions&hellip; %s', 'bbpress' );
    493515    $result    = esc_html__( 'No topic subscriptions to upgrade.',            'bbpress' );
     
    534556
    535557    // Complete results
     558    /* translators: %d: Number of upgraded topic subscriptions */
    536559    $result = sprintf( _n( 'Complete! %d topic subscription upgraded.', 'Complete! %d topic subscriptions upgraded.', $total, 'bbpress' ), bbp_number_format( $total ) );
    537560
     
    550573    // Define variables
    551574    $bbp_db    = bbp_db();
     575    /* translators: %s: Status of the upgrade process */
    552576    $statement = esc_html__( 'Upgrading user forum subscriptions&hellip; %s', 'bbpress' );
    553577    $result    = esc_html__( 'No forum subscriptions to upgrade.',            'bbpress' );
     
    594618
    595619    // Complete results
     620    /* translators: %d: Number of upgraded forum subscriptions */
    596621    $result = sprintf( _n( 'Complete! %d forum subscription upgraded.', 'Complete! %d forum subscriptions upgraded.', $total, 'bbpress' ), bbp_number_format( $total ) );
    597622
     
    610635    // Define variables
    611636    $bbp_db    = bbp_db();
     637    /* translators: %s: Status of the upgrade process */
    612638    $statement = esc_html__( 'Remove favorites from usermeta&hellip; %s', 'bbpress' );
    613639    $result    = esc_html__( 'No favorites to remove.',                   'bbpress' );
     
    630656
    631657    // Complete results
     658    /* translators: %d: Number of deleted favorites */
    632659    $result = sprintf( _n( 'Complete! %d favorite deleted.', 'Complete! %d favorites deleted.', $total, 'bbpress' ), bbp_number_format( $total ) );
    633660
     
    646673    // Define variables
    647674    $bbp_db    = bbp_db();
     675    /* translators: %s: Status of the upgrade process */
    648676    $statement = esc_html__( 'Remove topic subscriptions from usermeta&hellip; %s', 'bbpress' );
    649677    $result    = esc_html__( 'No topic subscriptions to remove.',                   'bbpress' );
     
    666694
    667695    // Complete results
     696    /* translators: %d: Number of deleted topic subscriptions */
    668697    $result = sprintf( _n( 'Complete! %d topic subscription deleted.', 'Complete! %d topic subscriptions deleted.', $total, 'bbpress' ), bbp_number_format( $total ) );
    669698
     
    682711    // Define variables
    683712    $bbp_db    = bbp_db();
     713    /* translators: %s: Status of the upgrade process */
    684714    $statement = esc_html__( 'Remove forum subscriptions from usermeta&hellip; %s', 'bbpress' );
    685715    $result    = esc_html__( 'No forum subscriptions to remove.',                   'bbpress' );
     
    702732
    703733    // Complete results
     734    /* translators: %d: Number of deleted forum subscriptions */
    704735    $result = sprintf( _n( 'Complete! %d forum subscription deleted.', 'Complete! %d forum subscriptions deleted.', $total, 'bbpress' ), bbp_number_format( $total ) );
    705736
  • trunk/src/includes/admin/topics.php

    r7359 r7360  
    2121class BBP_Topics_Admin {
    2222
    23         /** Variables *************************************************************/
    24 
    25         /**
    26         * @var The post type of this admin component
    27         */
    28         private $post_type = '';
    29 
    30         /** Functions *************************************************************/
    31 
    32         /**
    33         * The main bbPress topics admin loader
    34         *
    35         * @since 2.0.0 bbPress (r2515)
    36         */
    37         public function __construct() {
    38             $this->setup_globals();
    39             $this->setup_actions();
    40             }
    41 
    42         /**
    43         * Setup the admin hooks, actions and filters
    44         *
    45         * @since 2.0.0 bbPress (r2646)
    46         * @since 2.6.0 bbPress (r6101) Added bulk actions
    47         *
    48         * @access private
    49         */
    50         private function setup_actions() {
    51 
    52             // Messages
    53             add_filter( 'post_updated_messages', array( $this, 'updated_messages' ) );
    54 
    55             // Topic bulk actions, added in WordPress 4.7, see #WP16031.
    56             if ( bbp_get_major_wp_version() >= 4.7 ) {
    57                 add_filter( 'bulk_actions-edit-topic',        array( $this, 'bulk_actions' ) );
    58                 add_filter( 'handle_bulk_actions-edit-topic', array( $this, 'handle_bulk_actions' ), 10, 3 );
    59                 add_filter( 'bulk_post_updated_messages',     array( $this, 'bulk_post_updated_messages' ), 10, 2 );
    60             }
    61 
    62             // Topic column headers.
    63             add_filter( 'manage_' . $this->post_type . '_posts_columns',        array( $this, 'column_headers' ) );
    64 
    65             // Topic columns (in post row)
    66             add_action( 'manage_' . $this->post_type . '_posts_custom_column',  array( $this, 'column_data' ), 10, 2 );
    67             add_filter( 'post_row_actions',                                     array( $this, 'row_actions' ), 10, 2 );
    68 
    69             // Topic meta-box actions
    70             add_action( 'add_meta_boxes', array( $this, 'attributes_metabox'    ) );
    71             add_action( 'add_meta_boxes', array( $this, 'author_metabox'        ) );
    72             add_action( 'add_meta_boxes', array( $this, 'replies_metabox'       ) );
    73             add_action( 'add_meta_boxes', array( $this, 'engagements_metabox'   ) );
    74             add_action( 'add_meta_boxes', array( $this, 'favorites_metabox'     ) );
    75             add_action( 'add_meta_boxes', array( $this, 'subscriptions_metabox' ) );
    76             add_action( 'add_meta_boxes', array( $this, 'comments_metabox'      ) );
    77             add_action( 'save_post',      array( $this, 'save_meta_boxes'       ) );
    78 
    79             // Check if there are any bbp_toggle_topic_* requests on admin_init, also have a message displayed
    80             add_action( 'load-edit.php',  array( $this, 'toggle_topic'        ) );
    81             add_action( 'load-edit.php',  array( $this, 'toggle_topic_notice' ) );
    82 
    83             // Add ability to filter topics and replies per forum
    84             add_filter( 'restrict_manage_posts', array( $this, 'filter_dropdown'  ) );
    85             add_filter( 'bbp_request',           array( $this, 'filter_post_rows' ) );
    86 
    87             // Empty spam
    88             add_filter( 'manage_posts_extra_tablenav', array( $this, 'filter_empty_spam' ) );
    89 
    90             // Contextual Help
    91             add_action( 'load-edit.php',     array( $this, 'edit_help' ) );
    92             add_action( 'load-post.php',     array( $this, 'new_help'  ) );
    93             add_action( 'load-post-new.php', array( $this, 'new_help'  ) );
    94             }
    95 
    96         /**
    97         * Admin globals
    98         *
    99         * @since 2.0.0 bbPress (r2646)
    100         *
    101         * @access private
    102         */
    103         private function setup_globals() {
    104             $this->post_type = bbp_get_topic_post_type();
    105             }
    106 
    107         /** Contextual Help *******************************************************/
    108 
    109         /**
    110         * Contextual help for bbPress topic edit page
    111         *
    112         * @since 2.0.0 bbPress (r3119)
    113         */
    114         public function edit_help() {
    115 
    116             // Overview
    117             get_current_screen()->add_help_tab( array(
     23    /** Variables *************************************************************/
     24
     25    /**
     26    * @var The post type of this admin component
     27    */
     28    private $post_type = '';
     29
     30    /** Functions *************************************************************/
     31
     32    /**
     33    * The main bbPress topics admin loader
     34    *
     35    * @since 2.0.0 bbPress (r2515)
     36    */
     37    public function __construct() {
     38        $this->setup_globals();
     39        $this->setup_actions();
     40    }
     41
     42    /**
     43    * Setup the admin hooks, actions and filters
     44    *
     45    * @since 2.0.0 bbPress (r2646)
     46    * @since 2.6.0 bbPress (r6101) Added bulk actions
     47    *
     48    * @access private
     49    */
     50    private function setup_actions() {
     51
     52        // Messages
     53        add_filter( 'post_updated_messages', array( $this, 'updated_messages' ) );
     54
     55        // Topic bulk actions, added in WordPress 4.7, see #WP16031.
     56        if ( bbp_get_major_wp_version() >= 4.7 ) {
     57            add_filter( 'bulk_actions-edit-topic',        array( $this, 'bulk_actions' ) );
     58            add_filter( 'handle_bulk_actions-edit-topic', array( $this, 'handle_bulk_actions' ), 10, 3 );
     59            add_filter( 'bulk_post_updated_messages',     array( $this, 'bulk_post_updated_messages' ), 10, 2 );
     60        }
     61
     62        // Topic column headers.
     63        add_filter( 'manage_' . $this->post_type . '_posts_columns',        array( $this, 'column_headers' ) );
     64
     65        // Topic columns (in post row)
     66        add_action( 'manage_' . $this->post_type . '_posts_custom_column',  array( $this, 'column_data' ), 10, 2 );
     67        add_filter( 'post_row_actions',                                     array( $this, 'row_actions' ), 10, 2 );
     68
     69        // Topic meta-box actions
     70        add_action( 'add_meta_boxes', array( $this, 'attributes_metabox'    ) );
     71        add_action( 'add_meta_boxes', array( $this, 'author_metabox'        ) );
     72        add_action( 'add_meta_boxes', array( $this, 'replies_metabox'       ) );
     73        add_action( 'add_meta_boxes', array( $this, 'engagements_metabox'   ) );
     74        add_action( 'add_meta_boxes', array( $this, 'favorites_metabox'     ) );
     75        add_action( 'add_meta_boxes', array( $this, 'subscriptions_metabox' ) );
     76        add_action( 'add_meta_boxes', array( $this, 'comments_metabox'      ) );
     77        add_action( 'save_post',      array( $this, 'save_meta_boxes'       ) );
     78
     79        // Check if there are any bbp_toggle_topic_* requests on admin_init, also have a message displayed
     80        add_action( 'load-edit.php',  array( $this, 'toggle_topic'        ) );
     81        add_action( 'load-edit.php',  array( $this, 'toggle_topic_notice' ) );
     82
     83        // Add ability to filter topics and replies per forum
     84        add_filter( 'restrict_manage_posts', array( $this, 'filter_dropdown'  ) );
     85        add_filter( 'bbp_request',           array( $this, 'filter_post_rows' ) );
     86
     87        // Empty spam
     88        add_filter( 'manage_posts_extra_tablenav', array( $this, 'filter_empty_spam' ) );
     89
     90        // Contextual Help
     91        add_action( 'load-edit.php',     array( $this, 'edit_help' ) );
     92        add_action( 'load-post.php',     array( $this, 'new_help'  ) );
     93        add_action( 'load-post-new.php', array( $this, 'new_help'  ) );
     94    }
     95
     96    /**
     97    * Admin globals
     98    *
     99    * @since 2.0.0 bbPress (r2646)
     100    *
     101    * @access private
     102    */
     103    private function setup_globals() {
     104        $this->post_type = bbp_get_topic_post_type();
     105    }
     106
     107    /** Contextual Help *******************************************************/
     108
     109    /**
     110    * Contextual help for bbPress topic edit page
     111    *
     112    * @since 2.0.0 bbPress (r3119)
     113    */
     114    public function edit_help() {
     115
     116        // Overview
     117        get_current_screen()->add_help_tab( array(
    118118            'id'        => 'overview',
    119119            'title'     => __( 'Overview', 'bbpress' ),
    120120            'content'   =>
    121121                '<p>' . __( 'This screen displays the individual topics on your site. You can customize the display of this screen to suit your workflow.', 'bbpress' ) . '</p>'
    122             ) );
    123 
    124             // Screen Content
    125             get_current_screen()->add_help_tab( array(
     122        ) );
     123
     124        // Screen Content
     125        get_current_screen()->add_help_tab( array(
    126126            'id'        => 'screen-content',
    127127            'title'     => __( 'Screen Content', 'bbpress' ),
     
    134134                    '<li>' . __( 'You can refine the list to show only topics in a specific forum or from a specific month by using the dropdown menus above the topics list. Click the Filter button after making your selection.',                 'bbpress' ) . '</li>' .
    135135                '</ul>'
    136             ) );
    137 
    138             // Available Actions
    139             get_current_screen()->add_help_tab( array(
     136        ) );
     137
     138        // Available Actions
     139        get_current_screen()->add_help_tab( array(
    140140            'id'        => 'action-links',
    141141            'title'     => __( 'Available Actions', 'bbpress' ),
     
    152152                    '<li>' . __( '<strong>View</strong> will take you to your live site to view the topic.',                                                                                        'bbpress' ) . '</li>' .
    153153                '</ul>'
    154             ) );
    155 
    156             // Bulk Actions
    157             get_current_screen()->add_help_tab( array(
     154        ) );
     155
     156        // Bulk Actions
     157        get_current_screen()->add_help_tab( array(
    158158            'id'        => 'bulk-actions',
    159159            'title'     => __( 'Bulk Actions', 'bbpress' ),
     
    161161                '<p>' . __( 'You can also edit, spam, or move multiple topics to the trash at once. Select the topics you want to act on using the checkboxes, then select the action you want to take from the Bulk Actions menu and click Apply.',           'bbpress' ) . '</p>' .
    162162                '<p>' . __( 'When using Bulk Edit, you can change the metadata (categories, author, etc.) for all selected topics at once. To remove a topic from the grouping, just click the x next to its name in the Bulk Edit area that appears.', 'bbpress' ) . '</p>'
    163             ) );
    164 
    165             // Help Sidebar
    166             get_current_screen()->set_help_sidebar(
     163        ) );
     164
     165        // Help Sidebar
     166        get_current_screen()->set_help_sidebar(
    167167            '<p><strong>' . __( 'For more information:', 'bbpress' ) . '</strong></p>' .
    168168            '<p>' . __( '<a href="https://codex.bbpress.org" target="_blank">bbPress Documentation</a>',     'bbpress' ) . '</p>' .
    169169            '<p>' . __( '<a href="https://bbpress.org/forums/" target="_blank">bbPress Support Forums</a>',  'bbpress' ) . '</p>'
    170             );
    171             }
    172 
    173         /**
    174         * Contextual help for bbPress topic edit page
    175         *
    176         * @since 2.0.0 bbPress (r3119)
    177         */
    178         public function new_help() {
    179 
    180             $customize_display = '<p>' . __( 'The title field and the big topic editing Area are fixed in place, but you can reposition all the other boxes using drag and drop, and can minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.', 'bbpress' ) . '</p>';
    181 
    182             get_current_screen()->add_help_tab( array(
     170        );
     171    }
     172
     173    /**
     174    * Contextual help for bbPress topic edit page
     175    *
     176    * @since 2.0.0 bbPress (r3119)
     177    */
     178    public function new_help() {
     179
     180        $customize_display = '<p>' . __( 'The title field and the big topic editing Area are fixed in place, but you can reposition all the other boxes using drag and drop, and can minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.', 'bbpress' ) . '</p>';
     181
     182        get_current_screen()->add_help_tab( array(
    183183            'id'      => 'customize-display',
    184184            'title'   => __( 'Customizing This Display', 'bbpress' ),
    185185            'content' => $customize_display,
    186             ) );
    187 
    188             get_current_screen()->add_help_tab( array(
     186        ) );
     187
     188        get_current_screen()->add_help_tab( array(
    189189            'id'      => 'title-topic-editor',
    190190            'title'   => __( 'Title and Topic Editor', 'bbpress' ),
     
    192192                '<p>' . __( '<strong>Title</strong> - Enter a title for your topic. After you enter a title, you&#8217;ll see the permalink below, which you can edit.', 'bbpress' ) . '</p>' .
    193193                '<p>' . __( '<strong>Topic Editor</strong> - Enter the text for your topic. There are two modes of editing: Visual and HTML. Choose the mode by clicking on the appropriate tab. Visual mode gives you a WYSIWYG editor. Click the last icon in the row to get a second row of controls. The HTML mode allows you to enter raw HTML along with your topic text. You can insert media files by clicking the icons above the topic editor and following the directions. You can go to the distraction-free writing screen via the Fullscreen icon in Visual mode (second to last in the top row) or the Fullscreen button in HTML mode (last in the row). Once there, you can make buttons visible by hovering over the top area. Exit Fullscreen back to the regular topic editor.', 'bbpress' ) . '</p>'
    194             ) );
    195 
    196             $publish_box = '<p>' . __( '<strong>Publish</strong> - You can set the terms of publishing your topic in the Publish box. For Status, Visibility, and Publish (immediately), click on the Edit link to reveal more options. Visibility includes options for password-protecting a topic or making it stay at the top of your blog indefinitely (sticky). Publish (immediately) allows you to set a future or past date and time, so you can schedule a topic to be published in the future or backdate a topic.', 'bbpress' ) . '</p>';
    197 
    198             if ( current_theme_supports( 'topic-thumbnails' ) && post_type_supports( bbp_get_topic_post_type(), 'thumbnail' ) ) {
    199                 $publish_box .= '<p>' . __( '<strong>Featured Image</strong> - This allows you to associate an image with your topic without inserting it. This is usually useful only if your theme makes use of the featured image as a topic thumbnail on the home page, a custom header, etc.', 'bbpress' ) . '</p>';
    200             }
    201 
    202             get_current_screen()->add_help_tab( array(
     194        ) );
     195
     196        $publish_box = '<p>' . __( '<strong>Publish</strong> - You can set the terms of publishing your topic in the Publish box. For Status, Visibility, and Publish (immediately), click on the Edit link to reveal more options. Visibility includes options for password-protecting a topic or making it stay at the top of your blog indefinitely (sticky). Publish (immediately) allows you to set a future or past date and time, so you can schedule a topic to be published in the future or backdate a topic.', 'bbpress' ) . '</p>';
     197
     198        if ( current_theme_supports( 'topic-thumbnails' ) && post_type_supports( bbp_get_topic_post_type(), 'thumbnail' ) ) {
     199            $publish_box .= '<p>' . __( '<strong>Featured Image</strong> - This allows you to associate an image with your topic without inserting it. This is usually useful only if your theme makes use of the featured image as a topic thumbnail on the home page, a custom header, etc.', 'bbpress' ) . '</p>';
     200        }
     201
     202        get_current_screen()->add_help_tab( array(
    203203            'id'      => 'topic-attributes',
    204204            'title'   => __( 'Topic Attributes', 'bbpress' ),
     
    209209                    '<li>' . __( '<strong>Topic Type</strong> dropdown indicates the sticky status of the topic. Selecting the super sticky option would stick the topic to the front of your forums, i.e. the topic index, sticky option would stick the topic to its respective forum. Selecting normal would not stick the topic anywhere.', 'bbpress' ) . '</li>' .
    210210                '</ul>'
    211             ) );
    212 
    213             get_current_screen()->add_help_tab( array(
     211        ) );
     212
     213        get_current_screen()->add_help_tab( array(
    214214            'id'      => 'publish-box',
    215215            'title'   => __( 'Publish Box', 'bbpress' ),
    216216            'content' => $publish_box,
    217             ) );
    218 
    219             get_current_screen()->set_help_sidebar(
     217        ) );
     218
     219        get_current_screen()->set_help_sidebar(
    220220            '<p><strong>' . __( 'For more information:', 'bbpress' ) . '</strong></p>' .
    221221            '<p>' . __( '<a href="https://codex.bbpress.org" target="_blank">bbPress Documentation</a>',    'bbpress' ) . '</p>' .
    222222            '<p>' . __( '<a href="https://bbpress.org/forums/" target="_blank">bbPress Support Forums</a>', 'bbpress' ) . '</p>'
    223             );
     223        );
     224    }
     225
     226    /**
     227     * Add spam/unspam bulk actions to the bulk action dropdown.
     228     *
     229     * @since 2.6.0 bbPress (r6101)
     230     *
     231     * @param array $actions The list of bulk actions.
     232     * @return array The filtered list of bulk actions.
     233     */
     234    public function bulk_actions( $actions ) {
     235
     236        if ( current_user_can( 'moderate' ) ) {
     237            if ( bbp_get_spam_status_id() === get_query_var( 'post_status' ) ) {
     238                $actions['unspam'] = esc_html__( 'Unspam', 'bbpress' );
     239            } else {
     240                $actions['spam'] = esc_html__( 'Spam', 'bbpress' );
    224241            }
    225 
    226         /**
    227          * Add spam/unspam bulk actions to the bulk action dropdown.
    228          *
    229          * @since 2.6.0 bbPress (r6101)
    230          *
    231          * @param array $actions The list of bulk actions.
    232          * @return array The filtered list of bulk actions.
    233          */
    234         public function bulk_actions( $actions ) {
    235 
    236             if ( current_user_can( 'moderate' ) ) {
    237                 if ( bbp_get_spam_status_id() === get_query_var( 'post_status' ) ) {
    238                     $actions['unspam'] = esc_html__( 'Unspam', 'bbpress' );
    239                 } else {
    240                     $actions['spam'] = esc_html__( 'Spam', 'bbpress' );
     242        }
     243
     244        return $actions;
     245    }
     246
     247    /**
     248     * Add custom bulk action updated messages for topics.
     249     *
     250     * @since 2.6.0 bbPress (r6101)
     251     *
     252     * @param array $bulk_messages Arrays of messages, each keyed by the corresponding post type.
     253     * @param array $bulk_counts   Array of item counts for each message, used to build internationalized strings.
     254     */
     255    public function bulk_post_updated_messages( $bulk_messages, $bulk_counts ) {
     256        /* translators: %s: Number of topics */
     257        $bulk_messages['topic']['updated'] = _n( '%s topic updated.', '%s topics updated.', $bulk_counts['updated'], 'bbpress' );
     258        $bulk_messages['topic']['locked']  = ( 1 === $bulk_counts['locked'] )
     259            ? __( '1 topic not updated, somebody is editing it.', 'bbpress' )
     260            /* translators: %s: Number of topics */
     261            : _n( '%s topic not updated, somebody is editing it.', '%s topics not updated, somebody is editing them.', $bulk_counts['locked'], 'bbpress' );
     262
     263        return $bulk_messages;
     264    }
     265
     266    /**
     267     * Handle spam/unspam bulk actions.
     268     *
     269     * @since 2.6.0 bbPress (r6101)
     270     *
     271     * @param string $sendback The sendback URL.
     272     * @param string $doaction The action to be taken.
     273     * @param array  $post_ids The post IDS to take the action on.
     274     * @return string The sendback URL.
     275     */
     276    public function handle_bulk_actions( $sendback, $doaction, $post_ids ) {
     277
     278        $sendback = remove_query_arg( array( 'spam', 'unspam' ), $sendback );
     279        $updated  = $locked = 0;
     280
     281        if ( 'spam' === $doaction ) {
     282
     283            foreach ( (array) $post_ids as $post_id ) {
     284                if ( ! current_user_can( 'moderate', $post_id ) ) {
     285                    wp_die( esc_html__( 'Sorry, you are not allowed to spam this item.', 'bbpress' ) );
    241286                }
     287
     288                if ( wp_check_post_lock( $post_id ) ) {
     289                    $locked++;
     290                    continue;
     291                }
     292
     293                if ( ! bbp_spam_topic( $post_id ) ) {
     294                    wp_die( esc_html__( 'Error in spamming topic.', 'bbpress' ) );
     295                }
     296
     297                $updated++;
    242298            }
    243299
    244             return $actions;
    245             }
    246 
    247         /**
    248          * Add custom bulk action updated messages for topics.
    249          *
    250          * @since 2.6.0 bbPress (r6101)
    251          *
    252          * @param array $bulk_messages Arrays of messages, each keyed by the corresponding post type.
    253          * @param array $bulk_counts   Array of item counts for each message, used to build internationalized strings.
    254          */
    255         public function bulk_post_updated_messages( $bulk_messages, $bulk_counts ) {
    256             $bulk_messages['topic']['updated'] = _n( '%s topic updated.', '%s topics updated.', $bulk_counts['updated'], 'bbpress' );
    257             $bulk_messages['topic']['locked']  = ( 1 === $bulk_counts['locked'] )
    258             ? __( '1 topic not updated, somebody is editing it.', 'bbpress' )
    259             : _n( '%s topic not updated, somebody is editing it.', '%s topics not updated, somebody is editing them.', $bulk_counts['locked'], 'bbpress' );
    260 
    261             return $bulk_messages;
    262             }
    263 
    264         /**
    265          * Handle spam/unspam bulk actions.
    266          *
    267          * @since 2.6.0 bbPress (r6101)
    268          *
    269          * @param string $sendback The sendback URL.
    270          * @param string $doaction The action to be taken.
    271          * @param array  $post_ids The post IDS to take the action on.
    272          * @return string The sendback URL.
    273          */
    274         public function handle_bulk_actions( $sendback, $doaction, $post_ids ) {
    275 
    276             $sendback = remove_query_arg( array( 'spam', 'unspam' ), $sendback );
    277             $updated  = $locked = 0;
    278 
    279             if ( 'spam' === $doaction ) {
    280 
    281                 foreach ( (array) $post_ids as $post_id ) {
    282                     if ( ! current_user_can( 'moderate', $post_id ) ) {
    283                         wp_die( esc_html__( 'Sorry, you are not allowed to spam this item.', 'bbpress' ) );
    284                     }
    285 
    286                     if ( wp_check_post_lock( $post_id ) ) {
    287                         $locked++;
    288                         continue;
    289                     }
    290 
    291                     if ( ! bbp_spam_topic( $post_id ) ) {
    292                         wp_die( esc_html__( 'Error in spamming topic.', 'bbpress' ) );
    293                     }
    294 
    295                     $updated++;
    296                 }
    297 
    298                 $sendback = add_query_arg( array(
     300            $sendback = add_query_arg( array(
    299301                'updated' => $updated,
    300302                'ids'     => implode( ',', $post_ids ),
    301303                'locked'  => $locked
    302                 ), $sendback );
    303 
    304             } elseif ( 'unspam' === $doaction ) {
    305 
    306                 foreach ( (array) $post_ids as $post_id ) {
    307                     if ( ! current_user_can( 'moderate', $post_id ) ) {
    308                         wp_die( esc_html__( 'Sorry, you are not allowed to unspam this topic.', 'bbpress' ) );
    309                     }
    310 
    311                     if ( wp_check_post_lock( $post_id ) ) {
    312                         $locked++;
    313                         continue;
    314                     }
    315 
    316                     if ( ! bbp_unspam_topic( $post_id ) ) {
    317                         wp_die( esc_html__( 'Error in unspamming topic.', 'bbpress' ) );
    318                     }
    319 
    320                     $updated++;
     304            ), $sendback );
     305
     306        } elseif ( 'unspam' === $doaction ) {
     307
     308            foreach ( (array) $post_ids as $post_id ) {
     309                if ( ! current_user_can( 'moderate', $post_id ) ) {
     310                    wp_die( esc_html__( 'Sorry, you are not allowed to unspam this topic.', 'bbpress' ) );
    321311                }
    322312
    323                 $sendback = add_query_arg( array(
     313                if ( wp_check_post_lock( $post_id ) ) {
     314                    $locked++;
     315                    continue;
     316                }
     317
     318                if ( ! bbp_unspam_topic( $post_id ) ) {
     319                    wp_die( esc_html__( 'Error in unspamming topic.', 'bbpress' ) );
     320                }
     321
     322                $updated++;
     323            }
     324
     325            $sendback = add_query_arg( array(
    324326                'updated' => $updated,
    325327                'ids'     => implode( ',', $post_ids ),
    326328                'locked'  => $locked
    327                 ), $sendback );
    328             }
    329 
    330             return $sendback;
    331             }
    332 
    333         /**
    334         * Add the topic attributes meta-box
    335         *
    336         * @since 2.0.0 bbPress (r2744)
    337         */
    338         public function attributes_metabox() {
    339             add_meta_box(
     329            ), $sendback );
     330        }
     331
     332        return $sendback;
     333    }
     334
     335    /**
     336    * Add the topic attributes meta-box
     337    *
     338    * @since 2.0.0 bbPress (r2744)
     339    */
     340    public function attributes_metabox() {
     341        add_meta_box(
    340342            'bbp_topic_attributes',
    341343            esc_html__( 'Topic Attributes', 'bbpress' ),
     
    344346            'side',
    345347            'high'
    346             );
    347             }
    348 
    349         /**
    350         * Add the author info meta-box
    351         *
    352         * @since 2.0.0 bbPress (r2828)
    353         */
    354         public function author_metabox() {
    355 
    356             // Bail if post_type is not a topic
    357             if ( empty( $_GET['action'] ) || ( 'edit' !== $_GET['action'] ) ) {
    358                 return;
    359             }
    360 
    361             // Add the meta-box
    362             add_meta_box(
     348        );
     349    }
     350
     351    /**
     352    * Add the author info meta-box
     353    *
     354    * @since 2.0.0 bbPress (r2828)
     355    */
     356    public function author_metabox() {
     357
     358        // Bail if post_type is not a topic
     359        if ( empty( $_GET['action'] ) || ( 'edit' !== $_GET['action'] ) ) {
     360            return;
     361        }
     362
     363        // Add the meta-box
     364        add_meta_box(
    363365            'bbp_author_metabox',
    364366            esc_html__( 'Author Information', 'bbpress' ),
     
    367369            'side',
    368370            'high'
    369             );
    370             }
    371 
    372         /**
    373         * Add the replies meta-box
    374         *
    375         * Allows viewing & moderating of replies to a topic, based on the way
    376         * comments are visible on a blog post.
    377         *
    378         * @since 2.6.0 bbPress (r5886)
    379         */
    380         public function replies_metabox() {
    381 
    382             // Bail if post_type is not a reply
    383             if ( empty( $_GET['action'] ) || ( 'edit' !== $_GET['action'] ) ) {
    384                 return;
    385             }
    386 
    387             // Add the meta-box
    388             add_meta_box(
     371        );
     372    }
     373
     374    /**
     375    * Add the replies meta-box
     376    *
     377    * Allows viewing & moderating of replies to a topic, based on the way
     378    * comments are visible on a blog post.
     379    *
     380    * @since 2.6.0 bbPress (r5886)
     381    */
     382    public function replies_metabox() {
     383
     384        // Bail if post_type is not a reply
     385        if ( empty( $_GET['action'] ) || ( 'edit' !== $_GET['action'] ) ) {
     386            return;
     387        }
     388
     389        // Add the meta-box
     390        add_meta_box(
    389391            'bbp_topic_replies_metabox',
    390392            esc_html__( 'Replies', 'bbpress' ),
     
    393395            'normal',
    394396            'high'
    395             );
    396             }
    397 
    398         /**
    399         * Add the engagements meta-box
    400         *
    401         * Allows viewing of users who have engaged in a topic.
    402         *
    403         * @since 2.6.0 bbPress (r6333)
    404         */
    405         public function engagements_metabox() {
    406 
    407             // Bail when creating a new topic
    408             if ( empty( $_GET['action'] ) || ( 'edit' !== $_GET['action'] ) ) {
    409                 return;
    410             }
    411 
    412             // Bail if no engagements
    413             if ( ! bbp_is_engagements_active() ) {
    414                 return;
    415             }
    416 
    417             // Add the meta-box
    418             add_meta_box(
     397        );
     398    }
     399
     400    /**
     401    * Add the engagements meta-box
     402    *
     403    * Allows viewing of users who have engaged in a topic.
     404    *
     405    * @since 2.6.0 bbPress (r6333)
     406    */
     407    public function engagements_metabox() {
     408
     409        // Bail when creating a new topic
     410        if ( empty( $_GET['action'] ) || ( 'edit' !== $_GET['action'] ) ) {
     411            return;
     412        }
     413
     414        // Bail if no engagements
     415        if ( ! bbp_is_engagements_active() ) {
     416            return;
     417        }
     418
     419        // Add the meta-box
     420        add_meta_box(
    419421            'bbp_topic_engagements_metabox',
    420422            esc_html__( 'Engagements', 'bbpress' ),
     
    423425            'side',
    424426            'low'
    425             );
    426             }
    427 
    428         /**
    429         * Add the favorites meta-box
    430         *
    431         * Allows viewing of users who have favorited a topic.
    432         *
    433         * @since 2.6.0 bbPress (r6197)
    434         */
    435         public function favorites_metabox() {
    436 
    437             // Bail if post_type is not a reply
    438             if ( empty( $_GET['action'] ) || ( 'edit' !== $_GET['action'] ) ) {
    439                 return;
    440             }
    441 
    442             // Bail if no favorites
    443             if ( ! bbp_is_favorites_active() ) {
    444                 return;
    445             }
    446 
    447             // Add the meta-box
    448             add_meta_box(
     427        );
     428    }
     429
     430    /**
     431    * Add the favorites meta-box
     432    *
     433    * Allows viewing of users who have favorited a topic.
     434    *
     435    * @since 2.6.0 bbPress (r6197)
     436    */
     437    public function favorites_metabox() {
     438
     439        // Bail if post_type is not a reply
     440        if ( empty( $_GET['action'] ) || ( 'edit' !== $_GET['action'] ) ) {
     441            return;
     442        }
     443
     444        // Bail if no favorites
     445        if ( ! bbp_is_favorites_active() ) {
     446            return;
     447        }
     448
     449        // Add the meta-box
     450        add_meta_box(
    449451            'bbp_topic_favorites_metabox',
    450452            esc_html__( 'Favorites', 'bbpress' ),
     
    453455            'normal',
    454456            'high'
    455             );
    456             }
    457 
    458         /**
    459         * Add the subscriptions meta-box
    460         *
    461         * Allows viewing of users who have subscribed to a topic.
    462         *
    463         * @since 2.6.0 bbPress (r6197)
    464         */
    465         public function subscriptions_metabox() {
    466 
    467             // Bail if post_type is not a reply
    468             if ( empty( $_GET['action'] ) || ( 'edit' !== $_GET['action'] ) ) {
    469                 return;
    470             }
    471 
    472             // Bail if no subscriptions
    473             if ( ! bbp_is_subscriptions_active() ) {
    474                 return;
    475             }
    476 
    477             // Add the meta-box
    478             add_meta_box(
     457        );
     458    }
     459
     460    /**
     461    * Add the subscriptions meta-box
     462    *
     463    * Allows viewing of users who have subscribed to a topic.
     464    *
     465    * @since 2.6.0 bbPress (r6197)
     466    */
     467    public function subscriptions_metabox() {
     468
     469        // Bail if post_type is not a reply
     470        if ( empty( $_GET['action'] ) || ( 'edit' !== $_GET['action'] ) ) {
     471            return;
     472        }
     473
     474        // Bail if no subscriptions
     475        if ( ! bbp_is_subscriptions_active() ) {
     476            return;
     477        }
     478
     479        // Add the meta-box
     480        add_meta_box(
    479481            'bbp_topic_subscriptions_metabox',
    480482            esc_html__( 'Subscriptions', 'bbpress' ),
     
    483485            'normal',
    484486            'high'
    485             );
    486             }
    487 
    488         /**
    489          * Remove comments & discussion meta-boxes if comments are not supported
    490          *
    491          * @since 2.6.0 bbPress (r6186)
    492          */
    493         public function comments_metabox() {
    494             if ( ! post_type_supports( $this->post_type, 'comments' ) ) {
    495                 remove_meta_box( 'commentstatusdiv', $this->post_type, 'normal' );
    496                 remove_meta_box( 'commentsdiv',      $this->post_type, 'normal' );
    497             }
    498             }
    499 
    500         /**
    501          * Pass the topic attributes for processing
    502          *
    503          * @since 2.0.0 bbPress (r2746)
    504          *
    505          * @param int $topic_id Topic id
    506          * @return int Parent id
    507          */
    508         public function save_meta_boxes( $topic_id ) {
    509 
    510             // Bail if doing an autosave
    511             if ( bbp_doing_autosave() ) {
    512                 return $topic_id;
    513             }
    514 
    515             // Bail if not a post request
    516             if ( ! bbp_is_post_request() ) {
    517                 return $topic_id;
    518             }
    519 
    520             // Check action exists
    521             if ( empty( $_POST['action'] ) ) {
    522                 return $topic_id;
    523             }
    524 
    525             // Nonce check
    526             if ( empty( $_POST['bbp_topic_metabox'] ) || ! wp_verify_nonce( $_POST['bbp_topic_metabox'], 'bbp_topic_metabox_save' ) ) {
    527                 return $topic_id;
    528             }
    529 
    530             // Bail if current user cannot edit this topic
    531             if ( ! current_user_can( 'edit_topic', $topic_id ) ) {
    532                 return $topic_id;
    533             }
    534 
    535             // Get the forum ID
    536             $forum_id = ! empty( $_POST['parent_id'] ) ? (int) $_POST['parent_id'] : 0;
    537 
    538             // Get topic author data
    539             $anonymous_data = bbp_filter_anonymous_post_data();
    540             $author_id      = bbp_get_topic_author_id( $topic_id );
    541             $is_edit        = ( isset( $_POST['hidden_post_status'] ) && ( 'draft' !== $_POST['hidden_post_status'] ) );
    542 
    543             // Formally update the topic
    544             bbp_update_topic( $topic_id, $forum_id, $anonymous_data, $author_id, $is_edit );
    545 
    546             // Allow other fun things to happen
    547             do_action( 'bbp_topic_attributes_metabox_save', $topic_id, $forum_id       );
    548             do_action( 'bbp_author_metabox_save',           $topic_id, $anonymous_data );
    549 
     487        );
     488    }
     489
     490    /**
     491     * Remove comments & discussion meta-boxes if comments are not supported
     492     *
     493     * @since 2.6.0 bbPress (r6186)
     494     */
     495    public function comments_metabox() {
     496        if ( ! post_type_supports( $this->post_type, 'comments' ) ) {
     497            remove_meta_box( 'commentstatusdiv', $this->post_type, 'normal' );
     498            remove_meta_box( 'commentsdiv',      $this->post_type, 'normal' );
     499        }
     500    }
     501
     502    /**
     503     * Pass the topic attributes for processing
     504     *
     505     * @since 2.0.0 bbPress (r2746)
     506     *
     507     * @param int $topic_id Topic id
     508     * @return int Parent id
     509     */
     510    public function save_meta_boxes( $topic_id ) {
     511
     512        // Bail if doing an autosave
     513        if ( bbp_doing_autosave() ) {
    550514            return $topic_id;
    551             }
    552 
    553         /**
    554          * Toggle topic
    555          *
    556          * Handles the admin-side opening/closing, sticking/unsticking and
    557          * spamming/unspamming of topics
    558          *
    559          * @since 2.0.0 bbPress (r2727)
    560          */
    561         public function toggle_topic() {
    562 
    563             // Bail if not a topic toggle action
    564             if ( ! bbp_is_get_request() || empty( $_GET['action'] ) || empty( $_GET['topic_id'] ) ) {
    565                 return;
    566             }
    567 
    568             // Bail if not an allowed action
    569             $action = sanitize_key( $_GET['action'] );
    570             if ( empty( $action ) || ! in_array( $action, $this->get_allowed_action_toggles(), true ) ) {
    571                 return;
    572             }
    573 
    574             // Bail if topic is missing
    575             $topic_id = bbp_get_topic_id( $_GET['topic_id'] );
    576             if ( ! bbp_get_topic( $topic_id ) ) {
    577                 wp_die( esc_html__( 'The topic was not found.', 'bbpress' ) );
    578             }
    579 
    580             // What is the user doing here?
    581             if ( ! current_user_can( 'moderate', $topic_id ) ) {
    582                 wp_die( esc_html__( 'You do not have permission to do that.', 'bbpress' ) );
    583             }
    584 
    585             // Defaults
    586             $post_data = array( 'ID' => $topic_id );
    587             $message   = '';
    588             $success   = false;
    589 
    590             switch ( $action ) {
    591                 case 'bbp_toggle_topic_approve' :
    592                     check_admin_referer( 'approve-topic_' . $topic_id );
    593 
    594                     $is_approve = bbp_is_topic_public( $topic_id );
    595                     $message    = ( true === $is_approve )
     515        }
     516
     517        // Bail if not a post request
     518        if ( ! bbp_is_post_request() ) {
     519            return $topic_id;
     520        }
     521
     522        // Check action exists
     523        if ( empty( $_POST['action'] ) ) {
     524            return $topic_id;
     525        }
     526
     527        // Nonce check
     528        if ( empty( $_POST['bbp_topic_metabox'] ) || ! wp_verify_nonce( $_POST['bbp_topic_metabox'], 'bbp_topic_metabox_save' ) ) {
     529            return $topic_id;
     530        }
     531
     532        // Bail if current user cannot edit this topic
     533        if ( ! current_user_can( 'edit_topic', $topic_id ) ) {
     534            return $topic_id;
     535        }
     536
     537        // Get the forum ID
     538        $forum_id = ! empty( $_POST['parent_id'] ) ? (int) $_POST['parent_id'] : 0;
     539
     540        // Get topic author data
     541        $anonymous_data = bbp_filter_anonymous_post_data();
     542        $author_id      = bbp_get_topic_author_id( $topic_id );
     543        $is_edit        = ( isset( $_POST['hidden_post_status'] ) && ( 'draft' !== $_POST['hidden_post_status'] ) );
     544
     545        // Formally update the topic
     546        bbp_update_topic( $topic_id, $forum_id, $anonymous_data, $author_id, $is_edit );
     547
     548        // Allow other fun things to happen
     549        do_action( 'bbp_topic_attributes_metabox_save', $topic_id, $forum_id       );
     550        do_action( 'bbp_author_metabox_save',           $topic_id, $anonymous_data );
     551
     552        return $topic_id;
     553    }
     554
     555    /**
     556     * Toggle topic
     557     *
     558     * Handles the admin-side opening/closing, sticking/unsticking and
     559     * spamming/unspamming of topics
     560     *
     561     * @since 2.0.0 bbPress (r2727)
     562     */
     563    public function toggle_topic() {
     564
     565        // Bail if not a topic toggle action
     566        if ( ! bbp_is_get_request() || empty( $_GET['action'] ) || empty( $_GET['topic_id'] ) ) {
     567            return;
     568        }
     569
     570        // Bail if not an allowed action
     571        $action = sanitize_key( $_GET['action'] );
     572        if ( empty( $action ) || ! in_array( $action, $this->get_allowed_action_toggles(), true ) ) {
     573            return;
     574        }
     575
     576        // Bail if topic is missing
     577        $topic_id = bbp_get_topic_id( $_GET['topic_id'] );
     578        if ( ! bbp_get_topic( $topic_id ) ) {
     579            wp_die( esc_html__( 'The topic was not found.', 'bbpress' ) );
     580        }
     581
     582        // What is the user doing here?
     583        if ( ! current_user_can( 'moderate', $topic_id ) ) {
     584            wp_die( esc_html__( 'You do not have permission to do that.', 'bbpress' ) );
     585        }
     586
     587        // Defaults
     588        $post_data = array( 'ID' => $topic_id );
     589        $message   = '';
     590        $success   = false;
     591
     592        switch ( $action ) {
     593            case 'bbp_toggle_topic_approve' :
     594                check_admin_referer( 'approve-topic_' . $topic_id );
     595
     596                $is_approve = bbp_is_topic_public( $topic_id );
     597                $message    = ( true === $is_approve )
    596598                    ? 'unapproved'
    597599                    : 'approved';
    598                     $success    = ( true === $is_approve )
     600                $success    = ( true === $is_approve )
    599601                    ? bbp_unapprove_topic( $topic_id )
    600602                    : bbp_approve_topic( $topic_id );
    601603
    602                     break;
    603 
    604                 case 'bbp_toggle_topic_close' :
    605                     check_admin_referer( 'close-topic_' . $topic_id );
    606 
    607                     $is_open = bbp_is_topic_open( $topic_id );
    608                     $message = ( true === $is_open )
     604                break;
     605
     606            case 'bbp_toggle_topic_close' :
     607                check_admin_referer( 'close-topic_' . $topic_id );
     608
     609                $is_open = bbp_is_topic_open( $topic_id );
     610                $message = ( true === $is_open )
    609611                    ? 'closed'
    610612                    : 'opened';
    611                     $success = ( true === $is_open )
     613                $success = ( true === $is_open )
    612614                    ? bbp_close_topic( $topic_id )
    613615                    : bbp_open_topic( $topic_id );
    614616
    615                     break;
    616 
    617                 case 'bbp_toggle_topic_stick' :
    618                     check_admin_referer( 'stick-topic_' . $topic_id );
    619 
    620                     $is_sticky = bbp_is_topic_sticky( $topic_id );
    621                     $is_super  = ( false === $is_sticky ) && ! empty( $_GET['super'] ) && ( '1' === $_GET['super'] )
     617                break;
     618
     619            case 'bbp_toggle_topic_stick' :
     620                check_admin_referer( 'stick-topic_' . $topic_id );
     621
     622                $is_sticky = bbp_is_topic_sticky( $topic_id );
     623                $is_super  = ( false === $is_sticky ) && ! empty( $_GET['super'] ) && ( '1' === $_GET['super'] )
    622624                    ? true
    623625                    : false;
    624                     $message   = ( true === $is_sticky )
     626                $message   = ( true === $is_sticky )
    625627                    ? 'unstuck'
    626628                    : 'stuck';
    627                     $message   = ( true === $is_super )
     629                $message   = ( true === $is_super )
    628630                    ? 'super_sticky'
    629631                    : $message;
    630                     $success   = ( true === $is_sticky )
     632                $success   = ( true === $is_sticky )
    631633                    ? bbp_unstick_topic( $topic_id )
    632634                    : bbp_stick_topic( $topic_id, $is_super );
    633635
    634                     break;
    635 
    636                 case 'bbp_toggle_topic_spam'  :
    637                     check_admin_referer( 'spam-topic_' . $topic_id );
    638 
    639                     $is_spam = bbp_is_topic_spam( $topic_id );
    640                     $message = ( true === $is_spam )
     636                break;
     637
     638            case 'bbp_toggle_topic_spam'  :
     639                check_admin_referer( 'spam-topic_' . $topic_id );
     640
     641                $is_spam = bbp_is_topic_spam( $topic_id );
     642                $message = ( true === $is_spam )
    641643                    ? 'unspammed'
    642644                    : 'spammed';
    643                     $success = ( true === $is_spam )
     645                $success = ( true === $is_spam )
    644646                    ? bbp_unspam_topic( $topic_id )
    645647                    : bbp_spam_topic( $topic_id );
    646648
    647                     break;
    648             }
    649 
    650             // Setup the message
    651             $retval = array(
     649                break;
     650        }
     651
     652        // Setup the message
     653        $retval = array(
    652654            'bbp_topic_toggle_notice' => $message,
    653655            'topic_id'                => $topic_id
    654             );
    655 
    656             // Prepare for failure
    657             if ( ( false === $success ) || is_wp_error( $success ) ) {
    658                 $retval['failed'] = '1';
    659             }
    660 
    661             // Filter all message args
    662             $retval = apply_filters( 'bbp_toggle_topic_action_admin', $retval, $topic_id, $action );
    663 
    664             // Do additional topic toggle actions (admin side)
    665             do_action( 'bbp_toggle_topic_admin', $success, $post_data, $action, $retval );
    666 
    667             // Redirect back to the topic
    668             $redirect = add_query_arg( $retval, remove_query_arg( array( 'action', 'topic_id' ) ) );
    669             bbp_redirect( $redirect );
    670             }
    671 
    672         /**
    673          * Toggle topic notices
    674          *
    675          * Display the success/error notices from
    676          * {@link BBP_Admin::toggle_topic()}
    677          *
    678          * @since 2.0.0 bbPress (r2727)
    679          */
    680         public function toggle_topic_notice() {
    681 
    682             // Bail if missing topic toggle action
    683             if ( ! bbp_is_get_request() || empty( $_GET['topic_id'] ) || empty( $_GET['bbp_topic_toggle_notice'] ) ) {
    684                 return;
    685             }
    686 
    687             // Bail if not an allowed notice
    688             $notice = sanitize_key( $_GET['bbp_topic_toggle_notice'] );
    689             if ( empty( $notice ) || ! in_array( $notice, $this->get_allowed_notice_toggles(), true ) ) {
    690                 return;
    691             }
    692 
    693             // Bail if no topic_id or notice
    694             $topic_id = bbp_get_topic_id( $_GET['topic_id'] );
    695             if ( empty( $topic_id ) ) {
    696                 return;
    697             }
    698 
    699             // Bail if topic is missing
    700             if ( ! bbp_get_topic( $topic_id ) ) {
    701                 return;
    702             }
    703 
    704             // Use the title in the responses
    705             $topic_title = bbp_get_topic_title( $topic_id );
    706             $is_failure  = ! empty( $_GET['failed'] );
    707             $message     = '';
    708 
    709             // Which notice?
    710             switch ( $notice ) {
    711                 case 'opened'    :
    712                     $message = ( true === $is_failure )
     656        );
     657
     658        // Prepare for failure
     659        if ( ( false === $success ) || is_wp_error( $success ) ) {
     660            $retval['failed'] = '1';
     661        }
     662
     663        // Filter all message args
     664        $retval = apply_filters( 'bbp_toggle_topic_action_admin', $retval, $topic_id, $action );
     665
     666        // Do additional topic toggle actions (admin side)
     667        do_action( 'bbp_toggle_topic_admin', $success, $post_data, $action, $retval );
     668
     669        // Redirect back to the topic
     670        $redirect = add_query_arg( $retval, remove_query_arg( array( 'action', 'topic_id' ) ) );
     671        bbp_redirect( $redirect );
     672    }
     673
     674    /**
     675     * Toggle topic notices
     676     *
     677     * Display the success/error notices from
     678     * {@link BBP_Admin::toggle_topic()}
     679     *
     680     * @since 2.0.0 bbPress (r2727)
     681     */
     682    public function toggle_topic_notice() {
     683
     684        // Bail if missing topic toggle action
     685        if ( ! bbp_is_get_request() || empty( $_GET['topic_id'] ) || empty( $_GET['bbp_topic_toggle_notice'] ) ) {
     686            return;
     687        }
     688
     689        // Bail if not an allowed notice
     690        $notice = sanitize_key( $_GET['bbp_topic_toggle_notice'] );
     691        if ( empty( $notice ) || ! in_array( $notice, $this->get_allowed_notice_toggles(), true ) ) {
     692            return;
     693        }
     694
     695        // Bail if no topic_id or notice
     696        $topic_id = bbp_get_topic_id( $_GET['topic_id'] );
     697        if ( empty( $topic_id ) ) {
     698            return;
     699        }
     700
     701        // Bail if topic is missing
     702        if ( ! bbp_get_topic( $topic_id ) ) {
     703            return;
     704        }
     705
     706        // Use the title in the responses
     707        $topic_title = bbp_get_topic_title( $topic_id );
     708        $is_failure  = ! empty( $_GET['failed'] );
     709        $message     = '';
     710
     711        // Which notice?
     712        switch ( $notice ) {
     713            case 'opened'    :
     714                $message = ( true === $is_failure )
     715                    /* translators: %1$s: Topic title */
    713716                    ? sprintf( esc_html__( 'There was a problem opening the topic "%1$s".', 'bbpress' ), $topic_title )
     717                    /* translators: %1$s: Topic title */
    714718                    : sprintf( esc_html__( 'Topic "%1$s" successfully opened.',             'bbpress' ), $topic_title );
    715                     break;
    716 
    717                 case 'closed'    :
    718                     $message = ( true === $is_failure )
     719                break;
     720
     721            case 'closed'    :
     722                $message = ( true === $is_failure )
     723                    /* translators: %1$s: Topic title */
    719724                    ? sprintf( esc_html__( 'There was a problem closing the topic "%1$s".', 'bbpress' ), $topic_title )
     725                    /* translators: %1$s: Topic title */
    720726                    : sprintf( esc_html__( 'Topic "%1$s" successfully closed.',             'bbpress' ), $topic_title );
    721                     break;
    722 
    723                 case 'super_sticky' :
    724                     $message = ( true === $is_failure )
     727                break;
     728
     729            case 'super_sticky' :
     730                $message = ( true === $is_failure )
     731                    /* translators: %1$s: Topic title */
    725732                    ? sprintf( esc_html__( 'There was a problem sticking the topic "%1$s" to front.', 'bbpress' ), $topic_title )
     733                    /* translators: %1$s: Topic title */
    726734                    : sprintf( esc_html__( 'Topic "%1$s" successfully stuck to front.',               'bbpress' ), $topic_title );
    727                     break;
    728 
    729                 case 'stuck'   :
    730                     $message = ( true === $is_failure )
     735                break;
     736
     737            case 'stuck'   :
     738                $message = ( true === $is_failure )
     739                    /* translators: %1$s: Topic title */
    731740                    ? sprintf( esc_html__( 'There was a problem sticking the topic "%1$s".', 'bbpress' ), $topic_title )
     741                    /* translators: %1$s: Topic title */
    732742                    : sprintf( esc_html__( 'Topic "%1$s" successfully stuck.',               'bbpress' ), $topic_title );
    733                     break;
    734 
    735                 case 'unstuck' :
    736                     $message = ( true === $is_failure  )
     743                break;
     744
     745            case 'unstuck' :
     746                $message = ( true === $is_failure  )
     747                    /* translators: %1$s: Topic title */
    737748                    ? sprintf( esc_html__( 'There was a problem unsticking the topic "%1$s".', 'bbpress' ), $topic_title )
     749                    /* translators: %1$s: Topic title */
    738750                    : sprintf( esc_html__( 'Topic "%1$s" successfully unstuck.',               'bbpress' ), $topic_title );
    739                     break;
    740 
    741                 case 'spammed'   :
    742                     $message = ( true === $is_failure )
     751                break;
     752
     753            case 'spammed'   :
     754                $message = ( true === $is_failure )
     755                    /* translators: %1$s: Topic title */
    743756                    ? sprintf( esc_html__( 'There was a problem marking the topic "%1$s" as spam.', 'bbpress' ), $topic_title )
     757                    /* translators: %1$s: Topic title */
    744758                    : sprintf( esc_html__( 'Topic "%1$s" successfully marked as spam.',             'bbpress' ), $topic_title );
    745                     break;
    746 
    747                 case 'unspammed' :
    748                     $message = ( true === $is_failure )
     759                break;
     760
     761            case 'unspammed' :
     762                $message = ( true === $is_failure )
     763                    /* translators: %1$s: Topic title */
    749764                    ? sprintf( esc_html__( 'There was a problem unmarking the topic "%1$s" as spam.', 'bbpress' ), $topic_title )
     765                    /* translators: %1$s: Topic title */
    750766                    : sprintf( esc_html__( 'Topic "%1$s" successfully unmarked as spam.',             'bbpress' ), $topic_title );
    751                     break;
    752 
    753                 case 'approved'   :
    754                     $message = ( true === $is_failure )
     767                break;
     768
     769            case 'approved'   :
     770                $message = ( true === $is_failure )
     771                    /* translators: %1$s: Topic title */
    755772                    ? sprintf( esc_html__( 'There was a problem approving the topic "%1$s".', 'bbpress' ), $topic_title )
     773                    /* translators: %1$s: Topic title */
    756774                    : sprintf( esc_html__( 'Topic "%1$s" successfully approved.',             'bbpress' ), $topic_title );
    757                     break;
    758 
    759                 case 'unapproved' :
    760                     $message = ( true === $is_failure )
     775                break;
     776
     777            case 'unapproved' :
     778                $message = ( true === $is_failure )
     779                    /* translators: %1$s: Topic title */
    761780                    ? sprintf( esc_html__( 'There was a problem unapproving the topic "%1$s".', 'bbpress' ), $topic_title )
     781                    /* translators: %1$s: Topic title */
    762782                    : sprintf( esc_html__( 'Topic "%1$s" successfully unapproved.',             'bbpress' ), $topic_title );
    763                     break;
    764             }
    765 
    766             // Do additional topic toggle notice filters (admin side)
    767             $message = apply_filters( 'bbp_toggle_topic_notice_admin', $message, $topic_id, $notice, $is_failure );
    768             $class   = ( true === $is_failure )
     783                break;
     784        }
     785
     786        // Do additional topic toggle notice filters (admin side)
     787        $message = apply_filters( 'bbp_toggle_topic_notice_admin', $message, $topic_id, $notice, $is_failure );
     788        $class   = ( true === $is_failure )
    769789            ? 'error'
    770790            : 'updated';
    771791
    772             // Add the notice
    773             bbp_admin()->add_notice( $message, $class, true );
    774             }
    775 
    776         /**
    777         * Returns an array of keys used to sort row actions
    778         *
    779         * @since 2.6.0 bbPress (r6771)
    780         *
    781         * @return array
    782         */
    783         private function get_row_action_sort_order() {
    784 
    785             // Filter & return
    786             return (array) apply_filters( 'bbp_admin_topics_row_action_sort_order', array(
     792        // Add the notice
     793        bbp_admin()->add_notice( $message, $class, true );
     794    }
     795
     796    /**
     797    * Returns an array of keys used to sort row actions
     798    *
     799    * @since 2.6.0 bbPress (r6771)
     800    *
     801    * @return array
     802    */
     803    private function get_row_action_sort_order() {
     804
     805        // Filter & return
     806        return (array) apply_filters( 'bbp_admin_topics_row_action_sort_order', array(
    787807            'edit',
    788808            'stick',
     
    796816            'delete',
    797817            'view'
    798             ) );
    799             }
    800 
    801         /**
    802         * Returns an array of notice toggles
    803         *
    804         * @since 2.6.0 bbPress (r6396)
    805         *
    806         * @return array
    807         */
    808         private function get_allowed_notice_toggles() {
    809 
    810             // Filter & return
    811             return (array) apply_filters( 'bbp_admin_topics_allowed_notice_toggles', array(
     818        ) );
     819    }
     820
     821    /**
     822    * Returns an array of notice toggles
     823    *
     824    * @since 2.6.0 bbPress (r6396)
     825    *
     826    * @return array
     827    */
     828    private function get_allowed_notice_toggles() {
     829
     830        // Filter & return
     831        return (array) apply_filters( 'bbp_admin_topics_allowed_notice_toggles', array(
    812832            'opened',
    813833            'closed',
     
    819839            'approved',
    820840            'unapproved'
    821             ) );
    822             }
    823 
    824         /**
    825         * Returns an array of notice toggles
    826         *
    827         * @since 2.6.0 bbPress (r6396)
    828         *
    829         * @return array
    830         */
    831         private function get_allowed_action_toggles() {
    832 
    833             // Filter & return
    834             return (array) apply_filters( 'bbp_admin_topics_allowed_action_toggles', array(
     841        ) );
     842    }
     843
     844    /**
     845    * Returns an array of notice toggles
     846    *
     847    * @since 2.6.0 bbPress (r6396)
     848    *
     849    * @return array
     850    */
     851    private function get_allowed_action_toggles() {
     852
     853        // Filter & return
     854        return (array) apply_filters( 'bbp_admin_topics_allowed_action_toggles', array(
    835855            'bbp_toggle_topic_close',
    836856            'bbp_toggle_topic_stick',
    837857            'bbp_toggle_topic_spam',
    838858            'bbp_toggle_topic_approve'
    839             ) );
    840             }
    841 
    842         /**
    843         * Manage the column headers for the topics page
    844         *
    845         * @since 2.0.0 bbPress (r2485)
    846         *
    847         * @param array $columns The columns
    848         *
    849         * @return array $columns bbPress topic columns
    850         */
    851         public function column_headers( $columns ) {
    852             $columns = array(
     859        ) );
     860    }
     861
     862    /**
     863    * Manage the column headers for the topics page
     864    *
     865    * @since 2.0.0 bbPress (r2485)
     866    *
     867    * @param array $columns The columns
     868    *
     869    * @return array $columns bbPress topic columns
     870    */
     871    public function column_headers( $columns ) {
     872        $columns = array(
    853873            'cb'                    => '<input type="checkbox" />',
    854874            'title'                 => esc_html__( 'Topics',    'bbpress' ),
     
    859879            'bbp_topic_created'     => esc_html__( 'Created',   'bbpress' ),
    860880            'bbp_topic_freshness'   => esc_html__( 'Last Post', 'bbpress' )
    861             );
    862 
    863             // Filter & return
    864             return (array) apply_filters( 'bbp_admin_topics_column_headers', $columns );
    865             }
    866 
    867         /**
    868         * Print extra columns for the topics page
    869         *
    870         * @since 2.0.0 bbPress (r2485)
    871         *
    872         * @param string $column Column
    873         * @param int $topic_id Topic id
    874         */
    875         public function column_data( $column, $topic_id ) {
    876 
    877             // Get topic forum ID
    878             $forum_id = bbp_get_topic_forum_id( $topic_id );
    879 
    880             // Populate column data
    881             switch ( $column ) {
    882 
    883                 // Forum
    884                 case 'bbp_topic_forum' :
    885 
    886                     // Get title
    887                     $forum_title = ! empty( $forum_id )
     881        );
     882
     883        // Filter & return
     884        return (array) apply_filters( 'bbp_admin_topics_column_headers', $columns );
     885    }
     886
     887    /**
     888    * Print extra columns for the topics page
     889    *
     890    * @since 2.0.0 bbPress (r2485)
     891    *
     892    * @param string $column Column
     893    * @param int $topic_id Topic id
     894    */
     895    public function column_data( $column, $topic_id ) {
     896
     897        // Get topic forum ID
     898        $forum_id = bbp_get_topic_forum_id( $topic_id );
     899
     900        // Populate column data
     901        switch ( $column ) {
     902
     903            // Forum
     904            case 'bbp_topic_forum' :
     905
     906                // Get title
     907                $forum_title = ! empty( $forum_id )
    888908                    ? bbp_get_forum_title( $forum_id )
    889909                    : '';
    890910
    891                     // Output forum name
    892                     if ( ! empty( $forum_title ) ) {
    893                         echo $forum_title;
    894 
    895                     // Output dash
    896                     } else {
    897                         ?>
     911                // Output forum name
     912                if ( ! empty( $forum_title ) ) {
     913                    echo $forum_title;
     914
     915                // Output dash
     916                } else {
     917                    ?>
    898918                    <span aria-hidden="true">&mdash;</span>
    899919                    <span class="screen-reader-text"><?php esc_html_e( 'No forum', 'bbpress' ); ?></span>
    900920                    <?php
    901                     }
    902 
    903                     break;
    904 
    905                 // Reply Count
    906                 case 'bbp_topic_reply_count' :
    907                     bbp_topic_reply_count( $topic_id );
    908                     break;
    909 
    910                 // Reply Count
    911                 case 'bbp_topic_voice_count' :
    912                     bbp_topic_voice_count( $topic_id );
    913                     break;
    914 
    915                 // Author
    916                 case 'bbp_topic_author' :
    917                     bbp_topic_author_display_name( $topic_id );
    918                     break;
    919 
    920                 // Freshness
    921                 case 'bbp_topic_created':
    922                     printf( '%1$s <br /> %2$s',
     921                }
     922
     923                break;
     924
     925            // Reply Count
     926            case 'bbp_topic_reply_count' :
     927                bbp_topic_reply_count( $topic_id );
     928                break;
     929
     930            // Reply Count
     931            case 'bbp_topic_voice_count' :
     932                bbp_topic_voice_count( $topic_id );
     933                break;
     934
     935            // Author
     936            case 'bbp_topic_author' :
     937                bbp_topic_author_display_name( $topic_id );
     938                break;
     939
     940            // Freshness
     941            case 'bbp_topic_created':
     942                printf( '%1$s <br /> %2$s',
    923943                    get_the_date(),
    924944                    esc_attr( get_the_time() )
    925                     );
    926 
    927                     break;
    928 
    929                 // Freshness
    930                 case 'bbp_topic_freshness' :
    931                     $last_active = bbp_get_topic_last_active_time( $topic_id, false );
    932                     if ( ! empty( $last_active ) ) {
    933                         echo esc_html( $last_active );
    934                     } else {
    935                         esc_html_e( 'No Replies', 'bbpress' ); // This should never happen
    936                     }
    937 
    938                     break;
    939 
    940                 // Do an action for anything else
    941                 default :
    942                     do_action( 'bbp_admin_topics_column_data', $column, $topic_id );
    943                     break;
     945                );
     946
     947                break;
     948
     949            // Freshness
     950            case 'bbp_topic_freshness' :
     951                $last_active = bbp_get_topic_last_active_time( $topic_id, false );
     952                if ( ! empty( $last_active ) ) {
     953                    echo esc_html( $last_active );
     954                } else {
     955                    esc_html_e( 'No Replies', 'bbpress' ); // This should never happen
     956                }
     957
     958                break;
     959
     960            // Do an action for anything else
     961            default :
     962                do_action( 'bbp_admin_topics_column_data', $column, $topic_id );
     963                break;
     964        }
     965    }
     966
     967    /**
     968     * Topic Row actions
     969     *
     970     * Remove the quick-edit action link under the topic title and add the
     971     * content and close/stick/spam links
     972     *
     973     * @since 2.0.0 bbPress (r2485)
     974     *
     975     * @param array  $actions Actions
     976     * @param object $topic   Topic object
     977     *
     978     * @return array $actions Actions
     979     */
     980    public function row_actions( $actions = array(), $topic = false ) {
     981
     982        // Disable quick edit (too much to do here)
     983        unset( $actions['inline hide-if-no-js'] );
     984
     985        // View link
     986        $view_link = bbp_get_topic_permalink( $topic->ID );
     987
     988        // Maybe add view=all
     989        if ( ! in_array( $topic->post_status, array( bbp_get_closed_status_id(), bbp_get_public_status_id() ), true ) ) {
     990            $view_link = bbp_add_view_all( $view_link, true );
     991        }
     992
     993        // Show view link if it's not set, the topic is trashed and the user can view trashed topics
     994        if ( empty( $actions['view'] ) && ( bbp_get_trash_status_id() === $topic->post_status ) && current_user_can( 'view_trash' ) ) {
     995            /* translators: %s: Topic title */
     996            $actions['view'] = '<a href="' . esc_url( $view_link ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;', 'bbpress' ), bbp_get_topic_title( $topic->ID ) ) ) . '" rel="permalink">' . esc_html__( 'View', 'bbpress' ) . '</a>';
     997        }
     998
     999        // Only show the actions if the user is capable of viewing them :)
     1000        if ( current_user_can( 'moderate', $topic->ID ) ) {
     1001
     1002            // Pending
     1003            // Show the 'approve' and 'view' link on pending posts only and 'unapprove' on published posts only
     1004            $approve_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_approve' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'approve-topic_' . $topic->ID );
     1005            if ( bbp_is_topic_public( $topic->ID ) ) {
     1006                $actions['unapproved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Unapprove this topic', 'bbpress' ) . '">' . _x( 'Unapprove', 'Unapprove Topic', 'bbpress' ) . '</a>';
     1007            } else {
     1008
     1009                // Do not show 'approve' if already public
     1010                if ( ! bbp_is_topic_public( $topic->ID ) ) {
     1011                    $actions['approved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Approve this topic',   'bbpress' ) . '">' . _x( 'Approve',   'Approve Topic',   'bbpress' ) . '</a>';
     1012                }
     1013
     1014                // Modify the view link
     1015                /* translators: %s: Topic title */
     1016                $actions['view'] = '<a href="' . esc_url( $view_link   ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;', 'bbpress' ), bbp_get_topic_title( $topic->ID ) ) ) . '" rel="permalink">' . esc_html__( 'View', 'bbpress' ) . '</a>';
    9441017            }
    945             }
    946 
    947         /**
    948          * Topic Row actions
    949          *
    950          * Remove the quick-edit action link under the topic title and add the
    951          * content and close/stick/spam links
    952          *
    953          * @since 2.0.0 bbPress (r2485)
    954          *
    955          * @param array  $actions Actions
    956          * @param object $topic   Topic object
    957          *
    958          * @return array $actions Actions
    959          */
    960         public function row_actions( $actions = array(), $topic = false ) {
    961 
    962             // Disable quick edit (too much to do here)
    963             unset( $actions['inline hide-if-no-js'] );
    964 
    965             // View link
    966             $view_link = bbp_get_topic_permalink( $topic->ID );
    967 
    968             // Maybe add view=all
    969             if ( ! in_array( $topic->post_status, array( bbp_get_closed_status_id(), bbp_get_public_status_id() ), true ) ) {
    970                 $view_link = bbp_add_view_all( $view_link, true );
    971             }
    972 
    973             // Show view link if it's not set, the topic is trashed and the user can view trashed topics
    974             if ( empty( $actions['view'] ) && ( bbp_get_trash_status_id() === $topic->post_status ) && current_user_can( 'view_trash' ) ) {
    975                 $actions['view'] = '<a href="' . esc_url( $view_link ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;', 'bbpress' ), bbp_get_topic_title( $topic->ID ) ) ) . '" rel="permalink">' . esc_html__( 'View', 'bbpress' ) . '</a>';
    976             }
    977 
    978             // Only show the actions if the user is capable of viewing them :)
    979             if ( current_user_can( 'moderate', $topic->ID ) ) {
    980 
    981                 // Pending
    982                 // Show the 'approve' and 'view' link on pending posts only and 'unapprove' on published posts only
    983                 $approve_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_approve' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'approve-topic_' . $topic->ID );
    984                 if ( bbp_is_topic_public( $topic->ID ) ) {
    985                     $actions['unapproved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Unapprove this topic', 'bbpress' ) . '">' . _x( 'Unapprove', 'Unapprove Topic', 'bbpress' ) . '</a>';
     1018
     1019            // Close
     1020            // Show the 'close' and 'open' link on published and closed posts only
     1021            if ( bbp_is_topic_public( $topic->ID ) ) {
     1022                $close_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_close' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'close-topic_' . $topic->ID );
     1023                if ( bbp_is_topic_open( $topic->ID ) ) {
     1024                    $actions['closed'] = '<a href="' . esc_url( $close_uri ) . '" title="' . esc_attr__( 'Close this topic', 'bbpress' ) . '">' . _x( 'Close', 'Close a Topic', 'bbpress' ) . '</a>';
    9861025                } else {
    987 
    988                     // Do not show 'approve' if already public
    989                     if ( ! bbp_is_topic_public( $topic->ID ) ) {
    990                         $actions['approved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Approve this topic',   'bbpress' ) . '">' . _x( 'Approve',   'Approve Topic',   'bbpress' ) . '</a>';
    991                     }
    992 
    993                     // Modify the view link
    994                     $actions['view'] = '<a href="' . esc_url( $view_link   ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;', 'bbpress' ), bbp_get_topic_title( $topic->ID ) ) ) . '" rel="permalink">' . esc_html__( 'View', 'bbpress' ) . '</a>';
    995                 }
    996 
    997                 // Close
    998                 // Show the 'close' and 'open' link on published and closed posts only
    999                 if ( bbp_is_topic_public( $topic->ID ) ) {
    1000                     $close_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_close' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'close-topic_' . $topic->ID );
    1001                     if ( bbp_is_topic_open( $topic->ID ) ) {
    1002                         $actions['closed'] = '<a href="' . esc_url( $close_uri ) . '" title="' . esc_attr__( 'Close this topic', 'bbpress' ) . '">' . _x( 'Close', 'Close a Topic', 'bbpress' ) . '</a>';
    1003                     } else {
    1004                         $actions['closed'] = '<a href="' . esc_url( $close_uri ) . '" title="' . esc_attr__( 'Open this topic',  'bbpress' ) . '">' . _x( 'Open',  'Open a Topic',  'bbpress' ) . '</a>';
    1005                     }
    1006                 }
    1007 
    1008                 // Sticky
    1009                 // Dont show sticky if topic is spam, trash or pending
    1010                 if ( ! bbp_is_topic_spam( $topic->ID ) && ! bbp_is_topic_trash( $topic->ID ) && ! bbp_is_topic_pending( $topic->ID ) ) {
    1011                     $stick_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'stick-topic_'  . $topic->ID );
    1012                     if ( bbp_is_topic_sticky( $topic->ID ) ) {
    1013                         $actions['stick'] = '<a href="' . esc_url( $stick_uri ) . '" title="' . esc_attr__( 'Unstick this topic', 'bbpress' ) . '">' . esc_html__( 'Unstick', 'bbpress' ) . '</a>';
    1014                     } else {
    1015                         $super_uri        = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick', 'super' => '1' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'stick-topic_'  . $topic->ID );
    1016                         $actions['stick'] = '<a href="' . esc_url( $stick_uri ) . '" title="' . esc_attr__( 'Stick this topic to its forum', 'bbpress' ) . '">' . esc_html__( 'Stick', 'bbpress' ) . '</a> <a href="' . esc_url( $super_uri ) . '" title="' . esc_attr__( 'Stick this topic to front', 'bbpress' ) . '">' . esc_html__( '(to front)', 'bbpress' ) . '</a>';
    1017                     }
    1018                 }
    1019 
    1020                 // Spam
    1021                 $spam_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_spam' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'spam-topic_'  . $topic->ID );
    1022                 if ( ! bbp_is_topic_spam( $topic->ID ) ) {
    1023                     $actions['spam'] = '<a href="' . esc_url( $spam_uri ) . '" title="' . esc_attr__( 'Mark this topic as spam',    'bbpress' ) . '">' . esc_html__( 'Spam',     'bbpress' ) . '</a>';
    1024                 } else {
    1025                     $actions['unspam'] = '<a href="' . esc_url( $spam_uri ) . '" title="' . esc_attr__( 'Mark the topic as not spam', 'bbpress' ) . '">' . esc_html__( 'Not Spam', 'bbpress' ) . '</a>';
     1026                    $actions['closed'] = '<a href="' . esc_url( $close_uri ) . '" title="' . esc_attr__( 'Open this topic',  'bbpress' ) . '">' . _x( 'Open',  'Open a Topic',  'bbpress' ) . '</a>';
    10261027                }
    10271028            }
    10281029
    1029             // Do not show trash links for spam topics, or spam links for trashed topics
    1030             if ( current_user_can( 'delete_topic', $topic->ID ) ) {
    1031                 $trash_days = bbp_get_trash_days( bbp_get_topic_post_type() );
    1032 
    1033                 if ( bbp_get_trash_status_id() === $topic->post_status ) {
    1034                     $post_type_object   = get_post_type_object( bbp_get_topic_post_type() );
    1035                     $actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash', 'bbpress' ) . "' href='" . esc_url( wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $topic->ID ) ), 'untrash-post_' . $topic->ID ) ) . "'>" . esc_html__( 'Restore', 'bbpress' ) . '</a>';
    1036                 } elseif ( ! empty( $trash_days ) ) {
    1037                     $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash', 'bbpress' ) . "' href='" . esc_url( get_delete_post_link( $topic->ID ) ) . "'>" . esc_html__( 'Trash', 'bbpress' ) . '</a>';
    1038                 }
    1039 
    1040                 if ( ( bbp_get_trash_status_id() === $topic->post_status ) || empty( $trash_days ) ) {
    1041                     $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently', 'bbpress' ) . "' href='" . esc_url( get_delete_post_link( $topic->ID, '', true ) ) . "'>" . esc_html__( 'Delete Permanently', 'bbpress' ) . '</a>';
     1030            // Sticky
     1031            // Dont show sticky if topic is spam, trash or pending
     1032            if ( ! bbp_is_topic_spam( $topic->ID ) && ! bbp_is_topic_trash( $topic->ID ) && ! bbp_is_topic_pending( $topic->ID ) ) {
     1033                $stick_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'stick-topic_'  . $topic->ID );
     1034                if ( bbp_is_topic_sticky( $topic->ID ) ) {
     1035                    $actions['stick'] = '<a href="' . esc_url( $stick_uri ) . '" title="' . esc_attr__( 'Unstick this topic', 'bbpress' ) . '">' . esc_html__( 'Unstick', 'bbpress' ) . '</a>';
     1036                } else {
     1037                    $super_uri        = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick', 'super' => '1' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'stick-topic_'  . $topic->ID );
     1038                    $actions['stick'] = '<a href="' . esc_url( $stick_uri ) . '" title="' . esc_attr__( 'Stick this topic to its forum', 'bbpress' ) . '">' . esc_html__( 'Stick', 'bbpress' ) . '</a> <a href="' . esc_url( $super_uri ) . '" title="' . esc_attr__( 'Stick this topic to front', 'bbpress' ) . '">' . esc_html__( '(to front)', 'bbpress' ) . '</a>';
    10421039                }
    10431040            }
    10441041
    1045             // Sort & return
    1046             return $this->sort_row_actions( $actions );
     1042            // Spam
     1043            $spam_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_spam' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'spam-topic_'  . $topic->ID );
     1044            if ( ! bbp_is_topic_spam( $topic->ID ) ) {
     1045                $actions['spam'] = '<a href="' . esc_url( $spam_uri ) . '" title="' . esc_attr__( 'Mark this topic as spam',    'bbpress' ) . '">' . esc_html__( 'Spam',     'bbpress' ) . '</a>';
     1046            } else {
     1047                $actions['unspam'] = '<a href="' . esc_url( $spam_uri ) . '" title="' . esc_attr__( 'Mark the topic as not spam', 'bbpress' ) . '">' . esc_html__( 'Not Spam', 'bbpress' ) . '</a>';
    10471048            }
    1048 
    1049         /**
    1050          * Sort row actions by key
    1051          *
    1052          * @since 2.6.0
    1053          *
    1054          * @param array $actions
    1055          *
    1056          * @return array
    1057          */
    1058         private function sort_row_actions( $actions = array() ) {
    1059 
    1060             // Return value
    1061             $retval = array();
    1062 
    1063             // Known row actions, in sort order
    1064             $known_actions = $this->get_row_action_sort_order();
    1065 
    1066             // Sort known actions, and keep any unknown ones
    1067             foreach ( $known_actions as $key ) {
    1068                 if ( isset( $actions[ $key ] ) ) {
    1069                     $retval[ $key ] = $actions[ $key ];
    1070                     unset( $actions[ $key ] );
    1071                 }
     1049        }
     1050
     1051        // Do not show trash links for spam topics, or spam links for trashed topics
     1052        if ( current_user_can( 'delete_topic', $topic->ID ) ) {
     1053            $trash_days = bbp_get_trash_days( bbp_get_topic_post_type() );
     1054
     1055            if ( bbp_get_trash_status_id() === $topic->post_status ) {
     1056                $post_type_object   = get_post_type_object( bbp_get_topic_post_type() );
     1057                $actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash', 'bbpress' ) . "' href='" . esc_url( wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $topic->ID ) ), 'untrash-post_' . $topic->ID ) ) . "'>" . esc_html__( 'Restore', 'bbpress' ) . '</a>';
     1058            } elseif ( ! empty( $trash_days ) ) {
     1059                $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash', 'bbpress' ) . "' href='" . esc_url( get_delete_post_link( $topic->ID ) ) . "'>" . esc_html__( 'Trash', 'bbpress' ) . '</a>';
    10721060            }
    10731061
    1074             // Combine & return
    1075             return $retval + $actions;
     1062            if ( ( bbp_get_trash_status_id() === $topic->post_status ) || empty( $trash_days ) ) {
     1063                $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently', 'bbpress' ) . "' href='" . esc_url( get_delete_post_link( $topic->ID, '', true ) ) . "'>" . esc_html__( 'Delete Permanently', 'bbpress' ) . '</a>';
    10761064            }
    1077 
    1078         /**
    1079          * Add forum dropdown to topic and reply list table filters
    1080          *
    1081          * @since 2.0.0 bbPress (r2991)
    1082          *
    1083          * @return bool False. If post type is not topic or reply
    1084          */
    1085         public function filter_dropdown() {
    1086 
    1087             // Get which forum is selected
    1088             $selected = ! empty( $_GET['bbp_forum_id'] )
     1065        }
     1066
     1067        // Sort & return
     1068        return $this->sort_row_actions( $actions );
     1069    }
     1070
     1071    /**
     1072     * Sort row actions by key
     1073     *
     1074     * @since 2.6.0
     1075     *
     1076     * @param array $actions
     1077     *
     1078     * @return array
     1079     */
     1080    private function sort_row_actions( $actions = array() ) {
     1081
     1082        // Return value
     1083        $retval = array();
     1084
     1085        // Known row actions, in sort order
     1086        $known_actions = $this->get_row_action_sort_order();
     1087
     1088        // Sort known actions, and keep any unknown ones
     1089        foreach ( $known_actions as $key ) {
     1090            if ( isset( $actions[ $key ] ) ) {
     1091                $retval[ $key ] = $actions[ $key ];
     1092                unset( $actions[ $key ] );
     1093            }
     1094        }
     1095
     1096        // Combine & return
     1097        return $retval + $actions;
     1098    }
     1099
     1100    /**
     1101     * Add forum dropdown to topic and reply list table filters
     1102     *
     1103     * @since 2.0.0 bbPress (r2991)
     1104     *
     1105     * @return bool False. If post type is not topic or reply
     1106     */
     1107    public function filter_dropdown() {
     1108
     1109        // Get which forum is selected
     1110        $selected = ! empty( $_GET['bbp_forum_id'] )
    10891111            ? (int) $_GET['bbp_forum_id']
    10901112            : 0;
    10911113
    1092             // Show the forums dropdown
    1093             bbp_dropdown( array(
    1094             'selected'  => $selected,
    1095             'show_none' => esc_html__( 'In all forums', 'bbpress' )
    1096             ) );
    1097             }
    1098 
    1099         /**
    1100          * Add "Empty Spam" button for moderators
    1101          *
    1102          * @since 2.6.0 bbPress (r6791)
    1103          */
    1104         public function filter_empty_spam() {
    1105 
    1106             // Bail if not viewing spam
    1107             if ( empty( $_GET['post_status'] ) || ( bbp_get_spam_status_id() !== $_GET['post_status'] ) && current_user_can( 'moderate' ) ) {
    1108                 return;
    1109             }
    1110 
    1111             ?>
     1114        // Show the forums dropdown
     1115        bbp_dropdown(
     1116            array(
     1117                'selected'  => $selected,
     1118                'show_none' => esc_html__( 'In all forums', 'bbpress' )
     1119            )
     1120        );
     1121    }
     1122
     1123    /**
     1124     * Add "Empty Spam" button for moderators
     1125     *
     1126     * @since 2.6.0 bbPress (r6791)
     1127     */
     1128    public function filter_empty_spam() {
     1129
     1130        // Bail if not viewing spam
     1131        if ( empty( $_GET['post_status'] ) || ( bbp_get_spam_status_id() !== $_GET['post_status'] ) && current_user_can( 'moderate' ) ) {
     1132            return;
     1133        }
     1134
     1135        ?>
    11121136
    11131137        <div class="alignleft actions"><?php
     
    11201144                'delete_all',
    11211145                false
    1122                 );
    1123 
    1124             ?></div><?php
    1125     }
    1126 
    1127         /**
    1128         * Adjust the request query and include the forum id
    1129         *
    1130         * @since 2.0.0 bbPress (r2991)
    1131         *
    1132         * @param array $query_vars Query variables from {@link WP_Query}
    1133         * @return array Processed Query Vars
    1134         */
    1135         function filter_post_rows( $query_vars ) {
    1136 
    1137             // Add post_parent query_var if one is present
    1138             if ( ! empty( $_GET['bbp_forum_id'] ) ) {
    1139                 $query_vars['meta_key']   = '_bbp_forum_id';
    1140                 $query_vars['meta_type']  = 'NUMERIC';
    1141                 $query_vars['meta_value'] = $_GET['bbp_forum_id'];
    1142             }
    1143 
    1144             // Return manipulated query_vars
    1145             return $query_vars;
    1146             }
    1147 
    1148         /**
    1149         * Custom user feedback messages for topic post type
    1150         *
    1151         * @since 2.0.0 bbPress (r3080)
    1152         *
    1153         * @global int $post_ID
    1154         *
    1155         * @param array $messages
    1156         *
    1157         * @return array
    1158         */
    1159         public function updated_messages( $messages ) {
    1160             global $post_ID;
    1161 
    1162             // URL for the current topic
    1163             $topic_url = bbp_get_topic_permalink( $post_ID );
    1164 
    1165             // Current topic's post_date
    1166             $post_date = bbp_get_global_post_field( 'post_date', 'raw' );
    1167 
    1168             // Messages array
    1169             $messages[ $this->post_type ] = array(
     1146            );
     1147
     1148        ?></div><?php
     1149    }
     1150
     1151    /**
     1152    * Adjust the request query and include the forum id
     1153    *
     1154    * @since 2.0.0 bbPress (r2991)
     1155    *
     1156    * @param array $query_vars Query variables from {@link WP_Query}
     1157    * @return array Processed Query Vars
     1158    */
     1159    function filter_post_rows( $query_vars ) {
     1160
     1161        // Add post_parent query_var if one is present
     1162        if ( ! empty( $_GET['bbp_forum_id'] ) ) {
     1163            $query_vars['meta_key']   = '_bbp_forum_id';
     1164            $query_vars['meta_type']  = 'NUMERIC';
     1165            $query_vars['meta_value'] = $_GET['bbp_forum_id'];
     1166        }
     1167
     1168        // Return manipulated query_vars
     1169        return $query_vars;
     1170    }
     1171
     1172    /**
     1173    * Custom user feedback messages for topic post type
     1174    *
     1175    * @since 2.0.0 bbPress (r3080)
     1176    *
     1177    * @global int $post_ID
     1178    *
     1179    * @param array $messages
     1180    *
     1181    * @return array
     1182    */
     1183    public function updated_messages( $messages ) {
     1184        global $post_ID;
     1185
     1186        // URL for the current topic
     1187        $topic_url = bbp_get_topic_permalink( $post_ID );
     1188
     1189        // Current topic's post_date
     1190        $post_date = bbp_get_global_post_field( 'post_date', 'raw' );
     1191
     1192        // Messages array
     1193        $messages[ $this->post_type ] = array(
    11701194            0 => '', // Left empty on purpose
    11711195
     
    11881212
    11891213            // Restored from revision
    1190             // translators: %s: date and time of the revision
     1214            /* translators: %s: date and time of the revision */
    11911215            5 => isset( $_GET['revision'] )
     1216                    /* translators: %s: Date and time of the revision */
    11921217                    ? sprintf( esc_html__( 'Topic restored to revision from %s', 'bbpress' ), wp_post_revision_title( (int) $_GET['revision'], false ) )
    11931218                    : false,
     
    12161241                '%1$s <a target="_blank" href="%2$s">%3$s</a>',
    12171242                sprintf(
     1243                    /* translators: Publish box date format, see http://php.net/date */
    12181244                    esc_html__( 'Topic scheduled for: %s.', 'bbpress' ),
    1219                     // translators: Publish box date format, see http://php.net/date
    12201245                    '<strong>' . date_i18n( __( 'M j, Y @ G:i', 'bbpress' ), strtotime( $post_date ) ) . '</strong>'
    12211246                ),
     
    12311256                esc_html__( 'Preview topic', 'bbpress' )
    12321257            ),
    1233             );
    1234 
    1235             return $messages;
    1236             }
     1258        );
     1259
     1260        return $messages;
     1261    }
    12371262}
    12381263endif; // class_exists check
  • trunk/src/includes/common/classes.php

    r7357 r7360  
    491491        // Determine reply title (either post_title, or excerpt of post_content)
    492492        $title = ! empty( $object->post_title ) ? $object->post_title : wp_html_excerpt( $object->post_content, 10 );
     493        /* translators: 1: Reply ID, 2: Reply title */
    493494        $title   = sprintf( esc_html__( '%1$s - %2$s', 'bbpress' ), (int) $object->ID, $title );
    494495        $title   = apply_filters( 'bbp_walker_dropdown_post_title', $title, $output, $object, $depth, $args );
  • trunk/src/includes/common/formatting.php

    r7359 r7360  
    646646        $unknown_text   = apply_filters( 'bbp_core_time_since_unknown_text',   esc_html__( 'sometime',  'bbpress' ) );
    647647        $right_now_text = apply_filters( 'bbp_core_time_since_right_now_text', esc_html__( 'right now', 'bbpress' ) );
     648        /* translators: %s: Time period */
    648649        $ago_text       = apply_filters( 'bbp_core_time_since_ago_text',       esc_html__( '%s ago',    'bbpress' ) );
    649650
    650651        // array of time period chunks
    651652        $chunks = array(
     653            /* translators: %s: Number of years */
    652654            array( YEAR_IN_SECONDS,   _n_noop( '%s year',   '%s years',   'bbpress' ) ),
     655            /* translators: %s: Number of months */
    653656            array( MONTH_IN_SECONDS,  _n_noop( '%s month',  '%s months',  'bbpress' ) ),
     657            /* translators: %s: Number of weeks */
    654658            array( WEEK_IN_SECONDS,   _n_noop( '%s week',   '%s weeks',   'bbpress' ) ),
     659            /* translators: %s: Number of days */
    655660            array( DAY_IN_SECONDS,    _n_noop( '%s day',    '%s days',    'bbpress' ) ),
     661            /* translators: %s: Number of hours */
    656662            array( HOUR_IN_SECONDS,   _n_noop( '%s hour',   '%s hours',   'bbpress' ) ),
     663            /* translators: %s: Number of minutes */
    657664            array( MINUTE_IN_SECONDS, _n_noop( '%s minute', '%s minutes', 'bbpress' ) ),
     665            /* translators: %s: Number of seconds */
    658666            array( 1,                 _n_noop( '%s second', '%s seconds', 'bbpress' ) ),
    659667        );
  • trunk/src/includes/common/functions.php

    r7357 r7360  
    386386
    387387    // Defaults
    388     $topic_count     = $topic_count_hidden    = 0;
    389     $reply_count     = $reply_count_hidden    = 0;
    390     $topic_tag_count = $empty_topic_tag_count = 0;
    391     $hidden_topic_title = $hidden_reply_title = '';
     388    $topic_count        = $topic_count_hidden    = 0;
     389    $reply_count        = $reply_count_hidden    = 0;
     390    $topic_tag_count    = $empty_topic_tag_count = 0;
     391    $hidden_topic_title = $hidden_reply_title    = '';
    392392
    393393    // Post statuses
     
    440440        if ( ! empty( $r['count_pending_topics'] ) && ! empty( $caps['edit_others_topics'] ) ) {
    441441            $topics[ $pending ]       = bbp_number_not_negative( $all_topics->{$pending} );
     442            /* translators: %s: Number of pending topics */
    442443            $topic_titles[ $pending ] = sprintf( esc_html__( 'Pending: %s', 'bbpress' ), bbp_number_format_i18n( $topics[ $pending ] ) );
    443444        }
     
    446447        if ( ! empty( $r['count_private_topics'] ) && ! empty( $caps['read_private_topics'] ) ) {
    447448            $topics[ $private ]       = bbp_number_not_negative( $all_topics->{$private} );
     449            /* translators: %s: Number of private topics */
    448450            $topic_titles[ $private ] = sprintf( esc_html__( 'Private: %s', 'bbpress' ), bbp_number_format_i18n( $topics[ $private ] ) );
    449451        }
     
    452454        if ( ! empty( $r['count_hidden_topics'] ) && ! empty( $caps['read_hidden_topics'] ) ) {
    453455            $topics[ $hidden ]       = bbp_number_not_negative( $all_topics->{$hidden} );
     456            /* translators: %s: Number of hidden topics */
    454457            $topic_titles[ $hidden ] = sprintf( esc_html__( 'Hidden: %s', 'bbpress' ), bbp_number_format_i18n( $topics[ $hidden ] ) );
    455458        }
     
    458461        if ( ! empty( $r['count_spam_topics'] ) && ! empty( $caps['edit_others_topics'] ) ) {
    459462            $topics[ $spam ]       = bbp_number_not_negative( $all_topics->{$spam} );
     463            /* translators: %s: Number of spam topics */
    460464            $topic_titles[ $spam ] = sprintf( esc_html__( 'Spammed: %s', 'bbpress' ), bbp_number_format_i18n( $topics[ $spam ] ) );
    461465        }
     
    464468        if ( ! empty( $r['count_trash_topics'] ) && ! empty( $caps['view_trash'] ) ) {
    465469            $topics[ $trash ]       = bbp_number_not_negative( $all_topics->{$trash} );
     470            /* translators: %s: Number of trashed topics */
    466471            $topic_titles[ $trash ] = sprintf( esc_html__( 'Trashed: %s', 'bbpress' ), bbp_number_format_i18n( $topics[ $trash ] ) );
    467472        }
     
    489494        if ( ! empty( $r['count_pending_replies'] ) && ! empty( $caps['edit_others_replies'] ) ) {
    490495            $replies[ $pending ]      = bbp_number_not_negative( $all_replies->{$pending} );
     496            /* translators: %s: Number of pending replies */
    491497            $reply_titles[ $pending ] = sprintf( esc_html__( 'Pending: %s', 'bbpress' ), bbp_number_format_i18n( $replies[ $pending ] ) );
    492498        }
     
    495501        if ( ! empty( $r['count_private_replies'] ) && ! empty( $caps['read_private_replies'] ) ) {
    496502            $replies[ $private ]      = bbp_number_not_negative( $all_replies->{$private} );
     503            /* translators: %s: Number of private replies */
    497504            $reply_titles[ $private ] = sprintf( esc_html__( 'Private: %s', 'bbpress' ), bbp_number_format_i18n( $replies[ $private ] ) );
    498505        }
     
    501508        if ( ! empty( $r['count_hidden_replies'] ) && ! empty( $caps['read_hidden_replies'] ) ) {
    502509            $replies[ $hidden ]      = bbp_number_not_negative( $all_replies->{$hidden} );
     510            /* translators: %s: Number of hidden replies */
    503511            $reply_titles[ $hidden ] = sprintf( esc_html__( 'Hidden: %s', 'bbpress' ), bbp_number_format_i18n( $replies[ $hidden ] ) );
    504512        }
     
    507515        if ( ! empty( $r['count_spam_replies'] ) && ! empty( $caps['edit_others_replies'] ) ) {
    508516            $replies[ $spam ]      = bbp_number_not_negative( $all_replies->{$spam} );
     517            /* translators: %s: Number of spam replies */
    509518            $reply_titles[ $spam ] = sprintf( esc_html__( 'Spammed: %s', 'bbpress' ), bbp_number_format_i18n( $replies[ $spam ] ) );
    510519        }
     
    513522        if ( ! empty( $r['count_trash_replies'] ) && ! empty( $caps['view_trash'] ) ) {
    514523            $replies[ $trash ]      = bbp_number_not_negative( $all_replies->{$trash} );
     524            /* translators: %s: Number of trashed replies */
    515525            $reply_titles[ $trash ] = sprintf( esc_html__( 'Trashed: %s', 'bbpress' ), bbp_number_format_i18n( $replies[ $trash ] ) );
    516526        }
     
    742752
    743753            // Get the meta SQL
    744             $clauses = get_meta_sql( 
    745                 array( 
     754            $clauses = get_meta_sql(
     755                array(
    746756                    array(
    747757                        'key'   => '_bbp_anonymous_email',
    748758                        'value' => $email,
    749                     ) 
    750                 ), 
    751                 'post', 
    752                 $bbp_db->posts, 
    753                 'ID' 
     759                    )
     760                ),
     761                'post',
     762                $bbp_db->posts,
     763                'ID'
    754764            );
    755765
     
    11541164
    11551165    // For plugins to filter messages per reply/topic/user
     1166    /* translators: 1: Reply author name, 2: Reply content, 3: Reply URL */
    11561167    $message = sprintf( esc_html__( '%1$s wrote:
    11571168
     
    13211332
    13221333    // For plugins to filter messages per reply/topic/user
     1334    /* translators: 1: Topic author name, 2: Topic content, 3: Topic URL */
    13231335    $message = sprintf( esc_html__( '%1$s wrote:
    13241336
     
    23942406
    23952407                            // Restrict to specific forum ID
    2396                             $meta_query = array( 
     2408                            $meta_query = array(
    23972409                                array(
    23982410                                    'key'     => '_bbp_forum_id',
     
    24002412                                    'type'    => 'NUMERIC',
    24012413                                    'compare' => '='
    2402                                 ) 
     2414                                )
    24032415                            );
    24042416                        }
  • trunk/src/includes/common/template.php

    r7352 r7360  
    22
    33/**
    4  * bbPress Common Template Tags
     4 * bbPress Common Template Tags.
    55 *
    66 * Common template tags are ones that are used by more than one component, like
    77 * forums, topics, replies, users, topic tags, etc...
    8  *
    9  * @package bbPress
    10  * @subpackage TemplateTags
    118 */
    129
     
    1714
    1815/**
    19  * Output the forum URL
     16 * Output the forum URL.
    2017 *
    2118 * @since 2.1.0 bbPress (r3979)
     
    2623    echo esc_url( bbp_get_forums_url( $path ) );
    2724}
    28     /**
    29      * Return the forum URL
    30      *
    31      * @since 2.1.0 bbPress (r3979)
    32      *
    33      * @param string $path Additional path with leading slash
    34      */
    35     function bbp_get_forums_url( $path = '/' ) {
    36         return home_url( bbp_get_root_slug() . $path );
    37     }
    38 
    39 /**
    40  * Output the forum URL
     25
     26/**
     27 * Return the forum URL.
     28 *
     29 * @since 2.1.0 bbPress (r3979)
     30 *
     31 * @param string $path Additional path with leading slash
     32 */
     33function bbp_get_forums_url( $path = '/' ) {
     34    return home_url( bbp_get_root_slug() . $path );
     35}
     36
     37/**
     38 * Output the forum URL.
    4139 *
    4240 * @since 2.1.0 bbPress (r3979)
     
    4745    echo esc_url( bbp_get_topics_url( $path ) );
    4846}
    49     /**
    50      * Return the forum URL
    51      *
    52      * @since 2.1.0 bbPress (r3979)
    53      *
    54      * @param string $path Additional path with leading slash
    55      * @return The URL to the topics archive
    56      */
    57     function bbp_get_topics_url( $path = '/' ) {
    58         return home_url( bbp_get_topic_archive_slug() . $path );
    59     }
     47
     48/**
     49 * Return the forum URL.
     50 *
     51 * @since 2.1.0 bbPress (r3979)
     52 *
     53 * @param string $path Additional path with leading slash
     54 *
     55 * @return The URL to the topics archive
     56 */
     57function bbp_get_topics_url( $path = '/' ) {
     58    return home_url( bbp_get_topic_archive_slug() . $path );
     59}
    6060
    6161/** Add-on Actions ************************************************************/
    6262
    6363/**
    64  * Add our custom head action to wp_head
     64 * Add our custom head action to wp_head.
    6565 *
    6666 * @since 2.0.0 bbPress (r2464)
     
    7171
    7272/**
    73  * Add our custom footer action to wp_footer
     73 * Add our custom footer action to wp_footer.
    7474 *
    7575 * @since 2.0.0 bbPress (r2464)
     
    8282
    8383/**
    84  * Check if current site is public
     84 * Check if current site is public.
    8585 *
    8686 * @since 2.0.0 bbPress (r3398)
    8787 *
    8888 * @param int $site_id
     89 *
    8990 * @return bool True if site is public, false if private
    9091 */
     
    106107
    107108/**
    108  * Check if current page is a bbPress forum
     109 * Check if current page is a bbPress forum.
    109110 *
    110111 * @since 2.0.0 bbPress (r2549)
    111112 *
    112113 * @param int $post_id Possible post_id to check
     114 *
    113115 * @return bool True if it's a forum page, false if not
    114116 */
     
    152154
    153155/**
    154  * Viewing a single forum
     156 * Viewing a single forum.
    155157 *
    156158 * @since 2.0.0 bbPress (r3338)
     
    178180
    179181/**
    180  * Check if current page is a forum edit page
     182 * Check if current page is a forum edit page.
    181183 *
    182184 * @since 2.1.0 bbPress (r3553)
     
    209211
    210212/**
    211  * Check if current page is a bbPress topic
     213 * Check if current page is a bbPress topic.
    212214 *
    213215 * @since 2.0.0 bbPress (r2549)
    214216 *
    215217 * @param int $post_id Possible post_id to check
     218 *
    216219 * @return bool True if it's a topic page, false if not
    217220 */
     
    231234
    232235/**
    233  * Viewing a single topic
     236 * Viewing a single topic.
    234237 *
    235238 * @since 2.0.0 bbPress (r3338)
     
    278281
    279282/**
    280  * Check if current page is a topic edit page
     283 * Check if current page is a topic edit page.
    281284 *
    282285 * @since 2.0.0 bbPress (r2753)
     
    309312
    310313/**
    311  * Check if current page is a topic merge page
     314 * Check if current page is a topic merge page.
    312315 *
    313316 * @since 2.0.0 bbPress (r2756)
     
    330333
    331334/**
    332  * Check if current page is a topic split page
     335 * Check if current page is a topic split page.
    333336 *
    334337 * @since 2.0.0 bbPress (r2756)
     
    351354
    352355/**
    353  * Check if the current page is a topic tag
     356 * Check if the current page is a topic tag.
    354357 *
    355358 * @since 2.0.0 bbPress (r3311)
     
    382385
    383386/**
    384  * Check if the current page is editing a topic tag
     387 * Check if the current page is editing a topic tag.
    385388 *
    386389 * @since 2.0.0 bbPress (r3346)
     
    419422
    420423/**
    421  * Check if the current post type is one that comes with bbPress
     424 * Check if the current post type is one that comes with bbPress.
    422425 *
    423426 * @since 2.0.0 bbPress (r3311)
     
    433436
    434437    // Viewing one of the bbPress post types
    435     if ( in_array( get_post_type( $the_post ), array(
     438    if ( in_array(get_post_type( $the_post ), array(
    436439        bbp_get_forum_post_type(),
    437440        bbp_get_topic_post_type(),
    438         bbp_get_reply_post_type()
     441        bbp_get_reply_post_type(),
    439442    ), true ) ) {
    440443        $retval = true;
     
    446449
    447450/**
    448  * Check if current page is a bbPress reply
     451 * Check if current page is a bbPress reply.
    449452 *
    450453 * @since 2.0.0 bbPress (r2549)
    451454 *
    452455 * @param int $post_id Possible post_id to check
     456 *
    453457 * @return bool True if it's a reply page, false if not
    454458 */
     
    468472
    469473/**
    470  * Check if current page is a reply edit page
     474 * Check if current page is a reply edit page.
    471475 *
    472476 * @since 2.0.0 bbPress (r2753)
     
    499503
    500504/**
    501  * Check if current page is a reply move page
     505 * Check if current page is a reply move page.
    502506 *
    503507 * @return bool True if it's the reply move page, false if not
     
    518522
    519523/**
    520  * Viewing a single reply
     524 * Viewing a single reply.
    521525 *
    522526 * @since 2.0.0 bbPress (r3344)
     
    535539
    536540    // Single and a match
    537     if ( is_singular( bbp_get_reply_post_type() ) || ( bbp_is_query_name( 'bbp_single_reply' ) ) ) {
     541    if ( is_singular( bbp_get_reply_post_type() ) || bbp_is_query_name( 'bbp_single_reply' ) ) {
    538542        $retval = true;
    539543    }
     
    544548
    545549/**
    546  * Check if current page is a bbPress user's favorites page (profile page)
     550 * Check if current page is a bbPress user's favorites page (profile page ).
    547551 *
    548552 * @since 2.0.0 bbPress (r2652)
     
    568572
    569573/**
    570  * Check if current page is a bbPress user's subscriptions page (profile page)
     574 * Check if current page is a bbPress user's subscriptions page (profile page ).
    571575 *
    572576 * @since 2.0.0 bbPress (r2652)
     
    593597/**
    594598 * Check if current page shows the topics created by a bbPress user (profile
    595  * page)
     599 * page ).
    596600 *
    597601 * @since 2.0.0 bbPress (r2688)
     
    618622/**
    619623 * Check if current page shows the replies created by a bbPress user (profile
    620  * page)
     624 * page ).
    621625 *
    622626 * @since 2.2.0 bbPress (r4225)
     
    642646
    643647/**
    644  * Check if current page is the currently logged in users author page
     648 * Check if current page is the currently logged in users author page.
    645649 *
    646650 * @since 2.0.0 bbPress (r2688)
     
    666670
    667671/**
    668  * Check if current page is the currently logged in users author edit page
     672 * Check if current page is the currently logged in users author edit page.
    669673 *
    670674 * @since 2.1.0 bbPress (r3918)
     
    686690
    687691/**
    688  * Check if current page is a user profile page
     692 * Check if current page is a user profile page.
    689693 *
    690694 * @since 2.0.0 bbPress (r2688)
     
    710714
    711715/**
    712  * Check if current page is a user profile edit page
     716 * Check if current page is a user profile edit page.
    713717 *
    714718 * @since 2.0.0 bbPress (r2688)
     
    734738
    735739/**
    736  * Check if current page is a user profile page
     740 * Check if current page is a user profile page.
    737741 *
    738742 * @since 2.2.0 bbPress (r4225)
     
    758762
    759763/**
    760  * Check if current page is a user topics created page
     764 * Check if current page is a user topics created page.
    761765 *
    762766 * @since 2.2.0 bbPress (r4225)
     
    782786
    783787/**
    784  * Check if current page is a user replies created page
     788 * Check if current page is a user replies created page.
    785789 *
    786790 * @since 2.2.0 bbPress (r4225)
     
    806810
    807811/**
    808  * Check if current page is a user engagements page
     812 * Check if current page is a user engagements page.
    809813 *
    810814 * @since 2.6.0 bbPress (r6320)
     
    830834
    831835/**
    832  * Check if current page is a view page
     836 * Check if current page is a view page.
    833837 *
    834838 * @since 2.0.0 bbPress (r2789)
    835839 *
    836840 * @global WP_Query $wp_query To check if WP_Query::bbp_is_view is true
     841 *
    837842 * @return bool Is it a view page?
    838843 */
     
    860865
    861866/**
    862  * Check if current page is a search page
     867 * Check if current page is a search page.
    863868 *
    864869 * @since 2.3.0 bbPress (r4579)
    865870 *
    866871 * @global WP_Query $wp_query To check if WP_Query::bbp_is_search is true
     872 *
    867873 * @return bool Is it a search page?
    868874 */
     
    880886    $wp_query = bbp_get_wp_query();
    881887
    882     // Get the rewrite ID (one time, to avoid repeated calls)
     888    // Get the rewrite ID (one time, to avoid repeated calls )
    883889    $rewrite_id = bbp_get_search_rewrite_id();
    884890
     
    903909
    904910/**
    905  * Check if current page is a search results page
     911 * Check if current page is a search results page.
    906912 *
    907913 * @since 2.4.0 bbPress (r4919)
    908914 *
    909915 * @global WP_Query $wp_query To check if WP_Query::bbp_is_search is true
     916 *
    910917 * @return bool Is it a search page?
    911918 */
     
    943950
    944951/**
    945  * Check if current page is an edit page
     952 * Check if current page is an edit page.
    946953 *
    947954 * @since 2.1.0 bbPress (r3585)
     
    967974
    968975/**
    969  * Use the above is_() functions to output a body class for each scenario
     976 * Use the above is_() functions to output a body class for each scenario.
    970977 *
    971978 * @since 2.0.0 bbPress (r2926)
     
    973980 * @param array $wp_classes
    974981 * @param array $custom_classes
     982 *
    975983 * @return array Body Classes
    976984 */
     
    980988    $bbp_classes = array();
    981989
    982     /** Archives **************************************************************/
     990    /* Archives ***************************************************************/
    983991
    984992    if ( bbp_is_forum_archive() ) {
    985993        $bbp_classes[] = bbp_get_forum_post_type() . '-archive';
    986 
    987994    } elseif ( bbp_is_topic_archive() ) {
    988995        $bbp_classes[] = bbp_get_topic_post_type() . '-archive';
    989996
    990     /** Topic Tags ************************************************************/
    991 
     997    /* Topic Tags *************************************************************/
    992998    } elseif ( bbp_is_topic_tag() ) {
    993999        $bbp_classes[] = bbp_get_topic_tag_tax_id();
     
    9971003        $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-edit';
    9981004        $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-' . bbp_get_topic_tag_slug() . '-edit';
    999         $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-' . bbp_get_topic_tag_id()   . '-edit';
    1000 
    1001     /** Components ************************************************************/
    1002 
     1005        $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-' . bbp_get_topic_tag_id() . '-edit';
     1006
     1007    /* Components *************************************************************/
    10031008    } elseif ( bbp_is_single_forum() ) {
    10041009        $bbp_classes[] = bbp_get_forum_post_type();
    1005 
    10061010    } elseif ( bbp_is_single_topic() ) {
    10071011        $bbp_classes[] = bbp_get_topic_post_type();
    1008 
    10091012    } elseif ( bbp_is_single_reply() ) {
    10101013        $bbp_classes[] = bbp_get_reply_post_type();
    1011 
    10121014    } elseif ( bbp_is_topic_edit() ) {
    10131015        $bbp_classes[] = bbp_get_topic_post_type() . '-edit';
    1014 
    10151016    } elseif ( bbp_is_topic_merge() ) {
    10161017        $bbp_classes[] = bbp_get_topic_post_type() . '-merge';
    1017 
    10181018    } elseif ( bbp_is_topic_split() ) {
    10191019        $bbp_classes[] = bbp_get_topic_post_type() . '-split';
    1020 
    10211020    } elseif ( bbp_is_reply_edit() ) {
    10221021        $bbp_classes[] = bbp_get_reply_post_type() . '-edit';
    1023 
    10241022    } elseif ( bbp_is_reply_move() ) {
    10251023        $bbp_classes[] = bbp_get_reply_post_type() . '-move';
    1026 
    10271024    } elseif ( bbp_is_single_view() ) {
    10281025        $bbp_classes[] = 'bbp-view';
    10291026        $bbp_classes[] = 'bbp-view-' . bbp_get_view_id();
    10301027
    1031     /** User ******************************************************************/
    1032 
     1028    /* User *******************************************************************/
    10331029    } elseif ( bbp_is_single_user_edit() ) {
    10341030        $bbp_classes[] = 'bbp-user-edit';
    10351031        $bbp_classes[] = 'single';
    10361032        $bbp_classes[] = 'singular';
    1037 
    10381033    } elseif ( bbp_is_single_user() ) {
    10391034        $bbp_classes[] = 'bbp-user-page';
    10401035        $bbp_classes[] = 'single';
    10411036        $bbp_classes[] = 'singular';
    1042 
    10431037    } elseif ( bbp_is_user_home() ) {
    10441038        $bbp_classes[] = 'bbp-user-home';
    10451039        $bbp_classes[] = 'single';
    10461040        $bbp_classes[] = 'singular';
    1047 
    10481041    } elseif ( bbp_is_user_home_edit() ) {
    10491042        $bbp_classes[] = 'bbp-user-home-edit';
    10501043        $bbp_classes[] = 'single';
    10511044        $bbp_classes[] = 'singular';
    1052 
    10531045    } elseif ( bbp_is_topics_created() ) {
    10541046        $bbp_classes[] = 'bbp-topics-created';
    10551047        $bbp_classes[] = 'single';
    10561048        $bbp_classes[] = 'singular';
    1057 
    10581049    } elseif ( bbp_is_replies_created() ) {
    10591050        $bbp_classes[] = 'bbp-replies-created';
    10601051        $bbp_classes[] = 'single';
    10611052        $bbp_classes[] = 'singular';
    1062 
    10631053    } elseif ( bbp_is_favorites() ) {
    10641054        $bbp_classes[] = 'bbp-favorites';
    10651055        $bbp_classes[] = 'single';
    10661056        $bbp_classes[] = 'singular';
    1067 
    10681057    } elseif ( bbp_is_subscriptions() ) {
    10691058        $bbp_classes[] = 'bbp-subscriptions';
     
    10711060        $bbp_classes[] = 'singular';
    10721061
    1073     /** Search ****************************************************************/
    1074 
     1062    /* Search *****************************************************************/
    10751063    } elseif ( bbp_is_search() ) {
    10761064        $bbp_classes[] = 'bbp-search';
    10771065        $bbp_classes[] = 'forum-search';
    1078 
    10791066    } elseif ( bbp_is_search_results() ) {
    10801067        $bbp_classes[] = 'bbp-search-results';
    10811068        $bbp_classes[] = 'forum-search-results';
    10821069
    1083     /** Shortcodes ************************************************************/
    1084 
     1070    /* Shortcodes *************************************************************/
    10851071    } elseif ( bbp_has_shortcode() ) {
    10861072        $bbp_classes[] = 'bbp-shortcode';
    10871073    }
    10881074
    1089     /** General ***************************************************************/
     1075    /* General ****************************************************************/
    10901076
    10911077    // Any page with bbPress content
     
    10981084
    10991085    // Merge WP classes with bbPress classes and remove any duplicates
    1100     $classes = array_unique( array_merge( (array) $bbp_classes, (array) $wp_classes ) );
    1101 
    1102     // Deprecated filter (do not use)
     1086    $classes = array_unique(array_merge( (array) $bbp_classes, (array) $wp_classes ) );
     1087
     1088    // Deprecated filter (do not use )
    11031089    $classes = apply_filters( 'bbp_get_the_body_class', $classes, $bbp_classes, $wp_classes, $custom_classes );
    11041090
     
    11241110    $done = true;
    11251111
    1126 ?>
     1112    ?>
    11271113
    11281114<script type="text/javascript" id="bbp-swap-no-js-body-class">
     
    11461132 *
    11471133 * @param string $text
     1134 *
    11481135 * @return bool
    11491136 */
     
    11811168
    11821169/**
    1183  * Use the above is_() functions to return if in any bbPress page
     1170 * Use the above is_() functions to return if in any bbPress page.
    11841171 *
    11851172 * @since 2.0.0 bbPress (r3344)
     
    11941181    // Bail if main query has not been populated.
    11951182    if ( ! bbp_get_wp_query() ) {
    1196         _doing_it_wrong( __FUNCTION__, esc_html__( 'Conditional query tags do not work before the query is run. Before then, they always return false.', 'bbpress' ), '2.7.0' );
     1183        _doing_it_wrong(__FUNCTION__, esc_html__( 'Conditional query tags do not work before the query is run. Before then, they always return false.', 'bbpress' ), '2.7.0' );
     1184
    11971185        return $retval;
    11981186    }
    11991187
    1200     /** Archives **************************************************************/
     1188    /* Archives ***************************************************************/
    12011189
    12021190    if ( bbp_is_forum_archive() ) {
    12031191        $retval = true;
    1204 
    12051192    } elseif ( bbp_is_topic_archive() ) {
    12061193        $retval = true;
    12071194
    1208     /** Topic Tags ************************************************************/
    1209 
     1195    /* Topic Tags *************************************************************/
    12101196    } elseif ( bbp_is_topic_tag() ) {
    12111197        $retval = true;
    1212 
    12131198    } elseif ( bbp_is_topic_tag_edit() ) {
    12141199        $retval = true;
    12151200
    1216     /** Components ************************************************************/
    1217 
     1201    /* Components *************************************************************/
    12181202    } elseif ( bbp_is_single_forum() ) {
    12191203        $retval = true;
    1220 
    12211204    } elseif ( bbp_is_single_topic() ) {
    12221205        $retval = true;
    1223 
    12241206    } elseif ( bbp_is_single_reply() ) {
    12251207        $retval = true;
    1226 
    12271208    } elseif ( bbp_is_topic_edit() ) {
    12281209        $retval = true;
    1229 
    12301210    } elseif ( bbp_is_topic_merge() ) {
    12311211        $retval = true;
    1232 
    12331212    } elseif ( bbp_is_topic_split() ) {
    12341213        $retval = true;
    1235 
    12361214    } elseif ( bbp_is_reply_edit() ) {
    12371215        $retval = true;
    1238 
    12391216    } elseif ( bbp_is_reply_move() ) {
    12401217        $retval = true;
    1241 
    12421218    } elseif ( bbp_is_single_view() ) {
    12431219        $retval = true;
    12441220
    1245     /** User ******************************************************************/
    1246 
     1221    /* User *******************************************************************/
    12471222    } elseif ( bbp_is_single_user_edit() ) {
    12481223        $retval = true;
    1249 
    12501224    } elseif ( bbp_is_single_user() ) {
    12511225        $retval = true;
    1252 
    12531226    } elseif ( bbp_is_user_home() ) {
    12541227        $retval = true;
    1255 
    12561228    } elseif ( bbp_is_user_home_edit() ) {
    12571229        $retval = true;
    1258 
    12591230    } elseif ( bbp_is_topics_created() ) {
    12601231        $retval = true;
    1261 
    12621232    } elseif ( bbp_is_replies_created() ) {
    12631233        $retval = true;
    1264 
    12651234    } elseif ( bbp_is_favorites() ) {
    12661235        $retval = true;
    1267 
    12681236    } elseif ( bbp_is_subscriptions() ) {
    12691237        $retval = true;
    12701238
    1271     /** Search ****************************************************************/
    1272 
     1239    /* Search *****************************************************************/
    12731240    } elseif ( bbp_is_search() ) {
    12741241        $retval = true;
    1275 
    12761242    } elseif ( bbp_is_search_results() ) {
    12771243        $retval = true;
    12781244
    1279     /** Shortcodes ************************************************************/
    1280 
     1245    /* Shortcodes *************************************************************/
    12811246    } elseif ( bbp_has_shortcode() ) {
    12821247        $retval = true;
    12831248    }
    12841249
    1285     /** Done ******************************************************************/
     1250    /* Done *******************************************************************/
    12861251
    12871252    // Filter & return
     
    12921257
    12931258/**
    1294  * Output the login form action url
     1259 * Output the login form action url.
    12951260 *
    12961261 * @since 2.0.0 bbPress (r2815)
    12971262 *
    12981263 * @param array $args This function supports these arguments:
    1299  *  - action: The action being taken
    1300  *  - context: The context the action is being taken from
     1264 *                    - action: The action being taken
     1265 *                    - context: The context the action is being taken from
    13011266 */
    13021267function bbp_wp_login_action( $args = array() ) {
     
    13041269}
    13051270
    1306     /**
    1307      * Return the login form action url
    1308     *
    1309     * @since 2.6.0 bbPress (r5684)
    1310     *
    1311     * @param array $args This function supports these arguments:
    1312      *  - action: The action being taken
    1313      *  - context: The context the action is being taken from
    1314     */
    1315     function bbp_get_wp_login_action( $args = array() ) {
    1316 
    1317         // Parse arguments against default values
    1318         $r = bbp_parse_args( $args, array(
    1319             'action'  => '',
    1320             'context' => '',
    1321             'url'     => 'wp-login.php'
    1322         ), 'login_action' );
    1323 
    1324         // Add action as query arg
    1325         $login_url = ! empty( $r['action'] )
    1326             ? add_query_arg( array( 'action' => $r['action'] ), $r['url'] )
    1327             : $r['url'];
    1328 
    1329         $login_url = site_url( $login_url, $r['context'] );
    1330 
    1331         // Filter & return
    1332         return apply_filters( 'bbp_get_wp_login_action', $login_url, $r, $args );
    1333     }
     1271/**
     1272 * Return the login form action url.
     1273 *
     1274 * @since 2.6.0 bbPress (r5684)
     1275 *
     1276 * @param array $args This function supports these arguments:
     1277 *                    - action: The action being taken
     1278 *                    - context: The context the action is being taken from
     1279 */
     1280function bbp_get_wp_login_action( $args = array() ) {
     1281
     1282    // Parse arguments against default values
     1283    $r = bbp_parse_args( $args, array(
     1284        'action'  => '',
     1285        'context' => '',
     1286        'url'     => 'wp-login.php',
     1287    ), 'login_action' );
     1288
     1289    // Add action as query arg
     1290    $login_url = ! empty( $r['action'] )
     1291        ? add_query_arg(array( 'action' => $r['action'] ), $r['url'] )
     1292        : $r['url'];
     1293
     1294    $login_url = site_url( $login_url, $r['context'] );
     1295
     1296    // Filter & return
     1297    return apply_filters( 'bbp_get_wp_login_action', $login_url, $r, $args );
     1298}
    13341299
    13351300/**
     
    13701335 * @since 2.0.0 bbPress (r2815)
    13711336 *
    1372  * @param string $request Name of $_REQUEST to look for
     1337 * @param string $request    Name of $_REQUEST to look for
    13731338 * @param string $input_type Type of input. Default: text. Accepts:
    1374  *                            textarea|password|select|radio|checkbox
     1339 *                           textarea|password|select|radio|checkbox
    13751340 */
    13761341function bbp_sanitize_val( $request = '', $input_type = 'text' ) {
    13771342    echo bbp_get_sanitize_val( $request, $input_type );
    13781343}
    1379     /**
    1380      * Return sanitized $_REQUEST value.
    1381      *
    1382      * Use the $input_type parameter to properly process the value. This
    1383      * ensures correct sanitization of the value for the receiving input.
    1384      *
    1385      * @since 2.0.0 bbPress (r2815)
    1386      *
    1387      * @param string $request Name of $_REQUEST to look for
    1388      * @param string $input_type Type of input. Default: text. Accepts:
    1389      *                            textarea|password|select|radio|checkbox
    1390      *
    1391      * @return string Sanitized value ready for screen display
    1392      */
    1393     function bbp_get_sanitize_val( $request = '', $input_type = 'text' ) {
    1394 
    1395         // Check that requested
    1396         if ( empty( $_REQUEST[ $request ] ) ) {
    1397             return false;
    1398         }
    1399 
    1400         // Set request varaible
    1401         $pre_ret_val = $_REQUEST[ $request ];
    1402 
    1403         // Treat different kinds of fields in different ways
    1404         switch ( $input_type ) {
    1405             case 'text'     :
    1406             case 'textarea' :
    1407                 $retval = esc_attr( wp_unslash( $pre_ret_val ) );
    1408                 break;
    1409 
    1410             case 'password' :
    1411             case 'select'   :
    1412             case 'radio'    :
    1413             case 'checkbox' :
    1414             default :
    1415                 $retval = esc_attr( $pre_ret_val );
    1416                 break;
    1417         }
    1418 
    1419         // Filter & return
    1420         return apply_filters( 'bbp_get_sanitize_val', $retval, $request, $input_type );
    1421     }
    1422 
    1423 /**
    1424  * Output the current tab index of a given form
     1344
     1345/**
     1346 * Return sanitized $_REQUEST value.
     1347 *
     1348 * Use the $input_type parameter to properly process the value. This
     1349 * ensures correct sanitization of the value for the receiving input.
     1350 *
     1351 * @since 2.0.0 bbPress (r2815)
     1352 *
     1353 * @param string $request    Name of $_REQUEST to look for
     1354 * @param string $input_type Type of input. Default: text. Accepts:
     1355 *                           textarea|password|select|radio|checkbox
     1356 *
     1357 * @return string Sanitized value ready for screen display
     1358 */
     1359function bbp_get_sanitize_val( $request = '', $input_type = 'text' ) {
     1360
     1361    // Check that requested
     1362    if ( empty( $_REQUEST[ $request ] ) ) {
     1363        return false;
     1364    }
     1365
     1366    // Set request varaible
     1367    $pre_ret_val = $_REQUEST[ $request ];
     1368
     1369    // Treat different kinds of fields in different ways
     1370    switch ( $input_type ) {
     1371        case 'text':
     1372        case 'textarea':
     1373            $retval = esc_attr(wp_unslash( $pre_ret_val ) );
     1374            break;
     1375
     1376        case 'password':
     1377        case 'select':
     1378        case 'radio':
     1379        case 'checkbox':
     1380        default:
     1381            $retval = esc_attr( $pre_ret_val );
     1382            break;
     1383    }
     1384
     1385    // Filter & return
     1386    return apply_filters( 'bbp_get_sanitize_val', $retval, $request, $input_type );
     1387}
     1388
     1389/**
     1390 * Output the current tab index of a given form.
    14251391 *
    14261392 * Use this function to handle the tab indexing of user facing forms within a
     
    14291395 *
    14301396 * @since 2.0.0 bbPress (r2810)
    1431  *
    14321397 * @deprecated 2.6.0 bbPress (r5561)
    1433  *
    1434  * @link https://bbpress.trac.wordpress.org/attachment/ticket/2714 Trac Ticket
     1398 * @see https://bbpress.trac.wordpress.org/attachment/ticket/2714 Trac Ticket
     1399 *
    14351400 * @param int $auto_increment Optional. Default true. Set to false to prevent
    1436  *                             increment
     1401 *                            increment
    14371402 */
    14381403function bbp_tab_index( $auto_increment = true ) {
     
    14401405}
    14411406
    1442     /**
    1443      * Return the current tab index of a given form
    1444     *
    1445     * Use this function to handle the tab indexing of user facing forms
    1446     * within a template file. Calling this function will automatically
    1447     * increment the global tab index by default.
    1448     *
    1449     * @since 2.0.0 bbPress (r2810)
    1450      *
    1451      * @deprecated 2.6.0 bbPress (r5561)
    1452     *
    1453      * @link https://bbpress.trac.wordpress.org/attachment/ticket/2714 Trac Ticket
    1454      * @param int $auto_increment Optional. Default true. Set to false to
    1455      *                             prevent the increment
    1456     * @return int $bbp->tab_index The global tab index
    1457     */
    1458     function bbp_get_tab_index( $auto_increment = true ) {
    1459         $bbp = bbpress();
    1460 
    1461         if ( true === $auto_increment ) {
    1462             ++$bbp->tab_index;
    1463         }
    1464 
    1465         // Filter & return
    1466         return apply_filters( 'bbp_get_tab_index', (int) $bbp->tab_index );
    1467     }
     1407/**
     1408 * Return the current tab index of a given form.
     1409 *
     1410 * Use this function to handle the tab indexing of user facing forms
     1411 * within a template file. Calling this function will automatically
     1412 * increment the global tab index by default.
     1413 *
     1414 * @since 2.0.0 bbPress (r2810)
     1415 * @deprecated 2.6.0 bbPress (r5561)
     1416 * @see https://bbpress.trac.wordpress.org/attachment/ticket/2714 Trac Ticket
     1417 *
     1418 * @param int $auto_increment Optional. Default true. Set to false to
     1419 *                            prevent the increment
     1420 *
     1421 * @return int $bbp->tab_index The global tab index
     1422 */
     1423function bbp_get_tab_index( $auto_increment = true ) {
     1424    $bbp = bbpress();
     1425
     1426    if ( true === $auto_increment ) {
     1427        ++$bbp->tab_index;
     1428    }
     1429
     1430    // Filter & return
     1431    return apply_filters( 'bbp_get_tab_index', (int) $bbp->tab_index );
     1432}
    14681433
    14691434/**
     
    14831448}
    14841449
    1485     /**
    1486     * Return a "tabindex" attribute for an element, if an index was passed.
    1487     *
    1488     * This helper function is in use, but it is generally considered impolite to
    1489     * override the "tabindex" attribute beyond what the browser naturally assigns.
    1490     *
    1491     * Most internal usages pass `false` which results in no attribute being used.
    1492     *
    1493     * @since 2.6.0 bbPress (r6424)
    1494     *
    1495     * @param mixed $tab False to skip, any integer to use
    1496     *
    1497     * @return string
    1498     */
    1499     function bbp_get_tab_index_attribute( $tab = false ) {
    1500 
    1501         // Get attribute
    1502         $attr = is_numeric( $tab )
    1503             ? ' tabindex="' . (int) $tab . '"'
    1504             : '';
    1505 
    1506         // Filter & return
    1507         return apply_filters( 'bbp_get_tab_index_attribute', $attr, $tab );
    1508     }
     1450/**
     1451 * Return a "tabindex" attribute for an element, if an index was passed.
     1452 *
     1453 * This helper function is in use, but it is generally considered impolite to
     1454 * override the "tabindex" attribute beyond what the browser naturally assigns.
     1455 *
     1456 * Most internal usages pass `false` which results in no attribute being used.
     1457 *
     1458 * @since 2.6.0 bbPress (r6424)
     1459 *
     1460 * @param mixed $tab False to skip, any integer to use
     1461 *
     1462 * @return string
     1463 */
     1464function bbp_get_tab_index_attribute( $tab = false ) {
     1465
     1466    // Get attribute
     1467    $attr = is_numeric( $tab )
     1468        ? ' tabindex="' . (int) $tab . '"'
     1469        : '';
     1470
     1471    // Filter & return
     1472    return apply_filters( 'bbp_get_tab_index_attribute', $attr, $tab );
     1473}
    15091474
    15101475/**
     
    15211486    echo bbp_get_dropdown( $args );
    15221487}
    1523     /**
    1524      * Return a select box allowing to pick which forum/topic a new
    1525      * topic/reply belongs in.
     1488/**
     1489 * Return a select box allowing to pick which forum/topic a new
     1490 * topic/reply belongs in.
     1491 *
     1492 * @since 2.0.0 bbPress (r2746)
     1493 *
     1494 * @param array $args The function supports these args:
     1495 *                    - post_type: Post type, defaults to bbp_get_forum_post_type() ( bbp_forum)
     1496 *                    - selected: Selected ID, to not have any value as selected, pass
     1497 *                    anything smaller than 0 (due to the nature of select
     1498 *                    box, the first value would of course be selected -
     1499 *                    though you can have that as none (pass 'show_none' arg) )
     1500 *                    - orderby: Defaults to 'menu_order title'
     1501 *                    - post_parent: Post parent. Defaults to 0
     1502 *                    - post_status: Which all post_statuses to find in? Can be an array
     1503 *                    or CSV of publish, category, closed, private, spam,
     1504 *                    trash (based on post type ) - if not set, these are
     1505 *                    automatically determined based on the post_type
     1506 *                    - posts_per_page: Retrieve all forums/topics. Defaults to -1 to get
     1507 *                    all posts
     1508 *                    - walker: Which walker to use? Defaults to
     1509 *                    {@link BBP_Walker_Dropdown}
     1510 *                    - select_id: ID of the select box. Defaults to 'bbp_forum_id'
     1511 *                    - tab: Deprecated. Tabindex value. False or integer
     1512 *                    - options_only: Show only <options>? No <select>?
     1513 *                    - show_none: Boolean or String __( '&mdash; No Forum &mdash;', 'bbpress' )
     1514 *                    - disable_categories: Disable forum categories and closed forums?
     1515 *                    Defaults to true. Only for forums and when
     1516 *
     1517 * @return string The dropdown
     1518 */
     1519function bbp_get_dropdown( $args = array() ) {
     1520
     1521    // Setup return value
     1522    $retval = '';
     1523
     1524    /** Arguments *************************************************************/
     1525
     1526    // Parse arguments against default values
     1527    $r = bbp_parse_args( $args, array(
     1528        // Support for get_posts()
     1529        'post_type'   => bbp_get_forum_post_type(),
     1530        'post_parent' => null,
     1531        'post_status' => null,
     1532        'selected'    => 0,
     1533        'include'     => array(),
     1534        'exclude'     => array(),
     1535        'numberposts' => -1,
     1536        'orderby'     => 'menu_order title',
     1537        'order'       => 'ASC',
     1538
     1539        // Preloaded content
     1540        'posts' => array(),
     1541
     1542        // Custom hierarchy walkers
     1543        'walker' => '',
     1544
     1545        // Output-related
     1546        'select_id'          => 'bbp_forum_id',
     1547        'select_class'       => 'bbp_dropdown',
     1548        'tab'                => false,
     1549        'options_only'       => false,
     1550        'show_none'          => false,
     1551        'disable_categories' => true,
     1552        'disabled'           => '',
     1553    ), 'get_dropdown' );
     1554
     1555    // Fallback to our walker
     1556    if ( empty( $r['walker'] ) ) {
     1557        $r['walker'] = new BBP_Walker_Dropdown();
     1558        $r['walker']->tree_type = $r['post_type'];
     1559    }
     1560
     1561    // Force 0
     1562    if ( is_numeric( $r['selected'] ) && ( $r['selected'] < 0 ) ) {
     1563        $r['selected'] = 0;
     1564    }
     1565
     1566    // Force array
     1567    if ( ! empty( $r['include'] ) && ! is_array( $r['include'] ) ) {
     1568        $r['include'] = explode( ',', $r['include'] );
     1569    }
     1570
     1571    // Force array
     1572    if ( ! empty( $r['exclude'] ) && ! is_array( $r['exclude'] ) ) {
     1573        $r['exclude'] = explode( ',', $r['exclude'] );
     1574    }
     1575
     1576    /* Setup Posts ************************************************************/
     1577
     1578    /*
     1579     * Allow passing of custom posts data
    15261580     *
    1527      * @since 2.0.0 bbPress (r2746)
    1528      *
    1529      * @param array $args The function supports these args:
    1530      *  - post_type: Post type, defaults to bbp_get_forum_post_type() (bbp_forum)
    1531      *  - selected: Selected ID, to not have any value as selected, pass
    1532      *               anything smaller than 0 (due to the nature of select
    1533      *               box, the first value would of course be selected -
    1534      *               though you can have that as none (pass 'show_none' arg))
    1535      *  - orderby: Defaults to 'menu_order title'
    1536      *  - post_parent: Post parent. Defaults to 0
    1537      *  - post_status: Which all post_statuses to find in? Can be an array
    1538      *                  or CSV of publish, category, closed, private, spam,
    1539      *                  trash (based on post type) - if not set, these are
    1540      *                  automatically determined based on the post_type
    1541      *  - posts_per_page: Retrieve all forums/topics. Defaults to -1 to get
    1542      *                     all posts
    1543      *  - walker: Which walker to use? Defaults to
    1544      *             {@link BBP_Walker_Dropdown}
    1545      *  - select_id: ID of the select box. Defaults to 'bbp_forum_id'
    1546      *  - tab: Deprecated. Tabindex value. False or integer
    1547      *  - options_only: Show only <options>? No <select>?
    1548      *  - show_none: Boolean or String __( '&mdash; No Forum &mdash;', 'bbpress' )
    1549      *  - disable_categories: Disable forum categories and closed forums?
    1550      *                         Defaults to true. Only for forums and when
    1551      * @return string The dropdown
     1581     * @see bbp_get_reply_to_dropdown() as an example
    15521582     */
    1553     function bbp_get_dropdown( $args = array() ) {
    1554 
    1555         // Setup return value
    1556         $retval = '';
    1557 
    1558         /** Arguments *********************************************************/
    1559 
    1560         // Parse arguments against default values
    1561         $r = bbp_parse_args( $args, array(
    1562 
    1563             // Support for get_posts()
    1564             'post_type'          => bbp_get_forum_post_type(),
    1565             'post_parent'        => null,
    1566             'post_status'        => null,
    1567             'selected'           => 0,
    1568             'include'            => array(),
    1569             'exclude'            => array(),
    1570             'numberposts'        => -1,
    1571             'orderby'            => 'menu_order title',
    1572             'order'              => 'ASC',
    1573 
    1574             // Preloaded content
    1575             'posts'              => array(),
    1576 
    1577             // Custom hierarchy walkers
    1578             'walker'             => '',
    1579 
    1580             // Output-related
    1581             'select_id'          => 'bbp_forum_id',
    1582             'select_class'       => 'bbp_dropdown',
    1583             'tab'                => false,
    1584             'options_only'       => false,
    1585             'show_none'          => false,
    1586             'disable_categories' => true,
    1587             'disabled'           => ''
    1588         ), 'get_dropdown' );
    1589 
    1590         // Fallback to our walker
    1591         if ( empty( $r['walker'] ) ) {
    1592             $r['walker']            = new BBP_Walker_Dropdown();
    1593             $r['walker']->tree_type = $r['post_type'];
     1583    if ( empty( $r['posts'] ) ) {
     1584        $r['posts'] = get_posts( array(
     1585            'post_type'   => $r['post_type'],
     1586            'post_status' => $r['post_status'],
     1587            'post_parent' => $r['post_parent'],
     1588            'include'     => $r['include'],
     1589            'exclude'     => $r['exclude'],
     1590            'numberposts' => $r['numberposts'],
     1591            'orderby'     => $r['orderby'],
     1592            'order'       => $r['order'],
     1593        ) );
     1594    }
     1595
     1596    /* Drop Down **************************************************************/
     1597
     1598    // Build the opening tag for the select element
     1599    if ( empty( $r['options_only'] ) ) {
     1600
     1601        // Should this select appear disabled?
     1602        $disabled = disabled( isset( bbpress()->options[ $r['disabled'] ] ), true, false );
     1603
     1604        // Setup the tab index attribute
     1605        $tab = ! empty( $r['tab'] )
     1606            ? ' tabindex="'. intval( $r['tab'] ) . '"'
     1607            : '';
     1608
     1609        // Open the select tag
     1610        $retval .= '<select name="' . esc_attr( $r['select_id'] ) . '" id="' . esc_attr( $r['select_id'] ) . '" class="' . esc_attr( $r['select_class'] ) . '"' . $disabled . $tab . '>' . "\n";
     1611    }
     1612
     1613    // Display a leading 'no-value' option, with or without custom text
     1614    if ( ! empty( $r['show_none'] ) || ! empty( $r['none_found'] ) ) {
     1615
     1616        // Open the 'no-value' option tag
     1617        $retval .= "\t<option value=\"\" class=\"level-0\">";
     1618
     1619        // Use deprecated 'none_found' first for backpat
     1620        if ( ! empty( $r['none_found'] ) && is_string( $r['none_found'] ) ) {
     1621            $retval .= esc_html( $r['none_found'] );
     1622
     1623        // Use 'show_none' second
     1624        } elseif ( ! empty( $r['show_none'] ) && is_string( $r['show_none'] ) ) {
     1625            $retval .= esc_html( $r['show_none'] );
     1626
     1627        // Otherwise, make some educated guesses
     1628        } else {
     1629
     1630            // Switch the response based on post type
     1631            switch ( $r['post_type'] ) {
     1632                // Topics
     1633                case bbp_get_topic_post_type():
     1634                    $retval .= esc_html__( 'No topics available', 'bbpress' );
     1635                    break;
     1636
     1637                // Forums
     1638                case bbp_get_forum_post_type():
     1639                    $retval .= esc_html__( 'No forums available', 'bbpress' );
     1640                    break;
     1641
     1642                // Any other
     1643                default:
     1644                    $retval .= esc_html__( 'None available', 'bbpress' );
     1645                    break;
     1646            }
    15941647        }
    15951648
    1596         // Force 0
    1597         if ( is_numeric( $r['selected'] ) && ( $r['selected'] < 0 ) ) {
    1598             $r['selected'] = 0;
    1599         }
    1600 
    1601         // Force array
    1602         if ( ! empty( $r['include'] ) && ! is_array( $r['include'] ) ) {
    1603             $r['include'] = explode( ',', $r['include'] );
    1604         }
    1605 
    1606         // Force array
    1607         if ( ! empty( $r['exclude'] ) && ! is_array( $r['exclude'] ) ) {
    1608             $r['exclude'] = explode( ',', $r['exclude'] );
    1609         }
    1610 
    1611         /** Setup Posts *******************************************************/
    1612 
    1613         /**
    1614          * Allow passing of custom posts data
    1615          *
    1616          * @see bbp_get_reply_to_dropdown() as an example
    1617          */
    1618         if ( empty( $r['posts'] ) ) {
    1619             $r['posts'] = get_posts( array(
    1620                 'post_type'   => $r['post_type'],
    1621                 'post_status' => $r['post_status'],
    1622                 'post_parent' => $r['post_parent'],
    1623                 'include'     => $r['include'],
    1624                 'exclude'     => $r['exclude'],
    1625                 'numberposts' => $r['numberposts'],
    1626                 'orderby'     => $r['orderby'],
    1627                 'order'       => $r['order'],
    1628             ) );
    1629         }
    1630 
    1631         /** Drop Down *********************************************************/
    1632 
    1633         // Build the opening tag for the select element
    1634         if ( empty( $r['options_only'] ) ) {
    1635 
    1636             // Should this select appear disabled?
    1637             $disabled  = disabled( isset( bbpress()->options[ $r['disabled'] ] ), true, false );
    1638 
    1639             // Setup the tab index attribute
    1640             $tab       = ! empty( $r['tab'] ) ? ' tabindex="' . intval( $r['tab'] ) . '"' : '';
    1641 
    1642             // Open the select tag
    1643             $retval   .= '<select name="' . esc_attr( $r['select_id'] ) . '" id="' . esc_attr( $r['select_id'] ) . '" class="' . esc_attr( $r['select_class'] ) . '"' . $disabled . $tab . '>' . "\n";
    1644         }
    1645 
    1646         // Display a leading 'no-value' option, with or without custom text
    1647         if ( ! empty( $r['show_none'] ) || ! empty( $r['none_found'] ) ) {
    1648 
    1649             // Open the 'no-value' option tag
    1650             $retval .= "\t<option value=\"\" class=\"level-0\">";
    1651 
    1652             // Use deprecated 'none_found' first for backpat
    1653             if ( ! empty( $r['none_found'] ) && is_string( $r['none_found'] ) ) {
    1654                 $retval .= esc_html( $r['none_found'] );
    1655 
    1656             // Use 'show_none' second
    1657             } elseif ( ! empty( $r['show_none'] ) && is_string( $r['show_none'] ) ) {
    1658                 $retval .= esc_html( $r['show_none'] );
    1659 
    1660             // Otherwise, make some educated guesses
    1661             } else {
    1662 
    1663                 // Switch the response based on post type
    1664                 switch ( $r['post_type'] ) {
    1665 
    1666                     // Topics
    1667                     case bbp_get_topic_post_type() :
    1668                         $retval .= esc_html__( 'No topics available', 'bbpress' );
    1669                         break;
    1670 
    1671                     // Forums
    1672                     case bbp_get_forum_post_type() :
    1673                         $retval .= esc_html__( 'No forums available', 'bbpress' );
    1674                         break;
    1675 
    1676                     // Any other
    1677                     default :
    1678                         $retval .= esc_html__( 'None available', 'bbpress' );
    1679                         break;
    1680                 }
    1681             }
    1682 
    1683             // Close the 'no-value' option tag
    1684             $retval .= '</option>';
    1685         }
    1686 
    1687         // Items found so walk the tree
    1688         if ( ! empty( $r['posts'] ) ) {
    1689             $retval .= walk_page_dropdown_tree( $r['posts'], 0, $r );
    1690         }
    1691 
    1692         // Close the selecet tag
    1693         if ( empty( $r['options_only'] ) ) {
    1694             $retval .= '</select>';
    1695         }
    1696 
    1697         // Filter & return
    1698         return apply_filters( 'bbp_get_dropdown', $retval, $r, $args );
    1699     }
    1700 
    1701 /**
    1702  * Output the required hidden fields when creating/editing a forum
     1649        // Close the 'no-value' option tag
     1650        $retval .= '</option>';
     1651    }
     1652
     1653    // Items found so walk the tree
     1654    if ( ! empty( $r['posts'] ) ) {
     1655        $retval .= walk_page_dropdown_tree( $r['posts'], 0, $r );
     1656    }
     1657
     1658    // Close the selecet tag
     1659    if ( empty( $r['options_only'] ) ) {
     1660        $retval .= '</select>';
     1661    }
     1662
     1663    // Filter & return
     1664    return apply_filters( 'bbp_get_dropdown', $retval, $r, $args );
     1665}
     1666
     1667/**
     1668 * Output the required hidden fields when creating/editing a forum.
    17031669 *
    17041670 * @since 2.1.0 bbPress (r3553)
    17051671 */
    17061672function bbp_forum_form_fields() {
    1707 
    1708     if ( bbp_is_forum_edit() ) : ?>
     1673    if ( bbp_is_forum_edit() ) { ?>
    17091674
    17101675        <input type="hidden" name="action"       id="bbp_post_action" value="bbp-edit-forum" />
    17111676        <input type="hidden" name="bbp_forum_id" id="bbp_forum_id"    value="<?php bbp_forum_id(); ?>" />
    17121677
    1713         <?php if ( current_user_can( 'unfiltered_html' ) ) :
     1678        <?php if ( current_user_can( 'unfiltered_html' ) ) {
    17141679            wp_nonce_field( 'bbp-unfiltered-html-forum_' . bbp_get_forum_id(), '_bbp_unfiltered_html_forum', false );
    1715         endif; ?>
     1680        } ?>
    17161681
    17171682        <?php wp_nonce_field( 'bbp-edit-forum_' . bbp_get_forum_id() );
    1718 
    1719     else :
    1720 
    1721         if ( bbp_is_single_forum() ) : ?>
     1683    } else {
     1684        if ( bbp_is_single_forum() ) { ?>
    17221685
    17231686            <input type="hidden" name="bbp_forum_parent_id" id="bbp_forum_parent_id" value="<?php bbp_forum_parent_id(); ?>" />
    17241687
    1725         <?php endif; ?>
     1688        <?php } ?>
    17261689
    17271690        <input type="hidden" name="action" id="bbp_post_action" value="bbp-new-forum" />
    17281691
    1729         <?php if ( current_user_can( 'unfiltered_html' ) ) :
     1692        <?php if ( current_user_can( 'unfiltered_html' ) ) {
    17301693            wp_nonce_field( 'bbp-unfiltered-html-forum_new', '_bbp_unfiltered_html_forum', false );
    1731         endif; ?>
     1694        } ?>
    17321695
    17331696        <?php wp_nonce_field( 'bbp-new-forum' );
    1734 
    1735     endif;
    1736 }
    1737 
    1738 /**
    1739  * Output the required hidden fields when creating/editing a topic
     1697    }
     1698}
     1699
     1700/**
     1701 * Output the required hidden fields when creating/editing a topic.
    17401702 *
    17411703 * @since 2.0.0 bbPress (r2753)
    17421704 */
    17431705function bbp_topic_form_fields() {
    1744 
    1745     if ( bbp_is_topic_edit() ) : ?>
     1706    if ( bbp_is_topic_edit() ) { ?>
    17461707
    17471708        <input type="hidden" name="action"       id="bbp_post_action" value="bbp-edit-topic" />
    17481709        <input type="hidden" name="bbp_topic_id" id="bbp_topic_id"    value="<?php bbp_topic_id(); ?>" />
    17491710
    1750         <?php if ( current_user_can( 'unfiltered_html' ) ) :
     1711        <?php if ( current_user_can( 'unfiltered_html' ) ) {
    17511712            wp_nonce_field( 'bbp-unfiltered-html-topic_' . bbp_get_topic_id(), '_bbp_unfiltered_html_topic', false );
    1752         endif; ?>
     1713        } ?>
    17531714
    17541715        <?php wp_nonce_field( 'bbp-edit-topic_' . bbp_get_topic_id() );
    1755 
    1756     else :
    1757 
    1758         if ( bbp_is_single_forum() ) : ?>
     1716    } else {
     1717        if ( bbp_is_single_forum() ) { ?>
    17591718
    17601719            <input type="hidden" name="bbp_forum_id" id="bbp_forum_id" value="<?php bbp_forum_id(); ?>" />
    17611720
    1762         <?php endif; ?>
     1721        <?php } ?>
    17631722
    17641723        <input type="hidden" name="action" id="bbp_post_action" value="bbp-new-topic" />
    17651724
    1766         <?php if ( current_user_can( 'unfiltered_html' ) ) :
     1725        <?php if ( current_user_can( 'unfiltered_html' ) ) {
    17671726            wp_nonce_field( 'bbp-unfiltered-html-topic_new', '_bbp_unfiltered_html_topic', false );
    1768         endif; ?>
     1727        } ?>
    17691728
    17701729        <?php wp_nonce_field( 'bbp-new-topic' );
    1771 
    1772     endif;
    1773 }
    1774 
    1775 /**
    1776  * Output the required hidden fields when creating/editing a reply
     1730    }
     1731}
     1732
     1733/**
     1734 * Output the required hidden fields when creating/editing a reply.
    17771735 *
    17781736 * @since 2.0.0 bbPress (r2753)
    17791737 */
    17801738function bbp_reply_form_fields() {
    1781 
    1782     if ( bbp_is_reply_edit() ) : ?>
     1739    if ( bbp_is_reply_edit() ) { ?>
    17831740
    17841741        <input type="hidden" name="bbp_reply_id"    id="bbp_reply_id"    value="<?php bbp_reply_id(); ?>" />
    17851742        <input type="hidden" name="action"          id="bbp_post_action" value="bbp-edit-reply" />
    17861743
    1787         <?php if ( current_user_can( 'unfiltered_html' ) ) :
    1788             wp_nonce_field( 'bbp-unfiltered-html-reply_' . bbp_get_reply_id(), '_bbp_unfiltered_html_reply', false );
    1789         endif; ?>
     1744        <?php if ( current_user_can( 'unfiltered_html' ) ) {
     1745            wp_nonce_field( 'bbp-unfiltered-html-reply_' . bbp_get_reply_id(), '_bbp_unfiltered_html_reply', false );
     1746        } ?>
    17901747
    17911748        <?php wp_nonce_field( 'bbp-edit-reply_' . bbp_get_reply_id() );
    1792 
    1793     else : ?>
     1749    } else { ?>
    17941750
    17951751        <input type="hidden" name="bbp_topic_id"    id="bbp_topic_id"    value="<?php bbp_topic_id(); ?>" />
     
    17971753        <input type="hidden" name="action"          id="bbp_post_action" value="bbp-new-reply" />
    17981754
    1799         <?php if ( current_user_can( 'unfiltered_html' ) ) :
    1800             wp_nonce_field( 'bbp-unfiltered-html-reply_' . bbp_get_topic_id(), '_bbp_unfiltered_html_reply', false );
    1801         endif; ?>
     1755        <?php if ( current_user_can( 'unfiltered_html' ) ) {
     1756            wp_nonce_field( 'bbp-unfiltered-html-reply_' . bbp_get_topic_id(), '_bbp_unfiltered_html_reply', false );
     1757        } ?>
    18021758
    18031759        <?php wp_nonce_field( 'bbp-new-reply' );
    18041760
    18051761        // Show redirect field if not viewing a specific topic
    1806         if ( bbp_is_query_name( 'bbp_single_topic' ) ) :
     1762        if ( bbp_is_query_name( 'bbp_single_topic' ) ) {
    18071763            $redirect_to = apply_filters( 'bbp_reply_form_redirect_to', get_permalink() );
    18081764            bbp_redirect_to_field( $redirect_to );
    1809         endif;
    1810     endif;
    1811 }
    1812 
    1813 /**
    1814  * Output the required hidden fields when editing a user
     1765        }
     1766    }
     1767}
     1768
     1769/**
     1770 * Output the required hidden fields when editing a user.
    18151771 *
    18161772 * @since 2.0.0 bbPress (r2690)
     
    18261782
    18271783/**
    1828  * Merge topic form fields
     1784 * Merge topic form fields.
    18291785 *
    18301786 * Output the required hidden fields when merging a topic
     
    18421798
    18431799/**
    1844  * Split topic form fields
     1800 * Split topic form fields.
    18451801 *
    18461802 * Output the required hidden fields when splitting a topic
     
    18581814
    18591815/**
    1860  * Move reply form fields
     1816 * Move reply form fields.
    18611817 *
    18621818 * Output the required hidden fields when moving a reply
     
    18721828
    18731829/**
    1874  * Output a textarea or TinyMCE if enabled
     1830 * Output a textarea or TinyMCE if enabled.
    18751831 *
    18761832 * @since 2.1.0 bbPress (r3586)
     
    18811837    echo bbp_get_the_content( $args );
    18821838}
    1883     /**
    1884      * Return a textarea or TinyMCE if enabled
     1839
     1840/**
     1841 * Return a textarea or TinyMCE if enabled.
     1842 *
     1843 * @since 2.1.0 bbPress (r3586)
     1844 *
     1845 * @param array $args
     1846 *
     1847 * @return string HTML from output buffer
     1848 */
     1849function bbp_get_the_content( $args = array() ) {
     1850
     1851    // Parse arguments against default values
     1852    $r = bbp_parse_args( $args, array(
     1853        'context'           => 'topic',
     1854        'before'            => '<div class="bbp-the-content-wrapper">',
     1855        'after'             => '</div>',
     1856        'wpautop'           => true,
     1857        'media_buttons'     => false,
     1858        'textarea_rows'     => '12',
     1859        'tabindex'          => false,
     1860        'tabfocus_elements' => 'bbp_topic_title,bbp_topic_tags',
     1861        'editor_class'      => 'bbp-the-content',
     1862        'tinymce'           => false,
     1863        'teeny'             => true,
     1864        'quicktags'         => true,
     1865        'dfw'               => false,
     1866    ), 'get_the_content' );
     1867
     1868    // If using tinymce, remove our escaping and trust tinymce
     1869    if ( bbp_use_wp_editor() && ( false !== $r['tinymce'] ) ) {
     1870        remove_filter( 'bbp_get_form_forum_content', 'esc_textarea' );
     1871        remove_filter( 'bbp_get_form_topic_content', 'esc_textarea' );
     1872        remove_filter( 'bbp_get_form_reply_content', 'esc_textarea' );
     1873    }
     1874
     1875    // Assume we are not editing
     1876    $post_content = call_user_func( 'bbp_get_form_' . $r['context']. '_content' );
     1877
     1878    // Start an output buffor
     1879    ob_start();
     1880
     1881    // Output something before the editor
     1882    if ( ! empty( $r['before'] ) ) {
     1883        echo $r['before'];
     1884    }
     1885
     1886    // Use TinyMCE if available
     1887    if ( bbp_use_wp_editor() ) {
     1888
     1889        // Enable additional TinyMCE plugins before outputting the editor
     1890        add_filter( 'tiny_mce_plugins', 'bbp_get_tiny_mce_plugins' );
     1891        add_filter( 'teeny_mce_plugins', 'bbp_get_tiny_mce_plugins' );
     1892        add_filter( 'teeny_mce_buttons', 'bbp_get_teeny_mce_buttons' );
     1893        add_filter( 'quicktags_settings', 'bbp_get_quicktags_settings' );
     1894
     1895        // Output the editor
     1896        wp_editor( $post_content, 'bbp_' . $r['context']. '_content', array(
     1897            'wpautop'           => $r['wpautop'],
     1898            'media_buttons'     => $r['media_buttons'],
     1899            'textarea_rows'     => $r['textarea_rows'],
     1900            'tabindex'          => $r['tabindex'],
     1901            'tabfocus_elements' => $r['tabfocus_elements'],
     1902            'editor_class'      => $r['editor_class'],
     1903            'tinymce'           => $r['tinymce'],
     1904            'teeny'             => $r['teeny'],
     1905            'quicktags'         => $r['quicktags'],
     1906            'dfw'               => $r['dfw'],
     1907        ) );
     1908
     1909        // Remove additional TinyMCE plugins after outputting the editor
     1910        remove_filter( 'tiny_mce_plugins', 'bbp_get_tiny_mce_plugins' );
     1911        remove_filter( 'teeny_mce_plugins', 'bbp_get_tiny_mce_plugins' );
     1912        remove_filter( 'teeny_mce_buttons', 'bbp_get_teeny_mce_buttons' );
     1913        remove_filter( 'quicktags_settings', 'bbp_get_quicktags_settings' );
     1914
     1915    /*
     1916     * Fallback to normal textarea.
    18851917     *
    1886      * @since 2.1.0 bbPress (r3586)
    1887      *
    1888      * @param array $args
    1889      *
    1890      * @return string HTML from output buffer
     1918     * Note that we do not use esc_textarea() here to prevent double
     1919     * escaping the editable output, mucking up existing content.
    18911920     */
    1892     function bbp_get_the_content( $args = array() ) {
    1893 
    1894         // Parse arguments against default values
    1895         $r = bbp_parse_args( $args, array(
    1896             'context'           => 'topic',
    1897             'before'            => '<div class="bbp-the-content-wrapper">',
    1898             'after'             => '</div>',
    1899             'wpautop'           => true,
    1900             'media_buttons'     => false,
    1901             'textarea_rows'     => '12',
    1902             'tabindex'          => false,
    1903             'tabfocus_elements' => 'bbp_topic_title,bbp_topic_tags',
    1904             'editor_class'      => 'bbp-the-content',
    1905             'tinymce'           => false,
    1906             'teeny'             => true,
    1907             'quicktags'         => true,
    1908             'dfw'               => false
    1909         ), 'get_the_content' );
    1910 
    1911         // If using tinymce, remove our escaping and trust tinymce
    1912         if ( bbp_use_wp_editor() && ( false !== $r['tinymce'] ) ) {
    1913             remove_filter( 'bbp_get_form_forum_content', 'esc_textarea' );
    1914             remove_filter( 'bbp_get_form_topic_content', 'esc_textarea' );
    1915             remove_filter( 'bbp_get_form_reply_content', 'esc_textarea' );
    1916         }
    1917 
    1918         // Assume we are not editing
    1919         $post_content = call_user_func( 'bbp_get_form_' . $r['context'] . '_content' );
    1920 
    1921         // Start an output buffor
    1922         ob_start();
    1923 
    1924         // Output something before the editor
    1925         if ( ! empty( $r['before'] ) ) {
    1926             echo $r['before'];
    1927         }
    1928 
    1929         // Use TinyMCE if available
    1930         if ( bbp_use_wp_editor() ) :
    1931 
    1932             // Enable additional TinyMCE plugins before outputting the editor
    1933             add_filter( 'tiny_mce_plugins',   'bbp_get_tiny_mce_plugins'   );
    1934             add_filter( 'teeny_mce_plugins',  'bbp_get_tiny_mce_plugins'   );
    1935             add_filter( 'teeny_mce_buttons',  'bbp_get_teeny_mce_buttons'  );
    1936             add_filter( 'quicktags_settings', 'bbp_get_quicktags_settings' );
    1937 
    1938             // Output the editor
    1939             wp_editor( $post_content, 'bbp_' . $r['context'] . '_content', array(
    1940                 'wpautop'           => $r['wpautop'],
    1941                 'media_buttons'     => $r['media_buttons'],
    1942                 'textarea_rows'     => $r['textarea_rows'],
    1943                 'tabindex'          => $r['tabindex'],
    1944                 'tabfocus_elements' => $r['tabfocus_elements'],
    1945                 'editor_class'      => $r['editor_class'],
    1946                 'tinymce'           => $r['tinymce'],
    1947                 'teeny'             => $r['teeny'],
    1948                 'quicktags'         => $r['quicktags'],
    1949                 'dfw'               => $r['dfw'],
    1950             ) );
    1951 
    1952             // Remove additional TinyMCE plugins after outputting the editor
    1953             remove_filter( 'tiny_mce_plugins',   'bbp_get_tiny_mce_plugins'   );
    1954             remove_filter( 'teeny_mce_plugins',  'bbp_get_tiny_mce_plugins'   );
    1955             remove_filter( 'teeny_mce_buttons',  'bbp_get_teeny_mce_buttons'  );
    1956             remove_filter( 'quicktags_settings', 'bbp_get_quicktags_settings' );
    1957 
    1958         /**
    1959          * Fallback to normal textarea.
    1960          *
    1961          * Note that we do not use esc_textarea() here to prevent double
    1962          * escaping the editable output, mucking up existing content.
    1963          */
    1964         else : ?>
    1965 
    1966             <textarea id="bbp_<?php echo esc_attr( $r['context'] ); ?>_content" class="<?php echo esc_attr( $r['editor_class'] ); ?>" name="bbp_<?php echo esc_attr( $r['context'] ); ?>_content" cols="60" rows="<?php echo esc_attr( $r['textarea_rows'] ); ?>" <?php bbp_tab_index_attribute( $r['tabindex'] ); ?>><?php echo $post_content; ?></textarea>
    1967 
    1968         <?php endif;
    1969 
    1970         // Output something after the editor
    1971         if ( ! empty( $r['after'] ) ) {
    1972             echo $r['after'];
    1973         }
    1974 
    1975         // Put the output into a usable variable
    1976         $output = ob_get_clean();
    1977 
    1978         // Filter & return
    1979         return apply_filters( 'bbp_get_the_content', $output, $args, $post_content );
    1980     }
    1981 
    1982 /**
    1983  * Edit TinyMCE plugins to match core behaviour
     1921    } else { ?>
     1922
     1923        <textarea id="bbp_<?php echo esc_attr( $r['context'] ); ?>_content" class="<?php echo esc_attr( $r['editor_class'] ); ?>" name="bbp_<?php echo esc_attr( $r['context'] ); ?>_content" cols="60" rows="<?php echo esc_attr( $r['textarea_rows'] ); ?>" <?php bbp_tab_index_attribute( $r['tabindex'] ); ?>><?php echo $post_content; ?></textarea>
     1924
     1925    <?php }
     1926
     1927    // Output something after the editor
     1928    if ( ! empty( $r['after'] ) ) {
     1929        echo $r['after'];
     1930    }
     1931
     1932    // Put the output into a usable variable
     1933    $output = ob_get_clean();
     1934
     1935    // Filter & return
     1936    return apply_filters( 'bbp_get_the_content', $output, $args, $post_content );
     1937}
     1938
     1939/**
     1940 * Edit TinyMCE plugins to match core behaviour.
    19841941 *
    19851942 * @since 2.3.0 bbPress (r4574)
    19861943 *
    19871944 * @param array $plugins
     1945 *
    19881946 * @see tiny_mce_plugins, teeny_mce_plugins
     1947 *
    19891948 * @return array
    19901949 */
     
    20071966
    20081967/**
    2009  * Edit TeenyMCE buttons to match allowedtags
     1968 * Edit TeenyMCE buttons to match allowedtags.
    20101969 *
    20111970 * @since 2.3.0 bbPress (r4605)
    20121971 *
    20131972 * @param array $buttons
     1973 *
    20141974 * @see teeny_mce_buttons
     1975 *
    20151976 * @return array
    20161977 */
     
    20221983        'justifyleft',
    20231984        'justifycenter',
    2024         'justifyright'
     1985        'justifyright',
    20251986    ) );
    20261987
     
    20331994
    20341995/**
    2035  * Edit TinyMCE quicktags buttons to match allowedtags
     1996 * Edit TinyMCE quicktags buttons to match allowedtags.
    20361997 *
    20371998 * @since 2.3.0 bbPress (r4606)
    20381999 *
    20392000 * @param array $settings
     2001 *
    20402002 * @see quicktags_settings
     2003 *
    20412004 * @return array Quicktags settings
    20422005 */
     
    20502013        'ins',
    20512014        'more',
    2052         'spell'
     2015        'spell',
    20532016    ) );
    20542017
     
    20632026
    20642027/**
    2065  * Output the view id
     2028 * Output the view id.
    20662029 *
    20672030 * @since 2.0.0 bbPress (r2789)
     
    20732036}
    20742037
    2075     /**
    2076      * Get the view id
    2077      *
    2078      * Use view id if supplied, otherwise bbp_get_view_rewrite_id() query var.
    2079      *
    2080      * @since 2.0.0 bbPress (r2789)
    2081      *
    2082      * @param string $view Optional. View id.
    2083      * @return bool|string ID on success, false on failure
    2084      */
    2085     function bbp_get_view_id( $view = '' ) {
    2086         $bbp = bbpress();
    2087 
    2088         // User supplied string
    2089         if ( ! empty( $view ) && is_string( $view ) ) {
    2090             $view_id = $view;
    2091 
    2092         // Current view ID
    2093         } elseif ( ! empty( $bbp->current_view_id ) ) {
    2094             $view_id = $bbp->current_view_id;
    2095 
    2096         // Querying for view
    2097         } else {
    2098             $view_id = get_query_var( bbp_get_view_rewrite_id() );
    2099         }
    2100 
    2101         // Filter & return
    2102         return apply_filters( 'bbp_get_view_id', $view_id, $view );
    2103     }
    2104 
    2105 /**
    2106  * Output the view name aka title
     2038/**
     2039 * Get the view id.
     2040 *
     2041 * Use view id if supplied, otherwise bbp_get_view_rewrite_id() query var.
     2042 *
     2043 * @since 2.0.0 bbPress (r2789)
     2044 *
     2045 * @param string $view Optional. View id.
     2046 *
     2047 * @return bool|string ID on success, false on failure
     2048 */
     2049function bbp_get_view_id( $view = '' ) {
     2050    $bbp = bbpress();
     2051
     2052    // User supplied string
     2053    if ( ! empty( $view ) && is_string( $view ) ) {
     2054        $view_id = $view;
     2055
     2056    // Current view ID
     2057    } elseif ( ! empty( $bbp->current_view_id ) ) {
     2058        $view_id = $bbp->current_view_id;
     2059
     2060    // Querying for view
     2061    } else {
     2062        $view_id = get_query_var( bbp_get_view_rewrite_id() );
     2063    }
     2064
     2065    // Filter & return
     2066    return apply_filters( 'bbp_get_view_id', $view_id, $view );
     2067}
     2068
     2069/**
     2070 * Output the view name aka title.
    21072071 *
    21082072 * @since 2.0.0 bbPress (r2789)
     
    21142078}
    21152079
    2116     /**
    2117      * Get the view name aka title
    2118      *
    2119      * If a view id is supplied, that is used. Otherwise the bbp_view
    2120      * query var is checked for.
    2121      *
    2122      * @since 2.0.0 bbPress (r2789)
    2123      *
    2124      * @param string $view Optional. View id
    2125      * @return bool|string Title on success, false on failure
    2126      */
    2127     function bbp_get_view_title( $view = '' ) {
    2128         $bbp = bbpress();
    2129 
    2130         $view = bbp_get_view_id( $view );
    2131         if ( empty( $view ) ) {
    2132             return false;
    2133         }
    2134 
    2135         return $bbp->views[ $view ]['title'];
    2136     }
    2137 
    2138 /**
    2139  * Output the view url
     2080/**
     2081 * Get the view name aka title.
     2082 *
     2083 * If a view id is supplied, that is used. Otherwise the bbp_view
     2084 * query var is checked for.
     2085 *
     2086 * @since 2.0.0 bbPress (r2789)
     2087 *
     2088 * @param string $view Optional. View id
     2089 *
     2090 * @return bool|string Title on success, false on failure
     2091 */
     2092function bbp_get_view_title( $view = '' ) {
     2093    $bbp = bbpress();
     2094
     2095    $view = bbp_get_view_id( $view );
     2096    if ( empty( $view ) ) {
     2097        return false;
     2098    }
     2099
     2100    return $bbp->views[ $view ]['title'];
     2101}
     2102
     2103/**
     2104 * Output the view url.
    21402105 *
    21412106 * @since 2.0.0 bbPress (r2789)
     
    21462111    echo esc_url( bbp_get_view_url( $view ) );
    21472112}
    2148     /**
    2149      * Return the view url
    2150     *
    2151     * @since 2.0.0 bbPress (r2789)
    2152     *
    2153     * @param string $view Optional. View id
    2154      *                        used view id
    2155      * @return string View url (or home url if the view was not found)
    2156      */
    2157     function bbp_get_view_url( $view = false ) {
    2158 
    2159         $view = bbp_get_view_id( $view );
    2160         if ( empty( $view ) ) {
    2161             return home_url();
    2162         }
    2163 
    2164         // Pretty permalinks
    2165         if ( bbp_use_pretty_urls() ) {
    2166 
    2167             // Run through home_url()
    2168             $url = trailingslashit( bbp_get_root_url() . bbp_get_view_slug() ) . $view;
    2169             $url = user_trailingslashit( $url );
    2170             $url = home_url( $url );
    2171 
    2172         // Unpretty permalinks
    2173         } else {
    2174             $url = add_query_arg( array(
    2175                 bbp_get_view_rewrite_id() => $view
    2176             ), home_url( '/' ) );
    2177         }
    2178 
    2179         // Filter & return
    2180         return apply_filters( 'bbp_get_view_link', $url, $view );
    2181     }
     2113/**
     2114 * Return the view url.
     2115 *
     2116 * @since 2.0.0 bbPress (r2789)
     2117 *
     2118 * @param string $view Optional. View id
     2119 *                     used view id
     2120 *
     2121 * @return string View url (or home url if the view was not found )
     2122 */
     2123function bbp_get_view_url( $view = false ) {
     2124
     2125    $view = bbp_get_view_id( $view );
     2126    if ( empty( $view ) ) {
     2127        return home_url();
     2128    }
     2129
     2130    // Pretty permalinks
     2131    if ( bbp_use_pretty_urls() ) {
     2132        // Run through home_url()
     2133        $url = trailingslashit( bbp_get_root_url() . bbp_get_view_slug() ) . $view;
     2134        $url = user_trailingslashit( $url );
     2135        $url = home_url( $url );
     2136
     2137    // Unpretty permalinks
     2138    } else {
     2139        $url = add_query_arg( array(
     2140            bbp_get_view_rewrite_id() => $view,
     2141        ), home_url( '/' ) );
     2142    }
     2143
     2144    // Filter & return
     2145    return apply_filters( 'bbp_get_view_link', $url, $view );
     2146}
    21822147
    21832148/** Query *********************************************************************/
    21842149
    21852150/**
    2186  * Check the passed parameter against the current _bbp_query_name
     2151 * Check the passed parameter against the current _bbp_query_name.
    21872152 *
    21882153 * @since 2.0.0 bbPress (r2980)
     
    21952160
    21962161/**
    2197  * Get the '_bbp_query_name' setting
     2162 * Get the '_bbp_query_name' setting.
    21982163 *
    21992164 * @since 2.0.0 bbPress (r2695)
     
    22062171
    22072172/**
    2208  * Set the '_bbp_query_name' setting to $name
     2173 * Set the '_bbp_query_name' setting to $name.
    22092174 *
    22102175 * @since 2.0.0 bbPress (r2692)
     
    22172182
    22182183/**
    2219  * Used to clear the '_bbp_query_name' setting
     2184 * Used to clear the '_bbp_query_name' setting.
    22202185 *
    22212186 * @since 2.0.0 bbPress (r2692)
    2222  *
    22232187 */
    22242188function bbp_reset_query_name() {
     
    22292193
    22302194/**
    2231  * Output the page title as a breadcrumb
     2195 * Output the page title as a breadcrumb.
     2196 *
     2197 * @since 2.0.0 bbPress (r2589)
     2198 */
     2199function bbp_title_breadcrumb( $args = array() ) {
     2200    echo bbp_get_breadcrumb( $args );
     2201}
     2202
     2203/**
     2204 * Output a breadcrumb.
     2205 *
     2206 * @since 2.0.0 bbPress (r2589)
     2207 */
     2208function bbp_breadcrumb( $args = array() ) {
     2209    echo bbp_get_breadcrumb( $args );
     2210}
     2211
     2212/**
     2213 * Return a breadcrumb ( forum -> topic -> reply )
    22322214 *
    22332215 * @since 2.0.0 bbPress (r2589)
     
    22362218 * @param bool $current_page Include the current item
    22372219 * @param bool $root Include the root page if one exists
    2238  */
    2239 function bbp_title_breadcrumb( $args = array() ) {
    2240     echo bbp_get_breadcrumb( $args );
    2241 }
    2242 
    2243 /**
    2244  * Output a breadcrumb
    2245  *
    2246  * @since 2.0.0 bbPress (r2589)
    2247  *
    2248  * @param string $sep Separator. Defaults to '&larr;'
    2249  * @param bool $current_page Include the current item
    2250  * @param bool $root Include the root page if one exists
    2251  */
    2252 function bbp_breadcrumb( $args = array() ) {
    2253     echo bbp_get_breadcrumb( $args );
    2254 }
    2255     /**
    2256      * Return a breadcrumb ( forum -> topic -> reply )
    2257      *
    2258      * @since 2.0.0 bbPress (r2589)
    2259      *
    2260      * @param string $sep Separator. Defaults to '&larr;'
    2261      * @param bool $current_page Include the current item
    2262      * @param bool $root Include the root page if one exists
    2263      *
    2264      * @return string Breadcrumbs
    2265      */
    2266     function bbp_get_breadcrumb( $args = array() ) {
    2267 
    2268         // Turn off breadcrumbs
    2269         if ( apply_filters( 'bbp_no_breadcrumb', is_front_page() ) ) {
    2270             return;
     2220 *
     2221 * @return string Breadcrumbs
     2222 */
     2223function bbp_get_breadcrumb( $args = array() ) {
     2224
     2225    // Turn off breadcrumbs
     2226    if ( apply_filters( 'bbp_no_breadcrumb', is_front_page() ) ) {
     2227        return;
     2228    }
     2229
     2230    // Define variables
     2231    $front_id         = $root_id          = $remove_root_id      = 0;
     2232    $ancestors        = $crumbs           = $tag_data            = array();
     2233    $pre_root_text    = $pre_front_text   = $pre_current_text    = '';
     2234    $pre_include_root = $pre_include_home = $pre_include_current = true;
     2235
     2236    /** Home Text *************************************************************/
     2237
     2238    // No custom home text
     2239    if ( empty( $args['home_text'] ) ) {
     2240
     2241        $front_id = get_option( 'page_on_front' );
     2242
     2243        // Set home text to page title
     2244        if ( ! empty( $front_id ) ) {
     2245            $pre_front_text = get_the_title( $front_id );
     2246
     2247        // Default to 'Home'
     2248        } else {
     2249            $pre_front_text = esc_html__( 'Home', 'bbpress' );
    22712250        }
    2272 
    2273         // Define variables
    2274         $front_id         = $root_id          = $remove_root_id      = 0;
    2275         $ancestors        = $crumbs           = $tag_data            = array();
    2276         $pre_root_text    = $pre_front_text   = $pre_current_text    = '';
    2277         $pre_include_root = $pre_include_home = $pre_include_current = true;
    2278 
    2279         /** Home Text *********************************************************/
    2280 
    2281         // No custom home text
    2282         if ( empty( $args['home_text'] ) ) {
    2283 
    2284             $front_id = get_option( 'page_on_front' );
    2285 
    2286             // Set home text to page title
    2287             if ( ! empty( $front_id ) ) {
    2288                 $pre_front_text = get_the_title( $front_id );
    2289 
    2290             // Default to 'Home'
    2291             } else {
    2292                 $pre_front_text = esc_html__( 'Home', 'bbpress' );
     2251    }
     2252
     2253    /** Root Text *************************************************************/
     2254
     2255    // No custom root text
     2256    if ( empty( $args['root_text'] ) ) {
     2257        $page = bbp_get_page_by_path( bbp_get_root_slug() );
     2258        if ( ! empty( $page ) ) {
     2259            $root_id = $page->ID;
     2260        }
     2261        $pre_root_text = bbp_get_forum_archive_title();
     2262    }
     2263
     2264    /** Includes **************************************************************/
     2265
     2266    // Root slug is also the front page
     2267    if ( ! empty( $front_id ) && ( $front_id === $root_id ) ) {
     2268        $pre_include_root = false;
     2269    }
     2270
     2271    // Don't show root if viewing forum archive
     2272    if ( bbp_is_forum_archive() ) {
     2273        $pre_include_root = false;
     2274    }
     2275
     2276    // Don't show root if viewing page in place of forum archive
     2277    if ( ! empty( $root_id ) && ( ( is_single() || is_page() ) && ( get_the_ID() === $root_id ) ) ) {
     2278        $pre_include_root = false;
     2279    }
     2280
     2281    /** Current Text **********************************************************/
     2282
     2283    // Search page
     2284    if ( bbp_is_search() ) {
     2285        $pre_current_text = bbp_get_search_title();
     2286
     2287    // Forum archive
     2288    } elseif ( bbp_is_forum_archive() ) {
     2289        $pre_current_text = bbp_get_forum_archive_title();
     2290
     2291    // Topic archive
     2292    } elseif ( bbp_is_topic_archive() ) {
     2293        $pre_current_text = bbp_get_topic_archive_title();
     2294
     2295    // View
     2296    } elseif ( bbp_is_single_view() ) {
     2297        $pre_current_text = bbp_get_view_title();
     2298
     2299    // Single Forum
     2300    } elseif ( bbp_is_single_forum() ) {
     2301        $pre_current_text = bbp_get_forum_title();
     2302
     2303    // Single Topic
     2304    } elseif ( bbp_is_single_topic() ) {
     2305        $pre_current_text = bbp_get_topic_title();
     2306
     2307    // Single Topic
     2308    } elseif ( bbp_is_single_reply() ) {
     2309        $pre_current_text = bbp_get_reply_title();
     2310
     2311    // Topic Tag (or theme compat topic tag)
     2312    } elseif ( bbp_is_topic_tag() || ( get_query_var( 'bbp_topic_tag' ) && ! bbp_is_topic_tag_edit() ) ) {
     2313
     2314        // Always include the tag name
     2315        $tag_data[] = bbp_get_topic_tag_name();
     2316
     2317        // If capable, include a link to edit the tag
     2318        if ( current_user_can( 'manage_topic_tags' ) ) {
     2319            $tag_data[] = '<a href="' . esc_url( bbp_get_topic_tag_edit_link() ) . '" class="bbp-edit-topic-tag-link">' . esc_html__( '(Edit)', 'bbpress' ) . '</a>';
     2320        }
     2321
     2322        // Implode the results of the tag data
     2323        /* translators: %s: Topic tag data */
     2324        $pre_current_text = sprintf( esc_html__( 'Topic Tag: %s', 'bbpress' ), implode( ' ', $tag_data ) );
     2325
     2326    // Edit Topic Tag
     2327    } elseif ( bbp_is_topic_tag_edit() ) {
     2328        $pre_current_text = esc_html__( 'Edit', 'bbpress' );
     2329
     2330    // Single
     2331    } else {
     2332        $pre_current_text = get_the_title();
     2333    }
     2334
     2335    /** Parse Args ************************************************************/
     2336
     2337    // Parse args
     2338    $r = bbp_parse_args( $args, array(
     2339
     2340        // HTML
     2341        'before'          => '<div class="bbp-breadcrumb"><p>',
     2342        'after'           => '</p></div>',
     2343
     2344        // Separator
     2345        'sep'             => is_rtl() ? __( '&lsaquo;', 'bbpress' ) : __( '&rsaquo;', 'bbpress' ),
     2346        'pad_sep'         => 1,
     2347        'sep_before'      => '<span class="bbp-breadcrumb-sep">',
     2348        'sep_after'       => '</span>',
     2349
     2350        // Crumbs
     2351        'crumb_before'    => '',
     2352        'crumb_after'     => '',
     2353
     2354        // Home
     2355        'include_home'    => $pre_include_home,
     2356        'home_text'       => $pre_front_text,
     2357
     2358        // Forum root
     2359        'include_root'    => $pre_include_root,
     2360        'root_text'       => $pre_root_text,
     2361
     2362        // Current
     2363        'include_current' => $pre_include_current,
     2364        'current_text'    => $pre_current_text,
     2365        'current_before'  => '<span class="bbp-breadcrumb-current">',
     2366        'current_after'   => '</span>',
     2367    ), 'get_breadcrumb' );
     2368
     2369    /** Ancestors *********************************************************/
     2370
     2371    // Get post ancestors
     2372    if ( is_singular() || bbp_is_forum_edit() || bbp_is_topic_edit() || bbp_is_reply_edit() ) {
     2373        $ancestors = array_reverse( (array) get_post_ancestors( get_the_ID() ) );
     2374    }
     2375
     2376    // Do we want to include a link to home?
     2377    if ( ! empty( $r['include_home'] ) || empty( $r['home_text'] ) ) {
     2378        $crumbs[] = '<a href="' . esc_url( home_url() ) . '" class="bbp-breadcrumb-home">' . $r['home_text'] . '</a>';
     2379    }
     2380
     2381    // Do we want to include a link to the forum root?
     2382    if ( ! empty( $r['include_root'] ) || empty( $r['root_text'] ) ) {
     2383
     2384        // Page exists at root slug path, so use its permalink
     2385        $page = bbp_get_page_by_path( bbp_get_root_slug() );
     2386        if ( ! empty( $page ) ) {
     2387            $root_url       = get_permalink( $page->ID );
     2388            $remove_root_id = $page->ID;
     2389
     2390        // Use the root slug
     2391        } else {
     2392            $root_url = get_post_type_archive_link( bbp_get_forum_post_type() );
     2393        }
     2394
     2395        // Add the breadcrumb
     2396        $crumbs[] = '<a href="' . esc_url( $root_url ) . '" class="bbp-breadcrumb-root">' . $r['root_text'] . '</a>';
     2397    }
     2398
     2399    // Ancestors exist
     2400    if ( ! empty( $ancestors ) ) {
     2401
     2402        // Loop through parents
     2403        foreach ( (array) $ancestors as $parent_id ) {
     2404
     2405            // Parents
     2406            $parent = get_post( $parent_id );
     2407
     2408            // Skip parent if empty or error
     2409            if ( empty( $parent ) || is_wp_error( $parent ) ) {
     2410                continue;
     2411            }
     2412
     2413            // Skip to prevent duplicate root on subpages
     2414            if ( ! empty( $remove_root_id ) && ( $parent->ID === $remove_root_id ) ) {
     2415                continue;
     2416            }
     2417
     2418            // Switch through post_type to ensure correct filters are applied
     2419            switch ( $parent->post_type ) {
     2420
     2421                // Forum
     2422                case bbp_get_forum_post_type() :
     2423                    $crumbs[] = '<a href="' . esc_url( bbp_get_forum_permalink( $parent->ID ) ) . '" class="bbp-breadcrumb-forum">' . bbp_get_forum_title( $parent->ID ) . '</a>';
     2424                    break;
     2425
     2426                // Topic
     2427                case bbp_get_topic_post_type() :
     2428                    $crumbs[] = '<a href="' . esc_url( bbp_get_topic_permalink( $parent->ID ) ) . '" class="bbp-breadcrumb-topic">' . bbp_get_topic_title( $parent->ID ) . '</a>';
     2429                    break;
     2430
     2431                // Reply (Note: not in most themes )
     2432                case bbp_get_reply_post_type() :
     2433                    $crumbs[] = '<a href="' . esc_url( bbp_get_reply_permalink( $parent->ID ) ) . '" class="bbp-breadcrumb-reply">' . bbp_get_reply_title( $parent->ID ) . '</a>';
     2434                    break;
     2435
     2436                // WordPress Post/Page/Other
     2437                default :
     2438                    $crumbs[] = '<a href="' . esc_url( get_permalink( $parent->ID ) ) . '" class="bbp-breadcrumb-item">' . get_the_title( $parent->ID ) . '</a>';
     2439                    break;
    22932440            }
    22942441        }
    22952442
    2296         /** Root Text *********************************************************/
    2297 
    2298         // No custom root text
    2299         if ( empty( $args['root_text'] ) ) {
    2300             $page = bbp_get_page_by_path( bbp_get_root_slug() );
    2301             if ( ! empty( $page ) ) {
    2302                 $root_id = $page->ID;
    2303             }
    2304             $pre_root_text = bbp_get_forum_archive_title();
     2443    // Edit topic tag
     2444    } elseif ( bbp_is_topic_tag_edit() ) {
     2445        /* translators: %s: Topic Tag name */
     2446        $crumbs[] = '<a href="' . esc_url( get_term_link( bbp_get_topic_tag_id(), bbp_get_topic_tag_tax_id() ) ) . '" class="bbp-breadcrumb-topic-tag">' . sprintf( esc_html__( 'Topic Tag: %s', 'bbpress' ), bbp_get_topic_tag_name() ) . '</a>';
     2447
     2448    // Search
     2449    } elseif ( bbp_is_search() && bbp_get_search_terms() ) {
     2450        $crumbs[] = '<a href="' . esc_url( bbp_get_search_url() ) . '" class="bbp-breadcrumb-search">' . esc_html__( 'Search', 'bbpress' ) . '</a>';
     2451    }
     2452
     2453    /** Current ***********************************************************/
     2454
     2455    // Add current page to breadcrumb
     2456    if ( ! empty( $r['include_current'] ) || empty( $r['current_text'] ) ) {
     2457        $crumbs[] = $r['current_before'] . $r['current_text'] . $r['current_after'];
     2458    }
     2459
     2460    /** Separator *********************************************************/
     2461
     2462    // Wrap the separator in before/after before padding and filter
     2463    if ( ! empty( $r['sep'] ) ) {
     2464        $sep = $r['sep_before'] . $r['sep'] . $r['sep_after'];
     2465    } else {
     2466        $sep = '';
     2467    }
     2468
     2469    // Pad the separator
     2470    if ( ! empty( $r['pad_sep'] ) ) {
     2471        if ( function_exists( 'mb_strlen' ) ) {
     2472            $sep = str_pad( $sep, mb_strlen( $sep ) + ( (int) $r['pad_sep'] * 2 ), ' ', STR_PAD_BOTH );
     2473        } else {
     2474            $sep = str_pad( $sep, strlen( $sep ) + ( (int) $r['pad_sep'] * 2 ), ' ', STR_PAD_BOTH );
    23052475        }
    2306 
    2307         /** Includes **********************************************************/
    2308 
    2309         // Root slug is also the front page
    2310         if ( ! empty( $front_id ) && ( $front_id === $root_id ) ) {
    2311             $pre_include_root = false;
    2312         }
    2313 
    2314         // Don't show root if viewing forum archive
    2315         if ( bbp_is_forum_archive() ) {
    2316             $pre_include_root = false;
    2317         }
    2318 
    2319         // Don't show root if viewing page in place of forum archive
    2320         if ( ! empty( $root_id ) && ( ( is_single() || is_page() ) && ( get_the_ID() === $root_id ) ) ) {
    2321             $pre_include_root = false;
    2322         }
    2323 
    2324         /** Current Text ******************************************************/
    2325 
    2326         // Search page
    2327         if ( bbp_is_search() ) {
    2328             $pre_current_text = bbp_get_search_title();
    2329 
    2330         // Forum archive
    2331         } elseif ( bbp_is_forum_archive() ) {
    2332             $pre_current_text = bbp_get_forum_archive_title();
    2333 
    2334         // Topic archive
    2335         } elseif ( bbp_is_topic_archive() ) {
    2336             $pre_current_text = bbp_get_topic_archive_title();
    2337 
    2338         // View
    2339         } elseif ( bbp_is_single_view() ) {
    2340             $pre_current_text = bbp_get_view_title();
    2341 
    2342         // Single Forum
    2343         } elseif ( bbp_is_single_forum() ) {
    2344             $pre_current_text = bbp_get_forum_title();
    2345 
    2346         // Single Topic
    2347         } elseif ( bbp_is_single_topic() ) {
    2348             $pre_current_text = bbp_get_topic_title();
    2349 
    2350         // Single Topic
    2351         } elseif ( bbp_is_single_reply() ) {
    2352             $pre_current_text = bbp_get_reply_title();
    2353 
    2354         // Topic Tag (or theme compat topic tag)
    2355         } elseif ( bbp_is_topic_tag() || ( get_query_var( 'bbp_topic_tag' ) && ! bbp_is_topic_tag_edit() ) ) {
    2356 
    2357             // Always include the tag name
    2358             $tag_data[] = bbp_get_topic_tag_name();
    2359 
    2360             // If capable, include a link to edit the tag
    2361             if ( current_user_can( 'manage_topic_tags' ) ) {
    2362                 $tag_data[] = '<a href="' . esc_url( bbp_get_topic_tag_edit_link() ) . '" class="bbp-edit-topic-tag-link">' . esc_html__( '(Edit)', 'bbpress' ) . '</a>';
    2363             }
    2364 
    2365             // Implode the results of the tag data
    2366             $pre_current_text = sprintf( esc_html__( 'Topic Tag: %s', 'bbpress' ), implode( ' ', $tag_data ) );
    2367 
    2368         // Edit Topic Tag
    2369         } elseif ( bbp_is_topic_tag_edit() ) {
    2370             $pre_current_text = esc_html__( 'Edit', 'bbpress' );
    2371 
    2372         // Single
    2373         } else {
    2374             $pre_current_text = get_the_title();
    2375         }
    2376 
    2377         /** Parse Args ********************************************************/
    2378 
    2379         // Parse args
    2380         $r = bbp_parse_args( $args, array(
    2381 
    2382             // HTML
    2383             'before'          => '<div class="bbp-breadcrumb"><p>',
    2384             'after'           => '</p></div>',
    2385 
    2386             // Separator
    2387             'sep'             => is_rtl() ? __( '&lsaquo;', 'bbpress' ) : __( '&rsaquo;', 'bbpress' ),
    2388             'pad_sep'         => 1,
    2389             'sep_before'      => '<span class="bbp-breadcrumb-sep">',
    2390             'sep_after'       => '</span>',
    2391 
    2392             // Crumbs
    2393             'crumb_before'    => '',
    2394             'crumb_after'     => '',
    2395 
    2396             // Home
    2397             'include_home'    => $pre_include_home,
    2398             'home_text'       => $pre_front_text,
    2399 
    2400             // Forum root
    2401             'include_root'    => $pre_include_root,
    2402             'root_text'       => $pre_root_text,
    2403 
    2404             // Current
    2405             'include_current' => $pre_include_current,
    2406             'current_text'    => $pre_current_text,
    2407             'current_before'  => '<span class="bbp-breadcrumb-current">',
    2408             'current_after'   => '</span>',
    2409         ), 'get_breadcrumb' );
    2410 
    2411         /** Ancestors *********************************************************/
    2412 
    2413         // Get post ancestors
    2414         if ( is_singular() || bbp_is_forum_edit() || bbp_is_topic_edit() || bbp_is_reply_edit() ) {
    2415             $ancestors = array_reverse( (array) get_post_ancestors( get_the_ID() ) );
    2416         }
    2417 
    2418         // Do we want to include a link to home?
    2419         if ( ! empty( $r['include_home'] ) || empty( $r['home_text'] ) ) {
    2420             $crumbs[] = '<a href="' . esc_url( home_url() ) . '" class="bbp-breadcrumb-home">' . $r['home_text'] . '</a>';
    2421         }
    2422 
    2423         // Do we want to include a link to the forum root?
    2424         if ( ! empty( $r['include_root'] ) || empty( $r['root_text'] ) ) {
    2425 
    2426             // Page exists at root slug path, so use its permalink
    2427             $page = bbp_get_page_by_path( bbp_get_root_slug() );
    2428             if ( ! empty( $page ) ) {
    2429                 $root_url       = get_permalink( $page->ID );
    2430                 $remove_root_id = $page->ID;
    2431 
    2432             // Use the root slug
    2433             } else {
    2434                 $root_url = get_post_type_archive_link( bbp_get_forum_post_type() );
    2435             }
    2436 
    2437             // Add the breadcrumb
    2438             $crumbs[] = '<a href="' . esc_url( $root_url ) . '" class="bbp-breadcrumb-root">' . $r['root_text'] . '</a>';
    2439         }
    2440 
    2441         // Ancestors exist
    2442         if ( ! empty( $ancestors ) ) {
    2443 
    2444             // Loop through parents
    2445             foreach ( (array) $ancestors as $parent_id ) {
    2446 
    2447                 // Parents
    2448                 $parent = get_post( $parent_id );
    2449 
    2450                 // Skip parent if empty or error
    2451                 if ( empty( $parent ) || is_wp_error( $parent ) ) {
    2452                     continue;
    2453                 }
    2454 
    2455                 // Skip to prevent duplicate root on subpages
    2456                 if ( ! empty( $remove_root_id ) && ( $parent->ID === $remove_root_id ) ) {
    2457                     continue;
    2458                 }
    2459 
    2460                 // Switch through post_type to ensure correct filters are applied
    2461                 switch ( $parent->post_type ) {
    2462 
    2463                     // Forum
    2464                     case bbp_get_forum_post_type() :
    2465                         $crumbs[] = '<a href="' . esc_url( bbp_get_forum_permalink( $parent->ID ) ) . '" class="bbp-breadcrumb-forum">' . bbp_get_forum_title( $parent->ID ) . '</a>';
    2466                         break;
    2467 
    2468                     // Topic
    2469                     case bbp_get_topic_post_type() :
    2470                         $crumbs[] = '<a href="' . esc_url( bbp_get_topic_permalink( $parent->ID ) ) . '" class="bbp-breadcrumb-topic">' . bbp_get_topic_title( $parent->ID ) . '</a>';
    2471                         break;
    2472 
    2473                     // Reply (Note: not in most themes)
    2474                     case bbp_get_reply_post_type() :
    2475                         $crumbs[] = '<a href="' . esc_url( bbp_get_reply_permalink( $parent->ID ) ) . '" class="bbp-breadcrumb-reply">' . bbp_get_reply_title( $parent->ID ) . '</a>';
    2476                         break;
    2477 
    2478                     // WordPress Post/Page/Other
    2479                     default :
    2480                         $crumbs[] = '<a href="' . esc_url( get_permalink( $parent->ID ) ) . '" class="bbp-breadcrumb-item">' . get_the_title( $parent->ID ) . '</a>';
    2481                         break;
    2482                 }
    2483             }
    2484 
    2485         // Edit topic tag
    2486         } elseif ( bbp_is_topic_tag_edit() ) {
    2487             $crumbs[] = '<a href="' . esc_url( get_term_link( bbp_get_topic_tag_id(), bbp_get_topic_tag_tax_id() ) ) . '" class="bbp-breadcrumb-topic-tag">' . sprintf( esc_html__( 'Topic Tag: %s', 'bbpress' ), bbp_get_topic_tag_name() ) . '</a>';
    2488 
    2489         // Search
    2490         } elseif ( bbp_is_search() && bbp_get_search_terms() ) {
    2491             $crumbs[] = '<a href="' . esc_url( bbp_get_search_url() ) . '" class="bbp-breadcrumb-search">' . esc_html__( 'Search', 'bbpress' ) . '</a>';
    2492         }
    2493 
    2494         /** Current ***********************************************************/
    2495 
    2496         // Add current page to breadcrumb
    2497         if ( ! empty( $r['include_current'] ) || empty( $r['current_text'] ) ) {
    2498             $crumbs[] = $r['current_before'] . $r['current_text'] . $r['current_after'];
    2499         }
    2500 
    2501         /** Separator *********************************************************/
    2502 
    2503         // Wrap the separator in before/after before padding and filter
    2504         if ( ! empty( $r['sep'] ) ) {
    2505             $sep = $r['sep_before'] . $r['sep'] . $r['sep_after'];
    2506         } else {
    2507             $sep = '';
    2508         }
    2509 
    2510         // Pad the separator
    2511         if ( ! empty( $r['pad_sep'] ) ) {
    2512             if ( function_exists( 'mb_strlen' ) ) {
    2513                 $sep = str_pad( $sep, mb_strlen( $sep ) + ( (int) $r['pad_sep'] * 2 ), ' ', STR_PAD_BOTH );
    2514             } else {
    2515                 $sep = str_pad( $sep, strlen( $sep ) + ( (int) $r['pad_sep'] * 2 ), ' ', STR_PAD_BOTH );
     2476    }
     2477
     2478    /** Finish Up *********************************************************/
     2479
     2480    // Filter the separator and breadcrumb
     2481    $sep    = apply_filters( 'bbp_breadcrumb_separator', $sep    );
     2482    $crumbs = apply_filters( 'bbp_breadcrumbs',          $crumbs );
     2483
     2484    // Build the trail
     2485    $trail  = ! empty( $crumbs )
     2486        ? ( $r['before'] . $r['crumb_before'] . implode( $sep . $r['crumb_after'] . $r['crumb_before'], $crumbs ) . $r['crumb_after'] . $r['after'] )
     2487        : '';
     2488
     2489    // Filter & return
     2490    return apply_filters( 'bbp_get_breadcrumb', $trail, $crumbs, $r, $args );
     2491}
     2492
     2493/** Topic Tags ***************************************************************/
     2494
     2495/**
     2496 * Output all of the allowed tags in HTML format with attributes.
     2497 *
     2498 * This is useful for displaying in the post area, which elements and
     2499 * attributes are supported. As well as any plugins which want to display it.
     2500 *
     2501 * @since 2.0.0 bbPress (r2780)
     2502 */
     2503function bbp_allowed_tags() {
     2504    echo bbp_get_allowed_tags();
     2505}
     2506
     2507/**
     2508 * Display all of the allowed tags in HTML format with attributes.
     2509 *
     2510 * This is useful for displaying in the post area, which elements and
     2511 * attributes are supported. As well as any plugins which want to display it.
     2512 *
     2513 * @since 2.0.0 bbPress (r2780)
     2514 *
     2515 * @return string HTML allowed tags entity encoded
     2516 */
     2517function bbp_get_allowed_tags() {
     2518    $allowed = '';
     2519
     2520    foreach ( (array) bbp_kses_allowed_tags() as $tag => $attributes ) {
     2521        $allowed .= '<' . $tag;
     2522
     2523        if ( 0 < count( $attributes ) ) {
     2524            foreach ( array_keys( $attributes ) as $attribute ) {
     2525                $allowed .= ' ' . $attribute. '=""';
    25162526            }
    25172527        }
    25182528
    2519         /** Finish Up *********************************************************/
    2520 
    2521         // Filter the separator and breadcrumb
    2522         $sep    = apply_filters( 'bbp_breadcrumb_separator', $sep    );
    2523         $crumbs = apply_filters( 'bbp_breadcrumbs',          $crumbs );
    2524 
    2525         // Build the trail
    2526         $trail  = ! empty( $crumbs ) ? ( $r['before'] . $r['crumb_before'] . implode( $sep . $r['crumb_after'] . $r['crumb_before'], $crumbs ) . $r['crumb_after'] . $r['after'] ) : '';
    2527 
    2528         // Filter & return
    2529         return apply_filters( 'bbp_get_breadcrumb', $trail, $crumbs, $r, $args );
    2530     }
    2531 
    2532 /** Topic Tags ***************************************************************/
    2533 
    2534 /**
    2535  * Output all of the allowed tags in HTML format with attributes.
    2536  *
    2537  * This is useful for displaying in the post area, which elements and
    2538  * attributes are supported. As well as any plugins which want to display it.
    2539  *
    2540  * @since 2.0.0 bbPress (r2780)
    2541  */
    2542 function bbp_allowed_tags() {
    2543     echo bbp_get_allowed_tags();
    2544 }
    2545     /**
    2546      * Display all of the allowed tags in HTML format with attributes.
    2547      *
    2548      * This is useful for displaying in the post area, which elements and
    2549      * attributes are supported. As well as any plugins which want to display it.
    2550      *
    2551      * @since 2.0.0 bbPress (r2780)
    2552      *
    2553      * @return string HTML allowed tags entity encoded.
    2554      */
    2555     function bbp_get_allowed_tags() {
    2556 
    2557         $allowed = '';
    2558 
    2559         foreach ( (array) bbp_kses_allowed_tags() as $tag => $attributes ) {
    2560             $allowed .= '<' . $tag;
    2561             if ( 0 < count( $attributes ) ) {
    2562                 foreach ( array_keys( $attributes ) as $attribute ) {
    2563                     $allowed .= ' ' . $attribute . '=""';
    2564                 }
    2565             }
    2566             $allowed .= '> ';
    2567         }
    2568 
    2569         // Filter & return
    2570         return apply_filters( 'bbp_get_allowed_tags', htmlentities( $allowed ) );
    2571     }
     2529        $allowed .= '> ';
     2530    }
     2531
     2532    // Filter & return
     2533    return apply_filters( 'bbp_get_allowed_tags', htmlentities( $allowed ) );
     2534}
    25722535
    25732536/** Errors & Messages *********************************************************/
    25742537
    25752538/**
    2576  * Display possible errors & messages inside a template file
     2539 * Display possible errors & messages inside a template file.
    25772540 *
    25782541 * @since 2.0.0 bbPress (r2688)
     
    25852548    }
    25862549
    2587     // Define local variable(s)
     2550    // Define local variable(s )
    25882551    $errors = $messages = array();
    25892552
     
    26022565                $messages[] = $error;
    26032566            } else {
    2604                 $errors[]   = $error;
     2567                $errors[] = $error;
    26052568            }
    26062569        }
     
    26082571
    26092572    // Display errors first...
    2610     if ( ! empty( $errors ) ) : ?>
     2573    if ( ! empty( $errors ) ) { ?>
    26112574
    26122575        <div class="bbp-template-notice error" role="alert" tabindex="-1">
     
    26162579        </div>
    26172580
    2618     <?php endif;
     2581    <?php }
    26192582
    26202583    // ...and messages last
    2621     if ( ! empty( $messages ) ) : ?>
     2584    if ( ! empty( $messages ) ) { ?>
    26222585
    26232586        <div class="bbp-template-notice">
     
    26272590        </div>
    26282591
    2629     <?php endif;
     2592    <?php
     2593
     2594    }
    26302595}
    26312596
     
    26332598
    26342599/**
    2635  * Output the logout link
     2600 * Output the logout link.
    26362601 *
    26372602 * @since 2.0.0 bbPress (r2827)
     
    26422607    echo bbp_get_logout_link( $redirect_to );
    26432608}
    2644     /**
    2645      * Return the logout link
    2646      *
    2647      * @since 2.0.0 bbPress (r2827)
    2648      *
    2649      * @param string $redirect_to Redirect to url
    2650      *                        redirect to url
    2651      * @return string The logout link
    2652      */
    2653     function bbp_get_logout_link( $redirect_to = '' ) {
    2654 
    2655         // Build the link
    2656         $link = '<a href="' . wp_logout_url( $redirect_to ) . '" class="button logout-link">' . esc_html__( 'Log Out', 'bbpress' ) . '</a>';
    2657 
    2658         // Filter & return
    2659         return apply_filters( 'bbp_get_logout_link', $link, $redirect_to );
    2660     }
     2609
     2610/**
     2611 * Return the logout link.
     2612 *
     2613 * @since 2.0.0 bbPress (r2827)
     2614 *
     2615 * @param string $redirect_to Redirect to url
     2616 *                            redirect to url
     2617 *
     2618 * @return string The logout link
     2619 */
     2620function bbp_get_logout_link( $redirect_to = '' ) {
     2621
     2622    // Build the link
     2623    $link = '<a href="' . wp_logout_url( $redirect_to ). '" class="button logout-link">' . esc_html__( 'Log Out', 'bbpress' ). '</a>';
     2624
     2625    // Filter & return
     2626    return apply_filters( 'bbp_get_logout_link', $link, $redirect_to );
     2627}
    26612628
    26622629/** Title *********************************************************************/
    26632630
    26642631/**
    2665  * Custom page title for bbPress pages
     2632 * Custom page title for bbPress pages.
    26662633 *
    26672634 * @since 2.0.0 bbPress (r2788)
    26682635 *
    2669  * @param string $title Optional. The title (not used).
    2670  * @param string $sep Optional, default is '&raquo;'. How to separate the
    2671  *                     various items within the page title.
     2636 * @param string $title       Optional. The title (not used ).
     2637 * @param string $sep         Optional, default is '&raquo;'. How to separate the
     2638 *                            various items within the page title.
    26722639 * @param string $seplocation Optional. Direction to display title, 'right'.
    2673  *                        separator and separator location
     2640 *                            separator and separator location
     2641 *
    26742642 * @return string The title
    26752643 */
     
    26792647    $new_title = array();
    26802648
    2681     /** Archives **************************************************************/
     2649    /* Archives ************************************************************* */
    26822650
    26832651    // Forum Archive
     
    26892657        $new_title['text'] = bbp_get_topic_archive_title();
    26902658
    2691     /** Edit ******************************************************************/
     2659    /* Edit ***************************************************************** */
    26922660
    26932661    // Forum edit page
    26942662    } elseif ( bbp_is_forum_edit() ) {
    2695         $new_title['text']   = bbp_get_forum_title();
     2663        $new_title['text'] = bbp_get_forum_title();
     2664        /* translators: %s: Forum title */
    26962665        $new_title['format'] = esc_attr__( 'Forum Edit: %s', 'bbpress' );
    26972666
    26982667    // Topic edit page
    26992668    } elseif ( bbp_is_topic_edit() ) {
    2700         $new_title['text']   = bbp_get_topic_title();
     2669        $new_title['text'] = bbp_get_topic_title();
     2670        /* translators: %s: Topic title */
    27012671        $new_title['format'] = esc_attr__( 'Topic Edit: %s', 'bbpress' );
    27022672
    27032673    // Reply edit page
    27042674    } elseif ( bbp_is_reply_edit() ) {
    2705         $new_title['text']   = bbp_get_reply_title();
     2675        $new_title['text'] = bbp_get_reply_title();
     2676        /* translators: %s: Reply title */
    27062677        $new_title['format'] = esc_attr__( 'Reply Edit: %s', 'bbpress' );
    27072678
    27082679    // Topic tag edit page
    27092680    } elseif ( bbp_is_topic_tag_edit() ) {
    2710         $new_title['text']   = bbp_get_topic_tag_name();
     2681        $new_title['text'] = bbp_get_topic_tag_name();
     2682        /* translators: %s: Topic tag name */
    27112683        $new_title['format'] = esc_attr__( 'Topic Tag Edit: %s', 'bbpress' );
    27122684
    2713     /** Singles ***************************************************************/
     2685    /* Singles ************************************************************** */
    27142686
    27152687    // Forum page
    27162688    } elseif ( bbp_is_single_forum() ) {
    2717         $new_title['text']   = bbp_get_forum_title();
     2689        $new_title['text'] = bbp_get_forum_title();
     2690        /* translators: %s: Forum title */
    27182691        $new_title['format'] = esc_attr__( 'Forum: %s', 'bbpress' );
    27192692
    27202693    // Topic page
    27212694    } elseif ( bbp_is_single_topic() ) {
    2722         $new_title['text']   = bbp_get_topic_title();
     2695        $new_title['text'] = bbp_get_topic_title();
     2696        /* translators: %s: Topic title */
    27232697        $new_title['format'] = esc_attr__( 'Topic: %s', 'bbpress' );
    27242698
    27252699    // Replies
    27262700    } elseif ( bbp_is_single_reply() ) {
    2727         $new_title['text']   = bbp_get_reply_title();
     2701        $new_title['text'] = bbp_get_reply_title();
    27282702
    27292703    // Topic tag page
    27302704    } elseif ( bbp_is_topic_tag() || get_query_var( 'bbp_topic_tag' ) ) {
    2731         $new_title['text']   = bbp_get_topic_tag_name();
     2705        $new_title['text'] = bbp_get_topic_tag_name();
     2706        /* translators: %s: Topic tag name */
    27322707        $new_title['format'] = esc_attr__( 'Topic Tag: %s', 'bbpress' );
    27332708
    2734     /** Users *****************************************************************/
     2709    /* Users **************************************************************** */
    27352710
    27362711    // Profile page
    27372712    } elseif ( bbp_is_single_user() ) {
    2738 
    27392713        // Is user viewing their own profile?
    27402714        $is_user_home = bbp_is_user_home();
     
    27932767    // Profile edit page
    27942768    } elseif ( bbp_is_single_user_edit() ) {
    2795 
    27962769        // Current user
    27972770        if ( bbp_is_user_home_edit() ) {
    2798             $new_title['text']   = esc_attr__( 'Edit Your Profile', 'bbpress' );
     2771            $new_title['text'] = esc_attr__( 'Edit Your Profile', 'bbpress' );
    27992772
    28002773        // Other user
    28012774        } else {
    2802             $new_title['text']   = get_userdata( bbp_get_user_id() )->display_name;
     2775            $new_title['text'] = get_userdata( bbp_get_user_id() )->display_name;
     2776            /* translators: %s: User's display name */
    28032777            $new_title['format'] = esc_attr__( "Edit %s's Profile", 'bbpress' );
    28042778        }
    28052779
    2806     /** Views *****************************************************************/
     2780    /* Views **************************************************************** */
    28072781
    28082782    // Views
    28092783    } elseif ( bbp_is_single_view() ) {
    2810         $new_title['text']   = bbp_get_view_title();
     2784        $new_title['text'] = bbp_get_view_title();
     2785        /* translators: %s: View title */
    28112786        $new_title['format'] = esc_attr__( 'View: %s', 'bbpress' );
    28122787
    2813     /** Search ****************************************************************/
     2788    /* Search *************************************************************** */
    28142789
    28152790    // Search
     
    28242799    $new_title = bbp_parse_args( $new_title, array(
    28252800        'text'   => $title,
    2826         'format' => '%s'
     2801        'format' => '%s',
    28272802    ), 'title' );
    28282803
     
    28722847 * @since 2.7.0
    28732848 *
    2874  * @param string      $prepend Text displayed before a post title.
    2875  * @param int|WP_Post $post    Current post object.
     2849 * @param string      $prepend text displayed before a post title
     2850 * @param int|WP_Post $post    current post object
    28762851 *
    28772852 * @return string
  • trunk/src/includes/common/widgets.php

    r7357 r7360  
    803803                    <?php if ( ! empty( $author_link ) ) : ?>
    804804
    805                         <?php printf( esc_html_x( 'by %1$s', 'widgets', 'bbpress' ), '<span class="topic-author">' . $author_link . '</span>' ); ?>
     805                        <?php
     806                        printf(
     807                            /* translators: %1$s: Topic author link wrapped in span tag */
     808                            esc_html_x( 'by %1$s', 'widgets', 'bbpress' ), '<span class="topic-author">' . $author_link . '</span>'
     809                        );
     810                        ?>
    806811
    807812                    <?php endif; ?>
     
    11471152                    if ( ! empty( $settings['show_date'] ) && ! empty( $author_link ) ) :
    11481153
    1149                         // translators: 1: reply author, 2: reply link, 3: reply timestamp
     1154                        /* translators: 1: reply author, 2: reply link, 3: reply timestamp */
    11501155                        printf( esc_html_x( '%1$s on %2$s %3$s', 'widgets', 'bbpress' ), $author_link, $reply_link, $show_date );
    11511156
     
    11571162                    elseif ( ! empty( $author_link ) ) :
    11581163
    1159                         // translators: 1: reply author, 2: reply link
     1164                        /* translators: 1: reply author, 2: reply link */
    11601165                        printf( esc_html_x( '%1$s on %2$s', 'widgets', 'bbpress' ), $author_link, $reply_link );
    11611166
  • trunk/src/includes/core/theme-compat.php

    r7348 r7360  
    802802            'post_content'   => $new_content,
    803803            'post_type'      => '',
     804            /* translators: %s: Topic tag name */
    804805            'post_title'     => sprintf( esc_html__( 'Topic Tag: %s', 'bbpress' ), bbp_get_topic_tag_name() ),
    805806            'post_status'    => bbp_get_public_status_id(),
  • trunk/src/includes/extend/akismet.php

    r7359 r7360  
    629629                            $post_id,
    630630                            sprintf(
    631                                 esc_html__( 'Akismet overruled. Post status overridden to %s.', 'bbpress' ),
     631                                /* translators: %s: Post status */
     632                                esc_html__( 'Post status was changed to %s', 'bbpress' ),
    632633                                $_post->post_status
    633634                            ),
     
    652653                            $post_id,
    653654                            sprintf(
    654                                 esc_html__( 'Akismet overruled. Post status overridden to %s.', 'bbpress' ),
     655                                /* translators: %s: Post status */
     656                                esc_html__( 'Post status was changed to %s', 'bbpress' ),
    655657                                $_post->post_status
    656658                            ),
     
    666668                        $post_id,
    667669                        sprintf(
     670                            /* translators: %s: Akismet response */
    668671                            esc_html__( 'Akismet was unable to check this post (response: %s), will automatically retry again later.', 'bbpress' ),
    669672                            $this->last_post['bbp_akismet_result']
  • trunk/src/includes/extend/buddypress/activity.php

    r7214 r7360  
    399399
    400400        // Activity action & text
    401         $activity_text    = sprintf( esc_html__( '%1$s started the topic %2$s in the forum %3$s', 'bbpress' ), $user_link, $topic_link, $forum_link );
     401        $activity_text = sprintf(
     402            /* translators: 1: User linked profile, 2: Topic linked title, 3: Forum linked title */
     403            esc_html__( '%1$s started the topic %2$s in the forum %3$s', 'bbpress' ),
     404            $user_link,
     405            $topic_link,
     406            $forum_link
     407        );
    402408        $activity_action  = apply_filters( 'bbp_activity_topic_create',         $activity_text, $user_id,   $topic_id,   $forum_id );
    403409        $activity_content = apply_filters( 'bbp_activity_topic_create_excerpt', $topic_content                                     );
     
    537543
    538544        // Activity action & text
    539         $activity_text    = sprintf( esc_html__( '%1$s replied to the topic %2$s in the forum %3$s', 'bbpress' ), $user_link, $topic_link, $forum_link );
     545        $activity_text    = sprintf(
     546            /* translators: 1: User linked profile, 2: Topic linked title, 3: Forum linked title */
     547            esc_html__( '%1$s replied to the topic %2$s in the forum %3$s', 'bbpress' ),
     548            $user_link,
     549            $topic_link,
     550            $forum_link
     551        );
    540552        $activity_action  = apply_filters( 'bbp_activity_reply_create',         $activity_text, $user_id, $reply_id,  $topic_id );
    541553        $activity_content = apply_filters( 'bbp_activity_reply_create_excerpt', $reply_content                                  );
  • trunk/src/includes/extend/buddypress/functions.php

    r6850 r7360  
    775775function bbp_get_activity_actions() {
    776776
     777    // Define activity actions with proper translation support
     778    $actions = array(
     779
     780        'topic' =>
     781        /* translators: 1: User linked profile, 2: Topic linked title, 3: Forum linked title */
     782        esc_html__( '%1$s started the topic %2$s in the forum %3$s', 'bbpress' ),
     783
     784        'reply' =>
     785        /* translators: 1: User linked profile, 2: Topic linked title, 3: Forum linked title */
     786        esc_html__( '%1$s replied to the topic %2$s in the forum %3$s', 'bbpress' )
     787    );
     788
    777789    // Filter & return
    778     return (array) apply_filters( 'bbp_get_activity_actions', array(
    779         'topic' => esc_html__( '%1$s started the topic %2$s in the forum %3$s',    'bbpress' ),
    780         'reply' => esc_html__( '%1$s replied to the topic %2$s in the forum %3$s', 'bbpress' )
    781     ) );
     790    return (array) apply_filters( 'bbp_get_activity_actions', $actions );
    782791}
    783792
  • trunk/src/includes/extend/buddypress/groups.php

    r7357 r7360  
    484484                    <label for="bbp_group_forum_id"><?php esc_html_e( 'Group Forum:', 'bbpress' ); ?></label>
    485485                    <?php
    486                         bbp_dropdown( array(
    487                             'select_id' => 'bbp_group_forum_id',
    488                             'show_none' => esc_html__( '&mdash; No forum &mdash;', 'bbpress' ),
    489                             'selected'  => $forum_id
    490                         ) );
     486                        bbp_dropdown(
     487                            array(
     488                                'select_id' => 'bbp_group_forum_id',
     489                                'show_none' => esc_html__( '&mdash; No forum &mdash;', 'bbpress' ),
     490                                'selected'  => $forum_id
     491                            )
     492                        );
    491493                    ?>
    492494                    <p class="description"><?php esc_html_e( 'Network administrators can reconfigure which forum belongs to this group.', 'bbpress' ); ?></p>
     
    16931695    }
    16941696
    1695     /**
    1696     * Fixes rewrite pagination in BuddyPress Group Forums & Topics.
    1697      *
    1698     * Required for compatibility with BuddyPress > 12.0, where the /groups/
     1697    /**
     1698    * Fixes rewrite pagination in BuddyPress Group Forums & Topics.
     1699     *
     1700    * Required for compatibility with BuddyPress > 12.0, where the /groups/
    16991701     * rewrite rule will be caught before bbPress's /page/ rule.
    17001702     *
     
    17041706     * @param  string $type   Type of variable to check with `is_a()`
    17051707     * @return mixed  $object Verified object if valid, Default or null if invalid
    1706     */
    1707     public function rewrite_pagination( $object, $type = '' ) {
     1708    */
     1709    public function rewrite_pagination( $object, $type = '' ) {
    17081710
    17091711        // Bail if wrong global
    1710         if ( 'wp_query' !== $type ) {
    1711             return $object;
    1712         }
     1712        if ( 'wp_query' !== $type ) {
     1713            return $object;
     1714        }
    17131715
    17141716        // Bail if not inside a BuddyPress Group
    1715         if ( ! bp_is_group() ) {
    1716             return $object;
    1717         }
     1717        if ( ! bp_is_group() ) {
     1718            return $object;
     1719        }
    17181720
    17191721        // Bail if not inside a BuddyPress Group Forum
    1720         if ( ! bp_is_current_action( 'forum' ) ) {
    1721             return $object;
    1722         }
     1722        if ( ! bp_is_current_action( 'forum' ) ) {
     1723            return $object;
     1724        }
    17231725
    17241726        // Default "paged" value
    1725         $page_number = null;
    1726 
    1727         // Can't use bbp_is_single_topic() because it triggers a loop.
    1728         $is_single_topic = bp_is_action_variable( 'topic', 0 );
     1727        $page_number = null;
     1728
     1729        // Can't use bbp_is_single_topic() because it triggers a loop.
     1730        $is_single_topic = bp_is_action_variable( 'topic', 0 );
    17291731
    17301732        // Single Topic
    1731         if ( true === $is_single_topic ) {
     1733        if ( true === $is_single_topic ) {
    17321734
    17331735            // Get the page number from 3rd position
    1734             if ( bp_is_action_variable( 'page', 2 ) ) {
    1735                 $page_number = bp_action_variable( 3 );
    1736             }
     1736            if ( bp_is_action_variable( 'page', 2 ) ) {
     1737                $page_number = bp_action_variable( 3 );
     1738            }
    17371739
    17381740        // Single Forum
    1739         } else {
     1741        } else {
    17401742
    17411743            // Get the page number from 1st position
    1742             if ( bp_is_action_variable( 'page', 0 ) ) {
    1743                 $page_number = bp_action_variable( 1 );
    1744             }
    1745         }
     1744            if ( bp_is_action_variable( 'page', 0 ) ) {
     1745                $page_number = bp_action_variable( 1 );
     1746            }
     1747        }
    17461748
    17471749        // Bail if no page number
    1748         if ( empty( $page_number ) ) {
    1749             return $object;
    1750         }
     1750        if ( empty( $page_number ) ) {
     1751            return $object;
     1752        }
    17511753
    17521754        // Set the 'paged' WP_Query var to the new action-based value
    1753         $object->set( 'paged', $page_number );
     1755        $object->set( 'paged', $page_number );
    17541756
    17551757        // Return the filtered/modified object
    1756         return $object;
    1757     }
     1758        return $object;
     1759    }
    17581760
    17591761    /**
  • trunk/src/includes/extend/buddypress/notifications.php

    r7308 r7360  
    8484    $action_item_count = (int) $action_item_count;
    8585
    86     // Multiple
     86    // Multiple replies
    8787    if ( $action_item_count > 1 ) {
    8888        $filter = 'bbp_multiple_new_subscription_notification';
    89         $text   = sprintf( esc_html__( 'You have %1$d new replies to %2$s', 'bbpress' ), $action_item_count, $topic_title );
    90 
    91     // Single
     89        $text = sprintf(
     90            /* translators: 1: Number of replies, 2: Topic title */
     91            esc_html__( 'You have %1$d new replies to %2$s', 'bbpress' ),
     92            $action_item_count,
     93            $topic_title
     94        );
     95
     96    // Single reply
    9297    } else {
    9398        $filter = 'bbp_single_new_subscription_notification';
    94         $text   = ! empty( $secondary_item_id )
    95             ? sprintf( esc_html__( 'You have %1$d new reply to %2$s from %3$s', 'bbpress' ), $action_item_count, $topic_title, bp_core_get_user_displayname( $secondary_item_id ) )
    96             : sprintf( esc_html__( 'You have %1$d new reply to %2$s',             'bbpress' ), $action_item_count, $topic_title );
     99
     100        if ( ! empty( $secondary_item_id ) ) {
     101            $text = sprintf(
     102                /* translators: 1: Number of replies, 2: Topic title, 3: Reply author name */
     103                esc_html__( 'You have %1$d new reply to %2$s from %3$s', 'bbpress' ),
     104                $action_item_count,
     105                $topic_title,
     106                bp_core_get_user_displayname( $secondary_item_id )
     107            );
     108        } else {
     109            $text = sprintf(
     110                /* translators: 1: Number of replies, 2: Topic title */
     111                esc_html__( 'You have %1$d new reply to %2$s', 'bbpress' ),
     112                $action_item_count,
     113                $topic_title
     114            );
     115        }
    97116    }
    98117
  • trunk/src/includes/forums/functions.php

    r7357 r7360  
    355355
    356356    // WP_Error
     357
    357358    } elseif ( is_wp_error( $forum_id ) ) {
    358         bbp_add_error( 'bbp_forum_error', sprintf( __( '<strong>Error</strong>: The following problem(s) occurred: %s', 'bbpress' ), $forum_id->get_error_message() ) );
    359 
    360     // Generic error
     359        bbp_add_error(
     360            'bbp_forum_error',
     361            sprintf(
     362                /* translators: %s: Error message */
     363                esc_html__( '<strong>Error</strong>: The following problem(s) occurred: %s', 'bbpress' ),
     364                $forum_id->get_error_message()
     365            )
     366        );
    361367    } else {
    362         bbp_add_error( 'bbp_forum_error', __( '<strong>Error</strong>: The forum was not created.', 'bbpress' ) );
    363     }
     368            bbp_add_error( 'bbp_forum_error', __( '<strong>Error</strong>: The forum was not created.', 'bbpress' ) );
     369        }
    364370}
    365371
     
    602608    } else {
    603609        $append_error = ( is_wp_error( $forum_id ) && $forum_id->get_error_message() ) ? $forum_id->get_error_message() . ' ' : '';
    604         bbp_add_error( 'bbp_forum_error', sprintf( __( '<strong>Error</strong>: The following problem(s) have been found with your forum: %s Please try again.', 'bbpress' ) ), $append_error );
     610        bbp_add_error(
     611            'bbp_forum_error',
     612            sprintf(
     613                /* translators: %s: Error message */
     614                __( '<strong>Error</strong>: The following problem(s) have been found with your forum: %s Please try again.', 'bbpress' ) ),
     615                $append_error
     616        );
    605617    }
    606618}
  • trunk/src/includes/forums/template.php

    r7359 r7360  
    2121    echo bbp_get_forum_post_type();
    2222}
    23     /**
    24      * Return the unique id of the custom post type for forums
    25      *
    26      * @since 2.0.0 bbPress (r2857)
    27      *
    28      * @return string The unique forum post type id
    29      */
    30     function bbp_get_forum_post_type() {
     23
     24/**
     25 * Return the unique id of the custom post type for forums
     26 *
     27 * @since 2.0.0 bbPress (r2857)
     28 *
     29 * @return string The unique forum post type id
     30 */
     31function bbp_get_forum_post_type() {
    3132
    3233    // Filter & return
    3334    return apply_filters( 'bbp_get_forum_post_type', bbpress()->forum_post_type );
    34     }
    35 
     35}
    3636
    3737/**
     
    224224    echo bbp_get_forum_id( $forum_id );
    225225}
    226     /**
    227      * Return the forum id
    228      *
    229      * @since 2.0.0 bbPress (r2464)
    230      *
    231      * @param $forum_id Optional. Used to check emptiness
    232      * @return int The forum id
    233      */
    234     function bbp_get_forum_id( $forum_id = 0 ) {
     226
     227/**
     228 * Return the forum id
     229 *
     230 * @since 2.0.0 bbPress (r2464)
     231 *
     232 * @param $forum_id Optional. Used to check emptiness
     233 * @return int The forum id
     234 */
     235function bbp_get_forum_id( $forum_id = 0 ) {
    235236    $bbp      = bbpress();
    236237    $wp_query = bbp_get_wp_query();
     
    240241        $bbp_forum_id = $forum_id;
    241242
    242         // Currently inside a forum loop
    243         } elseif ( ! empty( $bbp->forum_query->in_the_loop ) && isset( $bbp->forum_query->post->ID ) ) {
     243    // Currently inside a forum loop
     244    } elseif ( ! empty( $bbp->forum_query->in_the_loop ) && isset( $bbp->forum_query->post->ID ) ) {
    244245        $bbp_forum_id = $bbp->forum_query->post->ID;
    245246
    246         // Currently inside a search loop
    247         } elseif ( ! empty( $bbp->search_query->in_the_loop ) && isset( $bbp->search_query->post->ID ) && bbp_is_forum( $bbp->search_query->post->ID ) ) {
     247    // Currently inside a search loop
     248    } elseif ( ! empty( $bbp->search_query->in_the_loop ) && isset( $bbp->search_query->post->ID ) && bbp_is_forum( $bbp->search_query->post->ID ) ) {
    248249        $bbp_forum_id = $bbp->search_query->post->ID;
    249250
    250         // Currently viewing a forum
    251         } elseif ( ( bbp_is_single_forum() || bbp_is_forum_edit() ) && ! empty( $bbp->current_forum_id ) ) {
     251    // Currently viewing a forum
     252    } elseif ( ( bbp_is_single_forum() || bbp_is_forum_edit() ) && ! empty( $bbp->current_forum_id ) ) {
    252253        $bbp_forum_id = $bbp->current_forum_id;
    253254
    254         // Currently viewing a forum
    255         } elseif ( ( bbp_is_single_forum() || bbp_is_forum_edit() ) && isset( $wp_query->post->ID ) ) {
     255    // Currently viewing a forum
     256    } elseif ( ( bbp_is_single_forum() || bbp_is_forum_edit() ) && isset( $wp_query->post->ID ) ) {
    256257        $bbp_forum_id = $wp_query->post->ID;
    257258
    258         // Currently viewing a topic
    259         } elseif ( bbp_is_single_topic() ) {
     259    // Currently viewing a topic
     260    } elseif ( bbp_is_single_topic() ) {
    260261        $bbp_forum_id = bbp_get_topic_forum_id();
    261262
    262         // Fallback
    263         } else {
     263    // Fallback
     264    } else {
    264265        $bbp_forum_id = 0;
    265         }
     266    }
    266267
    267268    // Filter & return
    268269    return (int) apply_filters( 'bbp_get_forum_id', (int) $bbp_forum_id, $forum_id );
    269     }
     270}
    270271
    271272/**
     
    326327    echo esc_url( bbp_get_forum_permalink( $forum_id, $redirect_to ) );
    327328}
    328     /**
    329      * Return the link to the forum
    330      *
    331      * @since 2.0.0 bbPress (r2464)
    332      *
    333      * @param int $forum_id Optional. Forum id
    334      * @param string $redirect_to Optional. Pass a redirect value for use with
    335      *                              shortcodes and other fun things.
    336      *
    337      * @return string Permanent link to forum
    338      */
    339     function bbp_get_forum_permalink( $forum_id = 0, $redirect_to = '' ) {
     329
     330/**
     331 * Return the link to the forum
     332 *
     333 * @since 2.0.0 bbPress (r2464)
     334 *
     335 * @param int $forum_id Optional. Forum id
     336 * @param string $redirect_to Optional. Pass a redirect value for use with
     337 *                              shortcodes and other fun things.
     338 *
     339 * @return string Permanent link to forum
     340 */
     341function bbp_get_forum_permalink( $forum_id = 0, $redirect_to = '' ) {
    340342    $forum_id = bbp_get_forum_id( $forum_id );
    341343
     
    344346        $forum_permalink = esc_url_raw( $redirect_to );
    345347
    346         // Use the topic permalink
    347         } else {
     348    // Use the topic permalink
     349    } else {
    348350        $forum_permalink = get_permalink( $forum_id );
    349         }
     351    }
    350352
    351353    // Filter & return
    352354    return apply_filters( 'bbp_get_forum_permalink', $forum_permalink, $forum_id );
    353     }
     355}
    354356
    355357/**
     
    363365    echo bbp_get_forum_title( $forum_id );
    364366}
    365     /**
    366      * Return the title of the forum
    367      *
    368      * @since 2.0.0 bbPress (r2464)
    369      *
    370      * @param int $forum_id Optional. Forum id
    371      * @return string Title of forum
    372      */
    373     function bbp_get_forum_title( $forum_id = 0 ) {
     367
     368/**
     369 * Return the title of the forum
     370 *
     371 * @since 2.0.0 bbPress (r2464)
     372 *
     373 * @param int $forum_id Optional. Forum id
     374 * @return string Title of forum
     375 */
     376function bbp_get_forum_title( $forum_id = 0 ) {
    374377    $forum_id = bbp_get_forum_id( $forum_id );
    375378    $title    = get_post_field( 'post_title', $forum_id );
     
    378381    // Filter & return
    379382    return apply_filters( 'bbp_get_forum_title', $title, $forum_id );
    380     }
     383}
    381384
    382385/**
     
    390393    echo bbp_get_forum_archive_title( $title );
    391394}
    392     /**
    393      * Return the forum archive title
    394      *
    395      * @since 2.0.0 bbPress (r3249)
    396      *
    397      * @param string $title Default text to use as title
    398      *
    399      * @return string The forum archive title
    400      */
    401     function bbp_get_forum_archive_title( $title = '' ) {
     395
     396/**
     397 * Return the forum archive title
     398 *
     399 * @since 2.0.0 bbPress (r3249)
     400 *
     401 * @param string $title Default text to use as title
     402 *
     403 * @return string The forum archive title
     404 */
     405function bbp_get_forum_archive_title( $title = '' ) {
    402406
    403407    // If no title was passed
     
    409413            $title = get_the_title( $page->ID );
    410414
    411             // Default to forum post type name label
    412             } else {
     415        // Default to forum post type name label
     416        } else {
    413417            $fto    = get_post_type_object( bbp_get_forum_post_type() );
    414418            $title  = $fto->labels->name;
    415             }
    416419        }
     420    }
    417421
    418422    // Filter & return
    419423    return apply_filters( 'bbp_get_forum_archive_title', $title );
    420     }
     424}
    421425
    422426/**
     
    430434    echo bbp_get_forum_content( $forum_id );
    431435}
    432     /**
    433      * Return the content of the forum
    434      *
    435      * @since 2.0.0 bbPress (r2780)
    436      *
    437      * @param int $forum_id Optional. Topic id
    438      *
    439      * @return string Content of the forum
    440      */
    441     function bbp_get_forum_content( $forum_id = 0 ) {
     436
     437/**
     438 * Return the content of the forum
     439 *
     440 * @since 2.0.0 bbPress (r2780)
     441 *
     442 * @param int $forum_id Optional. Topic id
     443 *
     444 * @return string Content of the forum
     445 */
     446function bbp_get_forum_content( $forum_id = 0 ) {
    442447    $forum_id = bbp_get_forum_id( $forum_id );
    443448
     
    445450    if ( post_password_required( $forum_id ) ) {
    446451        return get_the_password_form();
    447         }
     452    }
    448453
    449454    $content = get_post_field( 'post_content', $forum_id );
     
    451456    // Filter & return
    452457    return apply_filters( 'bbp_get_forum_content', $content, $forum_id );
    453     }
     458}
    454459
    455460/**
     
    474479    echo bbp_get_forum_last_active_id( $forum_id );
    475480}
    476     /**
    477      * Return the forums last active ID
    478      *
    479      * @since 2.0.0 bbPress (r2860)
    480      *
    481      * @param int $forum_id Optional. Forum id
    482      *                        the last active id and forum id
    483      * @return int Forum's last active id
    484      */
    485     function bbp_get_forum_last_active_id( $forum_id = 0 ) {
     481
     482/**
     483 * Return the forums last active ID
     484 *
     485 * @since 2.0.0 bbPress (r2860)
     486 *
     487 * @param int $forum_id Optional. Forum id
     488 *                        the last active id and forum id
     489 * @return int Forum's last active id
     490 */
     491function bbp_get_forum_last_active_id( $forum_id = 0 ) {
    486492    $forum_id  = bbp_get_forum_id( $forum_id );
    487493    $active_id = (int) get_post_meta( $forum_id, '_bbp_last_active_id', true );
     
    489495    // Filter & return
    490496    return (int) apply_filters( 'bbp_get_forum_last_active_id', $active_id, $forum_id );
    491     }
     497}
    492498
    493499/**
     
    501507    echo bbp_get_forum_last_active_time( $forum_id );
    502508}
    503     /**
    504      * Return the forums last update date/time (aka freshness)
    505      *
    506      * @since 2.0.0 bbPress (r2464)
    507      *
    508      * @param int $forum_id Optional. Forum id
    509      * @return string Forum last update date/time (freshness)
    510      */
    511     function bbp_get_forum_last_active_time( $forum_id = 0 ) {
     509
     510/**
     511 * Return the forums last update date/time (aka freshness)
     512 *
     513 * @since 2.0.0 bbPress (r2464)
     514 *
     515 * @param int $forum_id Optional. Forum id
     516 * @return string Forum last update date/time (freshness)
     517 */
     518function bbp_get_forum_last_active_time( $forum_id = 0 ) {
    512519
    513520    // Verify forum and get last active meta
     
    517524    if ( empty( $last_active ) ) {
    518525        $reply_id = bbp_get_forum_last_reply_id( $forum_id );
     526
    519527        if ( ! empty( $reply_id ) ) {
    520528            $last_active = get_post_field( 'post_date', $reply_id );
    521             } else {
     529        } else {
    522530            $topic_id = bbp_get_forum_last_topic_id( $forum_id );
    523531            if ( ! empty( $topic_id ) ) {
    524532                $last_active = bbp_get_topic_last_active_time( $topic_id );
    525                 }
    526533            }
    527534        }
    528 
    529     $active_time = ! empty( $last_active ) ? bbp_get_time_since( bbp_convert_date( $last_active ) ) : '';
     535    }
     536
     537    $active_time = ! empty( $last_active )
     538        ? bbp_get_time_since( bbp_convert_date( $last_active ) )
     539        : '';
    530540
    531541    // Filter & return
    532542    return apply_filters( 'bbp_get_forum_last_active', $active_time, $forum_id );
    533     }
     543}
    534544
    535545/**
     
    545555    echo bbp_get_forum_freshness_link( $forum_id );
    546556}
    547     /**
    548      * Returns link to the most recent activity inside a forum.
    549      *
    550      * Returns a complete link with attributes and content.
    551      *
    552      * @since 2.0.0 bbPress (r2625)
    553      *
    554      * @param int $forum_id Optional. Forum id
    555      */
    556     function bbp_get_forum_freshness_link( $forum_id = 0 ) {
     557
     558/**
     559 * Returns link to the most recent activity inside a forum.
     560 *
     561 * Returns a complete link with attributes and content.
     562 *
     563 * @since 2.0.0 bbPress (r2625)
     564 *
     565 * @param int $forum_id Optional. Forum id
     566 */
     567function bbp_get_forum_freshness_link( $forum_id = 0 ) {
    557568    $forum_id  = bbp_get_forum_id( $forum_id );
    558569    $active_id = bbp_get_forum_last_active_id( $forum_id );
     
    561572    if ( empty( $active_id ) ) {
    562573        $active_id = bbp_get_forum_last_reply_id( $forum_id );
    563         }
     574    }
    564575
    565576    if ( empty( $active_id ) ) {
    566577        $active_id = bbp_get_forum_last_topic_id( $forum_id );
    567         }
     578    }
    568579
    569580    if ( bbp_is_topic( $active_id ) ) {
    570581        $link_url = bbp_get_forum_last_topic_permalink( $forum_id );
    571582        $title    = bbp_get_forum_last_topic_title( $forum_id );
    572         } elseif ( bbp_is_reply( $active_id ) ) {
     583    } elseif ( bbp_is_reply( $active_id ) ) {
    573584        $link_url = bbp_get_forum_last_reply_url( $forum_id );
    574585        $title    = bbp_get_forum_last_reply_title( $forum_id );
    575         }
     586    }
    576587
    577588    $time_since = bbp_get_forum_last_active_time( $forum_id );
     
    579590    if ( ! empty( $time_since ) && ! empty( $link_url ) ) {
    580591        $anchor = '<a href="' . esc_url( $link_url ) . '" title="' . esc_attr( $title ) . '">' . esc_html( $time_since ) . '</a>';
    581         } else {
     592    } else {
    582593        $anchor = esc_html__( 'No Topics', 'bbpress' );
    583         }
     594    }
    584595
    585596    // Filter & return
    586597    return apply_filters( 'bbp_get_forum_freshness_link', $anchor, $forum_id, $time_since, $link_url, $title, $active_id );
    587     }
     598}
    588599
    589600/**
     
    597608    echo bbp_get_forum_parent_id( $forum_id );
    598609}
    599     /**
    600      * Return ID of forum parent, if exists
    601      *
    602      * @since 2.1.0 bbPress (r3675)
    603      *
    604      * @param int $forum_id Optional. Forum id
    605      * @return int Forum parent
    606      */
    607     function bbp_get_forum_parent_id( $forum_id = 0 ) {
     610
     611/**
     612 * Return ID of forum parent, if exists
     613 *
     614 * @since 2.1.0 bbPress (r3675)
     615 *
     616 * @param int $forum_id Optional. Forum id
     617 * @return int Forum parent
     618 */
     619function bbp_get_forum_parent_id( $forum_id = 0 ) {
    608620    $forum_id  = bbp_get_forum_id( $forum_id );
    609621    $parent_id = (int) get_post_field( 'post_parent', $forum_id );
     
    612624    if ( empty( $parent_id ) ) {
    613625        $parent_id = (int) get_post_meta( $forum_id, '_bbp_forum_id', true );
    614         }
     626    }
    615627
    616628    // Filter
    617629    if ( ! empty( $parent_id ) ) {
    618630        $parent_id = (int) bbp_get_forum_id( $parent_id );
    619         }
     631    }
    620632
    621633    // Filter & return
    622634    return (int) apply_filters( 'bbp_get_forum_parent_id', $parent_id, $forum_id );
    623     }
     635}
    624636
    625637/**
     
    809821}
    810822
    811     /**
    812     * Get the forum subscription link
    813     *
    814     * A custom wrapper for bbp_get_user_subscribe_link()
    815     *
    816     * @since 2.5.0 bbPress (r5156)
    817     * @since 2.6.0 bbPress (r6308) Add 'redirect_to' support
    818     */
    819     function bbp_get_forum_subscription_link( $args = array() ) {
     823/**
     824 * Get the forum subscription link
     825 *
     826 * A custom wrapper for bbp_get_user_subscribe_link()
     827 *
     828 * @since 2.5.0 bbPress (r5156)
     829 * @since 2.6.0 bbPress (r6308) Add 'redirect_to' support
     830 */
     831function bbp_get_forum_subscription_link( $args = array() ) {
    820832
    821833    // Defaults
    822834    $retval      = false;
    823835    $redirect_to = bbp_is_subscriptions()
    824     ? bbp_get_subscriptions_permalink()
    825     : '';
     836        ? bbp_get_subscriptions_permalink()
     837        : '';
    826838
    827839    // Parse the arguments
    828840    $r = bbp_parse_args( $args, array(
    829     'user_id'     => bbp_get_current_user_id(),
    830     'object_id'   => bbp_get_forum_id(),
    831     'object_type' => 'post',
    832     'before'      => '',
    833     'after'       => '',
    834     'subscribe'   => esc_html__( 'Subscribe',   'bbpress' ),
    835     'unsubscribe' => esc_html__( 'Unsubscribe', 'bbpress' ),
    836     'redirect_to' => $redirect_to
     841        'user_id'     => bbp_get_current_user_id(),
     842        'object_id'   => bbp_get_forum_id(),
     843        'object_type' => 'post',
     844        'before'      => '',
     845        'after'       => '',
     846        'subscribe'   => esc_html__( 'Subscribe',   'bbpress' ),
     847        'unsubscribe' => esc_html__( 'Unsubscribe', 'bbpress' ),
     848        'redirect_to' => $redirect_to
    837849    ), 'get_forum_subscribe_link' );
    838850
    839 // No link for categories until we support subscription hierarchy
    840 // @see https://bbpress.trac.wordpress.org/ticket/2475
    841 if ( ! bbp_is_forum_category() ) {
    842     $retval = bbp_get_user_subscribe_link( $r );
    843     }
    844 
    845 // Filter & return
    846 return apply_filters( 'bbp_get_forum_subscribe_link', $retval, $r, $args );
    847     }
     851    // No link for categories until we support subscription hierarchy
     852    // @see https://bbpress.trac.wordpress.org/ticket/2475
     853    if ( ! bbp_is_forum_category() ) {
     854        $retval = bbp_get_user_subscribe_link( $r );
     855    }
     856
     857    // Filter & return
     858    return apply_filters( 'bbp_get_forum_subscribe_link', $retval, $r, $args );
     859}
    848860
    849861/** Forum Last Topic **********************************************************/
     
    859871    echo bbp_get_forum_last_topic_id( $forum_id );
    860872}
    861     /**
    862      * Return the forum's last topic id
    863      *
    864      * @since 2.0.0 bbPress (r2464)
    865      *
    866      * @param int $forum_id Optional. Forum id
    867      * @return int Forum's last topic id
    868      */
    869     function bbp_get_forum_last_topic_id( $forum_id = 0 ) {
     873
     874/**
     875 * Return the forum's last topic id
     876 *
     877 * @since 2.0.0 bbPress (r2464)
     878 *
     879 * @param int $forum_id Optional. Forum id
     880 * @return int Forum's last topic id
     881 */
     882function bbp_get_forum_last_topic_id( $forum_id = 0 ) {
    870883    $forum_id = bbp_get_forum_id( $forum_id );
    871884    $topic_id = (int) get_post_meta( $forum_id, '_bbp_last_topic_id', true );
     
    873886    // Filter & return
    874887    return (int) apply_filters( 'bbp_get_forum_last_topic_id', $topic_id, $forum_id );
    875     }
     888}
    876889
    877890/**
     
    885898    echo bbp_get_forum_last_topic_title( $forum_id );
    886899}
    887     /**
    888      * Return the title of the last topic inside a forum
    889      *
    890      * @since 2.0.0 bbPress (r2625)
    891      *
    892      * @param int $forum_id Optional. Forum id
    893      * @return string Forum's last topic's title
    894      */
    895     function bbp_get_forum_last_topic_title( $forum_id = 0 ) {
     900
     901/**
     902 * Return the title of the last topic inside a forum
     903 *
     904 * @since 2.0.0 bbPress (r2625)
     905 *
     906 * @param int $forum_id Optional. Forum id
     907 * @return string Forum's last topic's title
     908 */
     909function bbp_get_forum_last_topic_title( $forum_id = 0 ) {
    896910    $forum_id = bbp_get_forum_id( $forum_id );
    897911    $topic_id = bbp_get_forum_last_topic_id( $forum_id );
    898     $title    = ! empty( $topic_id ) ? bbp_get_topic_title( $topic_id ) : '';
     912    $title    = ! empty( $topic_id )
     913        ? bbp_get_topic_title( $topic_id )
     914        : '';
    899915
    900916    // Filter & return
    901917    return apply_filters( 'bbp_get_forum_last_topic_title', $title, $forum_id );
    902     }
     918}
    903919
    904920/**
     
    912928    echo esc_url( bbp_get_forum_last_topic_permalink( $forum_id ) );
    913929}
    914     /**
    915      * Return the link to the last topic in a forum
    916      *
    917      * @since 2.0.0 bbPress (r2464)
    918      *
    919      * @param int $forum_id Optional. Forum id
    920      * @return string Permanent link to topic
    921      */
    922     function bbp_get_forum_last_topic_permalink( $forum_id = 0 ) {
     930
     931/**
     932 * Return the link to the last topic in a forum
     933 *
     934 * @since 2.0.0 bbPress (r2464)
     935 *
     936 * @param int $forum_id Optional. Forum id
     937 * @return string Permanent link to topic
     938 */
     939function bbp_get_forum_last_topic_permalink( $forum_id = 0 ) {
    923940    $forum_id = bbp_get_forum_id( $forum_id );
    924941    $topic_id = bbp_get_forum_last_topic_id( $forum_id );
     
    927944    // Filter & return
    928945    return apply_filters( 'bbp_get_forum_last_topic_permalink', $link, $forum_id, $topic_id );
    929     }
     946}
    930947
    931948/**
     
    956973    echo bbp_get_forum_last_topic_author_link( $forum_id );
    957974}
    958     /**
    959      * Return link to author of last topic of forum
    960      *
    961      * @since 2.0.0 bbPress (r2625)
    962      *
    963      * @param int $forum_id Optional. Forum id
    964      * @return string Forum's last topic's author link
    965      */
    966     function bbp_get_forum_last_topic_author_link( $forum_id = 0 ) {
     975
     976/**
     977 * Return link to author of last topic of forum
     978 *
     979 * @since 2.0.0 bbPress (r2625)
     980 *
     981 * @param int $forum_id Optional. Forum id
     982 * @return string Forum's last topic's author link
     983 */
     984function bbp_get_forum_last_topic_author_link( $forum_id = 0 ) {
    967985    $forum_id    = bbp_get_forum_id( $forum_id );
    968986    $author_id   = bbp_get_forum_last_topic_author_id( $forum_id );
     
    971989    // Filter & return
    972990    return apply_filters( 'bbp_get_forum_last_topic_author_link', $author_link, $forum_id );
    973     }
     991}
    974992
    975993/** Forum Last Reply **********************************************************/
     
    9851003    echo bbp_get_forum_last_reply_id( $forum_id );
    9861004}
    987     /**
    988      * Return the forums last reply id
    989      *
    990      * @since 2.0.0 bbPress (r2464)
    991      *
    992      * @param int $forum_id Optional. Forum id
    993      * @return int Forum's last reply id
    994      */
    995     function bbp_get_forum_last_reply_id( $forum_id = 0 ) {
     1005
     1006/**
     1007 * Return the forums last reply id
     1008 *
     1009 * @since 2.0.0 bbPress (r2464)
     1010 *
     1011 * @param int $forum_id Optional. Forum id
     1012 * @return int Forum's last reply id
     1013 */
     1014function bbp_get_forum_last_reply_id( $forum_id = 0 ) {
    9961015    $forum_id = bbp_get_forum_id( $forum_id );
    9971016    $reply_id = (int) get_post_meta( $forum_id, '_bbp_last_reply_id', true );
     
    9991018    // Filter & return
    10001019    return (int) apply_filters( 'bbp_get_forum_last_reply_id', $reply_id, $forum_id );
    1001     }
     1020}
    10021021
    10031022/**
     
    10091028    echo bbp_get_forum_last_reply_title( $forum_id );
    10101029}
    1011     /**
    1012      * Return the title of the last reply inside a forum
    1013      *
    1014      * @param int $forum_id Optional. Forum id
    1015      * @return string
    1016      */
    1017     function bbp_get_forum_last_reply_title( $forum_id = 0 ) {
     1030
     1031/**
     1032 * Return the title of the last reply inside a forum
     1033 *
     1034 * @param int $forum_id Optional. Forum id
     1035 * @return string
     1036 */
     1037function bbp_get_forum_last_reply_title( $forum_id = 0 ) {
    10181038    $forum_id = bbp_get_forum_id( $forum_id );
    10191039    $reply_id = bbp_get_forum_last_reply_id( $forum_id );
     
    10221042    // Filter & return
    10231043    return apply_filters( 'bbp_get_forum_last_reply_title', $title, $forum_id, $reply_id );
    1024     }
     1044}
    10251045
    10261046/**
     
    10341054    echo esc_url( bbp_get_forum_last_reply_permalink( $forum_id ) );
    10351055}
    1036     /**
    1037      * Return the link to the last reply in a forum
    1038      *
    1039      * @since 2.0.0 bbPress (r2464)
    1040      *
    1041      * @param int $forum_id Optional. Forum id
    1042      *
    1043      * @return string Permanent link to the forum's last reply
    1044      */
    1045     function bbp_get_forum_last_reply_permalink( $forum_id = 0 ) {
     1056
     1057/**
     1058 * Return the link to the last reply in a forum
     1059 *
     1060 * @since 2.0.0 bbPress (r2464)
     1061 *
     1062 * @param int $forum_id Optional. Forum id
     1063 *
     1064 * @return string Permanent link to the forum's last reply
     1065 */
     1066function bbp_get_forum_last_reply_permalink( $forum_id = 0 ) {
    10461067    $forum_id = bbp_get_forum_id( $forum_id );
    10471068    $reply_id = bbp_get_forum_last_reply_id( $forum_id );
     
    10501071    // Filter & return
    10511072    return apply_filters( 'bbp_get_forum_last_reply_permalink', $link, $forum_id, $reply_id );
    1052     }
     1073}
    10531074
    10541075/**
     
    10621083    echo esc_url( bbp_get_forum_last_reply_url( $forum_id ) );
    10631084}
    1064     /**
    1065      * Return the url to the last reply in a forum
    1066      *
    1067      * @since 2.0.0 bbPress (r2683)
    1068      *
    1069      * @param int $forum_id Optional. Forum id
    1070      * @return string Paginated URL to latest reply
    1071      */
    1072     function bbp_get_forum_last_reply_url( $forum_id = 0 ) {
     1085
     1086/**
     1087 * Return the url to the last reply in a forum
     1088 *
     1089 * @since 2.0.0 bbPress (r2683)
     1090 *
     1091 * @param int $forum_id Optional. Forum id
     1092 * @return string Paginated URL to latest reply
     1093 */
     1094function bbp_get_forum_last_reply_url( $forum_id = 0 ) {
    10731095    $forum_id = bbp_get_forum_id( $forum_id );
    10741096
     
    10781100        $reply_url = bbp_get_reply_url( $reply_id );
    10791101
    1080         // No replies, so look for topics and use last permalink
    1081         } else {
     1102    // No replies, so look for topics and use last permalink
     1103    } else {
    10821104        $reply_url = bbp_get_forum_last_topic_permalink( $forum_id );
    10831105
     
    10851107        if ( empty( $reply_url ) ) {
    10861108            $reply_url = '';
    1087             }
    10881109        }
     1110    }
    10891111
    10901112    // Filter & return
    10911113    return apply_filters( 'bbp_get_forum_last_reply_url', $reply_url, $forum_id, $reply_id );
    1092     }
     1114}
    10931115
    10941116/**
     
    11021124    echo bbp_get_forum_last_reply_author_id( $forum_id );
    11031125}
    1104     /**
    1105      * Return author ID of last reply of forum
    1106      *
    1107      * @since 2.0.0 bbPress (r2625)
    1108      *
    1109      * @param int $forum_id Optional. Forum id
    1110      * @return int Forum's last reply author id
    1111      */
    1112     function bbp_get_forum_last_reply_author_id( $forum_id = 0 ) {
     1126
     1127/**
     1128 * Return author ID of last reply of forum
     1129 *
     1130 * @since 2.0.0 bbPress (r2625)
     1131 *
     1132 * @param int $forum_id Optional. Forum id
     1133 * @return int Forum's last reply author id
     1134 */
     1135function bbp_get_forum_last_reply_author_id( $forum_id = 0 ) {
    11131136    $forum_id  = bbp_get_forum_id( $forum_id );
    11141137    $reply_id  = bbp_get_forum_last_reply_id( $forum_id );
     
    11171140    // Filter & return
    11181141    return apply_filters( 'bbp_get_forum_last_reply_author_id', $author_id, $forum_id, $reply_id );
    1119     }
     1142}
    11201143
    11211144/**
     
    11291152    echo bbp_get_forum_last_reply_author_link( $forum_id );
    11301153}
    1131     /**
    1132      * Return link to author of last reply of forum
    1133      *
    1134      * @since 2.0.0 bbPress (r2625)
    1135      *
    1136      * @param int $forum_id Optional. Forum id
    1137      * @return string Link to author of last reply of forum
    1138      */
    1139     function bbp_get_forum_last_reply_author_link( $forum_id = 0 ) {
     1154
     1155/**
     1156 * Return link to author of last reply of forum
     1157 *
     1158 * @since 2.0.0 bbPress (r2625)
     1159 *
     1160 * @param int $forum_id Optional. Forum id
     1161 * @return string Link to author of last reply of forum
     1162 */
     1163function bbp_get_forum_last_reply_author_link( $forum_id = 0 ) {
    11401164    $forum_id    = bbp_get_forum_id( $forum_id );
    11411165    $author_id   = bbp_get_forum_last_reply_author_id( $forum_id );
     
    11441168    // Filter & return
    11451169    return apply_filters( 'bbp_get_forum_last_reply_author_link', $author_link, $forum_id, $author_id );
    1146     }
     1170}
    11471171
    11481172/** Forum Counts **************************************************************/
     
    11591183}
    11601184
    1161     /**
    1162     * Return the topics link of the forum
    1163     *
    1164     * @since 2.0.0 bbPress (r2883)
    1165     *
    1166     * @param int $forum_id Optional. Topic id
    1167     */
    1168     function bbp_get_forum_topics_link( $forum_id = 0 ) {
     1185/**
     1186 * Return the topics link of the forum
     1187 *
     1188 * @since 2.0.0 bbPress (r2883)
     1189 *
     1190 * @param int $forum_id Optional. Topic id
     1191 */
     1192function bbp_get_forum_topics_link( $forum_id = 0 ) {
    11691193    $forum_id = bbp_get_forum_id( $forum_id );
    11701194    $link     = bbp_get_forum_permalink( $forum_id );
     1195    /* translators: %s: Number of topics */
    11711196    $topics   = sprintf( _n( '%s topic', '%s topics', bbp_get_forum_topic_count( $forum_id, true, true ), 'bbpress' ), bbp_get_forum_topic_count( $forum_id, true, false ) );
    11721197
    11731198    // First link never has view=all
    11741199    $retval = bbp_get_view_all( 'edit_others_topics' )
    1175     ? "<a href='" . esc_url( bbp_remove_view_all( $link ) ) . "'>" . esc_html( $topics ) . '</a>'
    1176     : esc_html( $topics );
     1200        ? "<a href='" . esc_url( bbp_remove_view_all( $link ) ) . "'>" . esc_html( $topics ) . '</a>'
     1201        : esc_html( $topics );
    11771202
    11781203    // Get deleted topics
     
    11841209        // Hidden text
    11851210        $deleted_num = bbp_get_forum_topic_count_hidden( $forum_id, false, false );
     1211        /* translators: %s: Number of hidden topics */
    11861212        $extra       = ' ' . sprintf( _n( '(+%s hidden)', '(+%s hidden)', $deleted_int, 'bbpress' ), $deleted_num );
    11871213
     
    11901216            ? " <a href='" . esc_url( bbp_add_view_all( $link, true ) ) . "'>" . esc_html( $extra ) . '</a>'
    11911217            : " {$extra}";
    1192         }
     1218    }
    11931219
    11941220    // Filter & return
    11951221    return apply_filters( 'bbp_get_forum_topics_link', $retval, $forum_id );
    1196     }
     1222}
    11971223
    11981224/**
     
    12071233    echo bbp_get_forum_subforum_count( $forum_id, $integer );
    12081234}
    1209     /**
    1210      * Return total subforum count of a forum
    1211      *
    1212      * @since 2.0.0 bbPress (r2464)
    1213      *
    1214      * @param int $forum_id Optional. Forum id
    1215      * @param boolean $integer Optional. Whether or not to format the result
    1216      * @return int Forum's subforum count
    1217      */
    1218     function bbp_get_forum_subforum_count( $forum_id = 0, $integer = false ) {
     1235
     1236/**
     1237 * Return total subforum count of a forum
     1238 *
     1239 * @since 2.0.0 bbPress (r2464)
     1240 *
     1241 * @param int $forum_id Optional. Forum id
     1242 * @param boolean $integer Optional. Whether or not to format the result
     1243 * @return int Forum's subforum count
     1244 */
     1245function bbp_get_forum_subforum_count( $forum_id = 0, $integer = false ) {
    12191246    $forum_id    = bbp_get_forum_id( $forum_id );
    12201247    $forum_count = (int) get_post_meta( $forum_id, '_bbp_forum_subforum_count', true );
    12211248    $filter      = ( true === $integer )
    1222     ? 'bbp_get_forum_subforum_count_int'
    1223     : 'bbp_get_forum_subforum_count';
     1249        ? 'bbp_get_forum_subforum_count_int'
     1250        : 'bbp_get_forum_subforum_count';
    12241251
    12251252    return apply_filters( $filter, $forum_count, $forum_id );
    1226     }
     1253}
    12271254
    12281255/**
     
    12381265    echo bbp_get_forum_topic_count( $forum_id, $total_count, $integer );
    12391266}
    1240     /**
    1241      * Return total topic count of a forum
    1242      *
    1243      * @since 2.0.0 bbPress (r2464)
    1244      *
    1245      * @param int $forum_id Optional. Forum id
    1246      * @param bool $total_count Optional. To get the total count or normal
    1247      *                           count? Defaults to total.
    1248      * @param boolean $integer Optional. Whether or not to format the result
    1249      * @return int Forum topic count
    1250      */
    1251     function bbp_get_forum_topic_count( $forum_id = 0, $total_count = true, $integer = false ) {
     1267
     1268/**
     1269 * Return total topic count of a forum
     1270 *
     1271 * @since 2.0.0 bbPress (r2464)
     1272 *
     1273 * @param int $forum_id Optional. Forum id
     1274 * @param bool $total_count Optional. To get the total count or normal
     1275 *                           count? Defaults to total.
     1276 * @param boolean $integer Optional. Whether or not to format the result
     1277 * @return int Forum topic count
     1278 */
     1279function bbp_get_forum_topic_count( $forum_id = 0, $total_count = true, $integer = false ) {
    12521280    $forum_id = bbp_get_forum_id( $forum_id );
    12531281    $meta_key = empty( $total_count ) ? '_bbp_topic_count' : '_bbp_total_topic_count';
    12541282    $topics   = (int) get_post_meta( $forum_id, $meta_key, true );
    12551283    $filter   = ( true === $integer )
    1256     ? 'bbp_get_forum_topic_count_int'
    1257     : 'bbp_get_forum_topic_count';
     1284        ? 'bbp_get_forum_topic_count_int'
     1285        : 'bbp_get_forum_topic_count';
    12581286
    12591287    return apply_filters( $filter, $topics, $forum_id );
    1260     }
     1288}
    12611289
    12621290/**
     
    12721300    echo bbp_get_forum_reply_count( $forum_id, $total_count, $integer );
    12731301}
    1274     /**
    1275      * Return total post count of a forum
    1276      *
    1277      * @since 2.0.0 bbPress (r2464)
    1278      *
    1279      * @param int $forum_id Optional. Forum id
    1280      * @param bool $total_count Optional. To get the total count or normal
    1281      *                           count?
    1282      * @param boolean $integer Optional. Whether or not to format the result
    1283      * @return int Forum reply count
    1284      */
    1285     function bbp_get_forum_reply_count( $forum_id = 0, $total_count = true, $integer = false ) {
     1302
     1303/**
     1304 * Return total post count of a forum
     1305 *
     1306 * @since 2.0.0 bbPress (r2464)
     1307 *
     1308 * @param int $forum_id Optional. Forum id
     1309 * @param bool $total_count Optional. To get the total count or normal
     1310 *                           count?
     1311 * @param boolean $integer Optional. Whether or not to format the result
     1312 * @return int Forum reply count
     1313 */
     1314function bbp_get_forum_reply_count( $forum_id = 0, $total_count = true, $integer = false ) {
    12861315    $forum_id = bbp_get_forum_id( $forum_id );
    12871316    $meta_key = empty( $total_count ) ? '_bbp_reply_count' : '_bbp_total_reply_count';
    12881317    $replies  = (int) get_post_meta( $forum_id, $meta_key, true );
    12891318    $filter   = ( true === $integer )
    1290     ? 'bbp_get_forum_reply_count_int'
    1291     : 'bbp_get_forum_reply_count';
     1319        ? 'bbp_get_forum_reply_count_int'
     1320        : 'bbp_get_forum_reply_count';
    12921321
    12931322    return apply_filters( $filter, $replies, $forum_id );
    1294     }
     1323}
    12951324
    12961325/**
     
    13061335    echo bbp_get_forum_post_count( $forum_id, $total_count, $integer );
    13071336}
    1308     /**
    1309      * Return total post count of a forum
    1310      *
    1311      * @since 2.0.0 bbPress (r2954)
    1312      *
    1313      * @param int $forum_id Optional. Forum id
    1314      * @param bool $total_count Optional. To get the total count or normal
    1315      *                           count?
    1316      * @param boolean $integer Optional. Whether or not to format the result
    1317      * @return int Forum post count
    1318      */
    1319     function bbp_get_forum_post_count( $forum_id = 0, $total_count = true, $integer = false ) {
     1337
     1338/**
     1339 * Return total post count of a forum
     1340 *
     1341 * @since 2.0.0 bbPress (r2954)
     1342 *
     1343 * @param int $forum_id Optional. Forum id
     1344 * @param bool $total_count Optional. To get the total count or normal
     1345 *                           count?
     1346 * @param boolean $integer Optional. Whether or not to format the result
     1347 * @return int Forum post count
     1348 */
     1349function bbp_get_forum_post_count( $forum_id = 0, $total_count = true, $integer = false ) {
    13201350    $forum_id = bbp_get_forum_id( $forum_id );
    13211351    $topics   = bbp_get_forum_topic_count( $forum_id, $total_count, true );
     
    13231353    $retval   = ( $replies + $topics );
    13241354    $filter   = ( true === $integer )
    1325     ? 'bbp_get_forum_post_count_int'
    1326     : 'bbp_get_forum_post_count';
     1355        ? 'bbp_get_forum_post_count_int'
     1356        : 'bbp_get_forum_post_count';
    13271357
    13281358    return apply_filters( $filter, $retval, $forum_id );
    1329     }
     1359}
    13301360
    13311361/**
     
    13431373    echo bbp_get_forum_topic_count_hidden( $forum_id, $total_count, $integer );
    13441374}
    1345     /**
    1346      * Return total hidden topic count of a forum (hidden includes trashed,
    1347      * spammed and pending topics)
    1348      *
    1349      * @since 2.0.0 bbPress (r2883)
    1350      * @since 2.6.0 bbPress (r6922) Changed function signature to add total counts
    1351      *
    1352      * @param int $forum_id Optional. Forum id
    1353      * @param bool $total_count Optional. To get the total count or normal count?
    1354      * @param boolean $integer Optional. Whether or not to format the result
    1355      * @return int Topic hidden topic count
    1356      */
    1357     function bbp_get_forum_topic_count_hidden( $forum_id = 0, $total_count = true, $integer = null ) {
     1375
     1376/**
     1377 * Return total hidden topic count of a forum (hidden includes trashed,
     1378 * spammed and pending topics)
     1379 *
     1380 * @since 2.0.0 bbPress (r2883)
     1381 * @since 2.6.0 bbPress (r6922) Changed function signature to add total counts
     1382 *
     1383 * @param int $forum_id Optional. Forum id
     1384 * @param bool $total_count Optional. To get the total count or normal count?
     1385 * @param boolean $integer Optional. Whether or not to format the result
     1386 * @return int Topic hidden topic count
     1387 */
     1388function bbp_get_forum_topic_count_hidden( $forum_id = 0, $total_count = true, $integer = null ) {
    13581389    $forum_id = bbp_get_forum_id( $forum_id );
    13591390    $meta_key = empty( $total_count ) ? '_bbp_topic_count_hidden' : '_bbp_total_topic_count_hidden';
    13601391    $topics   = (int) get_post_meta( $forum_id, $meta_key, true );
    13611392    $filter   = ( true === $integer )
    1362     ? 'bbp_get_forum_topic_count_hidden_int'
    1363     : 'bbp_get_forum_topic_count_hidden';
     1393        ? 'bbp_get_forum_topic_count_hidden_int'
     1394        : 'bbp_get_forum_topic_count_hidden';
    13641395
    13651396    return apply_filters( $filter, $topics, $forum_id );
    1366     }
     1397}
    13671398
    13681399/**
     
    13791410    echo bbp_get_forum_reply_count_hidden( $forum_id, $total_count, $integer );
    13801411}
    1381     /**
    1382      * Return total hidden reply count of a forum (hidden includes trashed,
    1383      * spammed and pending replies)
    1384      *
    1385      * @since 2.6.0 bbPress (r6922)
    1386      *
    1387      * @param int $forum_id Optional. Forum id
    1388      * @param bool $total_count Optional. To get the total count or normal
    1389      *                           count?
    1390      * @param boolean $integer Optional. Whether or not to format the result
    1391      * @return int Forum reply count
    1392      */
    1393     function bbp_get_forum_reply_count_hidden( $forum_id = 0, $total_count = true, $integer = false ) {
     1412
     1413/**
     1414 * Return total hidden reply count of a forum (hidden includes trashed,
     1415 * spammed and pending replies)
     1416 *
     1417 * @since 2.6.0 bbPress (r6922)
     1418 *
     1419 * @param int $forum_id Optional. Forum id
     1420 * @param bool $total_count Optional. To get the total count or normal
     1421 *                           count?
     1422 * @param boolean $integer Optional. Whether or not to format the result
     1423 * @return int Forum reply count
     1424 */
     1425function bbp_get_forum_reply_count_hidden( $forum_id = 0, $total_count = true, $integer = false ) {
    13941426    $forum_id = bbp_get_forum_id( $forum_id );
    13951427    $meta_key = empty( $total_count ) ? '_bbp_reply_count_hidden' : '_bbp_total_reply_count_hidden';
    13961428    $replies  = (int) get_post_meta( $forum_id, $meta_key, true );
    13971429    $filter   = ( true === $integer )
    1398     ? 'bbp_get_forum_reply_count_hidden_int'
    1399     : 'bbp_get_forum_reply_count_hidden';
     1430        ? 'bbp_get_forum_reply_count_hidden_int'
     1431        : 'bbp_get_forum_reply_count_hidden';
    14001432
    14011433    return apply_filters( $filter, $replies, $forum_id );
    1402     }
     1434}
    14031435
    14041436/**
     
    14121444    echo bbp_get_forum_status( $forum_id );
    14131445}
    1414     /**
    1415      * Return the status of the forum
    1416      *
    1417      * @since 2.0.0 bbPress (r2667)
    1418      *
    1419      * @param int $forum_id Optional. Forum id
    1420      * @return string Status of forum
    1421      */
    1422     function bbp_get_forum_status( $forum_id = 0 ) {
     1446
     1447/**
     1448 * Return the status of the forum
     1449 *
     1450 * @since 2.0.0 bbPress (r2667)
     1451 *
     1452 * @param int $forum_id Optional. Forum id
     1453 * @return string Status of forum
     1454 */
     1455function bbp_get_forum_status( $forum_id = 0 ) {
    14231456    $forum_id = bbp_get_forum_id( $forum_id );
    14241457    $status   = get_post_meta( $forum_id, '_bbp_status', true );
     
    14261459    if ( empty( $status ) ) {
    14271460        $status = 'open';
    1428         }
     1461    }
    14291462
    14301463    // Filter & return
    14311464    return apply_filters( 'bbp_get_forum_status', $status, $forum_id );
    1432     }
     1465}
    14331466
    14341467/**
     
    14421475    echo bbp_get_forum_visibility( $forum_id );
    14431476}
    1444     /**
    1445      * Return the visibility of the forum
    1446      *
    1447      * @since 2.0.0 bbPress (r2997)
    1448      *
    1449      * @param int $forum_id Optional. Forum id
    1450      * @return string Status of forum
    1451      */
    1452     function bbp_get_forum_visibility( $forum_id = 0 ) {
     1477
     1478/**
     1479 * Return the visibility of the forum
     1480 *
     1481 * @since 2.0.0 bbPress (r2997)
     1482 *
     1483 * @param int $forum_id Optional. Forum id
     1484 * @return string Status of forum
     1485 */
     1486function bbp_get_forum_visibility( $forum_id = 0 ) {
    14531487    $forum_id   = bbp_get_forum_id( $forum_id );
    14541488    $visibility = get_post_status( $forum_id );
     
    14561490    // Filter & return
    14571491    return apply_filters( 'bbp_get_forum_visibility', $visibility, $forum_id );
    1458     }
     1492}
    14591493
    14601494/**
     
    14681502    echo bbp_get_forum_type( $forum_id );
    14691503}
    1470     /**
    1471      * Return the type of forum (category/forum/etc...)
    1472      *
    1473      * @since 2.1.0 bbPress (r3563)
    1474      *
    1475      * @param int $forum_id Optional. Forum id
    1476      * @return bool Whether the forum is a category or not
    1477      */
    1478     function bbp_get_forum_type( $forum_id = 0 ) {
     1504
     1505/**
     1506 * Return the type of forum (category/forum/etc...)
     1507 *
     1508 * @since 2.1.0 bbPress (r3563)
     1509 *
     1510 * @param int $forum_id Optional. Forum id
     1511 * @return bool Whether the forum is a category or not
     1512 */
     1513function bbp_get_forum_type( $forum_id = 0 ) {
    14791514    $forum_id = bbp_get_forum_id( $forum_id );
    14801515    $retval   = get_post_meta( $forum_id, '_bbp_forum_type', true );
     
    14821517    if ( empty( $retval ) ) {
    14831518        $retval = 'forum';
    1484         }
     1519    }
    14851520
    14861521    // Filter & return
    14871522    return apply_filters( 'bbp_get_forum_type', $retval, $forum_id );
    1488     }
     1523}
    14891524
    14901525/**
     
    17581793    echo bbp_get_forum_author_id( $forum_id );
    17591794}
    1760     /**
    1761      * Return the author ID of the forum
    1762      *
    1763      * @since 2.1.0 bbPress (r3675)
    1764      *
    1765      * @param int $forum_id Optional. Forum id
    1766      *
    1767      * @return string Author of forum
    1768      */
    1769     function bbp_get_forum_author_id( $forum_id = 0 ) {
     1795
     1796/**
     1797 * Return the author ID of the forum
     1798 *
     1799 * @since 2.1.0 bbPress (r3675)
     1800 *
     1801 * @param int $forum_id Optional. Forum id
     1802 *
     1803 * @return string Author of forum
     1804 */
     1805function bbp_get_forum_author_id( $forum_id = 0 ) {
    17701806    $forum_id  = bbp_get_forum_id( $forum_id );
    17711807    $author_id = get_post_field( 'post_author', $forum_id );
     
    17731809    // Filter & return
    17741810    return (int) apply_filters( 'bbp_get_forum_author_id', (int) $author_id, $forum_id );
    1775     }
     1811}
    17761812
    17771813/**
     
    17851821    echo bbp_get_forum_author_display_name( $forum_id );
    17861822}
    1787     /**
    1788      * Return the author of the forum
    1789      *
    1790      * @since 2.1.0 bbPress (r3675)
    1791      *
    1792      * @param int $forum_id Optional. Forum id
    1793      * @return string Author of forum
    1794      */
    1795     function bbp_get_forum_author_display_name( $forum_id = 0 ) {
     1823
     1824/**
     1825 * Return the author of the forum
     1826 *
     1827 * @since 2.1.0 bbPress (r3675)
     1828 *
     1829 * @param int $forum_id Optional. Forum id
     1830 * @return string Author of forum
     1831 */
     1832function bbp_get_forum_author_display_name( $forum_id = 0 ) {
    17961833    $forum_id  = bbp_get_forum_id( $forum_id );
    17971834    $author_id = bbp_get_forum_author_id( $forum_id );
     
    18001837    // Filter & return
    18011838    return apply_filters( 'bbp_get_forum_author_display_name', $author, $forum_id, $author_id );
    1802     }
     1839}
    18031840
    18041841/**
     
    18791916    echo bbp_get_forum_class( $forum_id, $classes );
    18801917}
    1881     /**
    1882      * Return the row class of a forum
    1883      *
    1884      * @since 2.0.0 bbPress (r2667)
    1885      *
    1886      * @param int $forum_id Optional. Forum ID
    1887      * @param array Extra classes you can pass when calling this function
    1888      * @return string Row class of the forum
    1889      */
    1890     function bbp_get_forum_class( $forum_id = 0, $classes = array() ) {
     1918
     1919/**
     1920 * Return the row class of a forum
     1921 *
     1922 * @since 2.0.0 bbPress (r2667)
     1923 *
     1924 * @param int $forum_id Optional. Forum ID
     1925 * @param array Extra classes you can pass when calling this function
     1926 * @return string Row class of the forum
     1927 */
     1928function bbp_get_forum_class( $forum_id = 0, $classes = array() ) {
    18911929    $bbp        = bbpress();
    18921930    $forum_id   = bbp_get_forum_id( $forum_id );
     
    18971935    $classes    = array_filter( (array) $classes );
    18981936    $count      = isset( $bbp->forum_query->current_post )
    1899     ? (int) $bbp->forum_query->current_post
    1900     : 1;
     1937        ? (int) $bbp->forum_query->current_post
     1938        : 1;
    19011939
    19021940    //  Stripes
    19031941    $even_odd = ( $count % 2 )
    1904     ? 'even'
    1905     : 'odd';
     1942        ? 'even'
     1943        : 'odd';
    19061944
    19071945    // User is moderator of forum
    19081946    $forum_moderator = ( bbp_is_user_forum_moderator( $author_id, $forum_id ) === $author_id )
    1909     ? 'forum-mod'
    1910     : '';
     1947        ? 'forum-mod'
     1948        : '';
    19111949
    19121950    // Is forum a non-postable category?
    19131951    $category = bbp_is_forum_category( $forum_id )
    1914     ? 'status-category'
    1915     : '';
     1952        ? 'status-category'
     1953        : '';
    19161954
    19171955    // Forum has children?
    19181956    $subs = bbp_get_forum_subforum_count( $forum_id )
    1919     ? 'bbp-has-subforums'
    1920     : '';
     1957        ? 'bbp-has-subforums'
     1958        : '';
    19211959
    19221960    // Forum has parent?
    19231961    $parent = ! empty( $parent_id )
    1924     ? 'bbp-parent-forum-' . $parent_id
    1925     : '';
     1962        ? 'bbp-parent-forum-' . $parent_id
     1963        : '';
    19261964
    19271965    // Get forum classes
    19281966    $forum_classes = array(
    1929     'loop-item-'            . $count,
    1930     'bbp-forum-status-'     . $status,
    1931     'bbp-forum-visibility-' . $visibility,
    1932     $even_odd,
    1933     $forum_moderator,
    1934     $category,
    1935     $subs,
    1936     $parent
     1967        'loop-item-'            . $count,
     1968        'bbp-forum-status-'     . $status,
     1969        'bbp-forum-visibility-' . $visibility,
     1970        $even_odd,
     1971        $forum_moderator,
     1972        $category,
     1973        $subs,
     1974        $parent
    19371975    );
    19381976
     
    19461984    // Return
    19471985    return 'class="' . implode( ' ', $new_classes ) . '"';
    1948     }
     1986}
    19491987
    19501988/** Single Forum **************************************************************/
     
    19611999    echo bbp_get_single_forum_description( $args );
    19622000}
    1963     /**
    1964      * Return a fancy description of the current forum, including total
    1965      * topics, total replies, and last activity.
    1966      *
    1967      * @since 2.0.0 bbPress (r2860)
    1968      *
    1969      * @param array $args This function supports these arguments:
    1970      *  - forum_id: Forum id
    1971      *  - before: Before the text
    1972      *  - after: After the text
    1973      *  - size: Size of the avatar
    1974      * @return string Filtered forum description
    1975      */
    1976     function bbp_get_single_forum_description( $args = array() ) {
     2001
     2002/**
     2003 * Return a fancy description of the current forum, including total
     2004 * topics, total replies, and last activity.
     2005 *
     2006 * @since 2.0.0 bbPress (r2860)
     2007 *
     2008 * @param array $args This function supports these arguments:
     2009 *  - forum_id: Forum id
     2010 *  - before: Before the text
     2011 *  - after: After the text
     2012 *  - size: Size of the avatar
     2013 * @return string Filtered forum description
     2014 */
     2015function bbp_get_single_forum_description( $args = array() ) {
    19772016
    19782017    // Parse arguments against default values
    19792018    $r = bbp_parse_args( $args, array(
    1980     'forum_id'  => 0,
    1981     'before'    => '<div class="bbp-template-notice info"><ul><li class="bbp-forum-description">',
    1982     'after'     => '</li></ul></div>',
    1983     'size'      => 14,
    1984     'feed'      => true
     2019        'forum_id'  => 0,
     2020        'before'    => '<div class="bbp-template-notice info"><ul><li class="bbp-forum-description">',
     2021        'after'     => '</li></ul></div>',
     2022        'size'      => 14,
     2023        'feed'      => true
    19852024    ), 'get_single_forum_description' );
    19862025
    1987 // Validate forum_id
    1988 $forum_id = bbp_get_forum_id( $r['forum_id'] );
    1989 
    1990 // Unhook the 'view all' query var adder
    1991 remove_filter( 'bbp_get_forum_permalink', 'bbp_add_view_all' );
    1992 
    1993 // Get some forum data
    1994 $tc_int      = bbp_get_forum_topic_count( $forum_id, true, true  );
    1995 $rc_int      = bbp_get_forum_reply_count( $forum_id, true, true  );
    1996 $topic_count = bbp_get_forum_topic_count( $forum_id, true, false );
    1997 $reply_count = bbp_get_forum_reply_count( $forum_id, true, false );
    1998 $last_active = bbp_get_forum_last_active_id( $forum_id );
    1999 
    2000 // Has replies
    2001 if ( ! empty( $reply_count ) ) {
    2002     $reply_text = sprintf( _n( '%s reply', '%s replies', $rc_int, 'bbpress' ), $reply_count );
    2003     }
    2004 
    2005 // Forum has active data
    2006 if ( ! empty( $last_active ) ) {
    2007     $topic_text      = bbp_get_forum_topics_link( $forum_id );
    2008     $time_since      = bbp_get_forum_freshness_link( $forum_id );
    2009     $last_updated_by = bbp_get_author_link( array( 'post_id' => $last_active, 'size' => $r['size'] ) );
     2026    // Validate forum_id
     2027    $forum_id = bbp_get_forum_id( $r['forum_id'] );
     2028
     2029    // Unhook the 'view all' query var adder
     2030    remove_filter( 'bbp_get_forum_permalink', 'bbp_add_view_all' );
     2031
     2032    // Get some forum data
     2033    $tc_int      = bbp_get_forum_topic_count( $forum_id, true, true  );
     2034    $rc_int      = bbp_get_forum_reply_count( $forum_id, true, true  );
     2035    $topic_count = bbp_get_forum_topic_count( $forum_id, true, false );
     2036    $reply_count = bbp_get_forum_reply_count( $forum_id, true, false );
     2037    $last_active = bbp_get_forum_last_active_id( $forum_id );
     2038
     2039    // Has replies
     2040    if ( ! empty( $reply_count ) ) {
     2041        /* translators: %s: Number of replies */
     2042        $reply_text = sprintf( _n( '%s reply', '%s replies', $rc_int, 'bbpress' ), $reply_count );
     2043    }
     2044
     2045    // Forum has active data
     2046    if ( ! empty( $last_active ) ) {
     2047        $topic_text      = bbp_get_forum_topics_link( $forum_id );
     2048        $time_since      = bbp_get_forum_freshness_link( $forum_id );
     2049        $last_updated_by = bbp_get_author_link( array( 'post_id' => $last_active, 'size' => $r['size'] ) );
    20102050
    20112051    // Forum has no last active data
    20122052    } else {
    2013     $topic_text      = sprintf( _n( '%s topic', '%s topics', $tc_int, 'bbpress' ), $topic_count );
    2014     }
    2015 
    2016 // Forum has active data
    2017 if ( ! empty( $last_active ) ) {
    2018 
    2019     // Has replies
    2020     if ( ! empty( $reply_count ) ) {
    2021         $retstr = bbp_is_forum_category( $forum_id )
    2022             ? sprintf( esc_html__( 'This category has %1$s, %2$s, and was last updated %3$s by %4$s.', 'bbpress' ), $topic_text, $reply_text, $time_since, $last_updated_by )
    2023             : sprintf( esc_html__( 'This forum has %1$s, %2$s, and was last updated %3$s by %4$s.',    'bbpress' ), $topic_text, $reply_text, $time_since, $last_updated_by );
     2053        /* translators: %s: Number of topics */
     2054        $topic_text      = sprintf( _n( '%s topic', '%s topics', $tc_int, 'bbpress' ), $topic_count );
     2055    }
     2056
     2057    // Forum has active data
     2058    if ( ! empty( $last_active ) ) {
     2059
     2060        // Has replies
     2061        if ( ! empty( $reply_count ) ) {
     2062            $retstr = bbp_is_forum_category( $forum_id )
     2063                /* translators: 1: Topics link, 2: Replies text, 3: Last update time, 4: Author link */
     2064                ? sprintf( esc_html__( 'This category has %1$s, %2$s, and was last updated %3$s by %4$s.', 'bbpress' ), $topic_text, $reply_text, $time_since, $last_updated_by )
     2065                /* translators: 1: Topics link, 2: Replies text, 3: Last update time, 4: Author link */
     2066                : sprintf( esc_html__( 'This forum has %1$s, %2$s, and was last updated %3$s by %4$s.',    'bbpress' ), $topic_text, $reply_text, $time_since, $last_updated_by );
    20242067
    20252068        // Only has topics
    20262069        } else {
     2070            $retstr = bbp_is_forum_category( $forum_id )
     2071                /* translators: 1: Topics link, 2: Last update time, 3: Author link */
     2072                ? sprintf( esc_html__( 'This category has %1$s, and was last updated %2$s by %3$s.', 'bbpress' ), $topic_text, $time_since, $last_updated_by )
     2073                /* translators: 1: Topics link, 2: Last update time, 3: Author link */
     2074                : sprintf( esc_html__( 'This forum has %1$s, and was last updated %2$s by %3$s.',    'bbpress' ), $topic_text, $time_since, $last_updated_by );
     2075        }
     2076
     2077    // Forum has no last active data (but does have topics & replies)
     2078    } elseif ( ! empty( $reply_count ) ) {
    20272079        $retstr = bbp_is_forum_category( $forum_id )
    2028         ? sprintf( esc_html__( 'This category has %1$s, and was last updated %2$s by %3$s.', 'bbpress' ), $topic_text, $time_since, $last_updated_by )
    2029         : sprintf( esc_html__( 'This forum has %1$s, and was last updated %2$s by %3$s.',    'bbpress' ), $topic_text, $time_since, $last_updated_by );
    2030         }
    2031 
    2032         // Forum has no last active data (but does have topics & replies)
    2033     } elseif ( ! empty( $reply_count ) ) {
    2034 $retstr = bbp_is_forum_category( $forum_id )
    2035 ? sprintf( esc_html__( 'This category has %1$s and %2$s.', 'bbpress' ), $topic_text, $reply_text )
    2036 : sprintf( esc_html__( 'This forum has %1$s and %2$s.',    'bbpress' ), $topic_text, $reply_text );
    2037 
    2038 // Forum has no last active data or replies (but does have topics)
     2080            /* translators: 1: Topics link, 2: Replies text */
     2081            ? sprintf( esc_html__( 'This category has %1$s and %2$s.', 'bbpress' ), $topic_text, $reply_text )
     2082            /* translators: 1: Topics link, 2: Replies text */
     2083            : sprintf( esc_html__( 'This forum has %1$s and %2$s.',    'bbpress' ), $topic_text, $reply_text );
     2084
     2085    // Forum has no last active data or replies (but does have topics)
    20392086    } elseif ( ! empty( $topic_count ) ) {
    2040     $retstr = bbp_is_forum_category( $forum_id )
    2041     ? sprintf( esc_html__( 'This category has %1$s.', 'bbpress' ), $topic_text )
    2042     : sprintf( esc_html__( 'This forum has %1$s.',    'bbpress' ), $topic_text );
     2087        $retstr = bbp_is_forum_category( $forum_id )
     2088            /* translators: 1: Topics link */
     2089            ? sprintf( esc_html__( 'This category has %1$s.', 'bbpress' ), $topic_text )
     2090            /* translators: 1: Topics link */
     2091            : sprintf( esc_html__( 'This forum has %1$s.',    'bbpress' ), $topic_text );
    20432092
    20442093    // Forum is empty
    20452094    } else {
    2046     $retstr = esc_html__( 'This forum is empty.', 'bbpress' );
    2047     }
    2048 
    2049 // Add the 'view all' filter back
    2050 add_filter( 'bbp_get_forum_permalink', 'bbp_add_view_all' );
    2051 
    2052 // Combine the elements together
    2053 $retstr = $r['before'] . $retstr . $r['after'];
    2054 
    2055 // Filter & return
    2056 return apply_filters( 'bbp_get_single_forum_description', $retstr, $r, $args );
    2057     }
     2095        $retstr = esc_html__( 'This forum is empty.', 'bbpress' );
     2096    }
     2097
     2098    // Add the 'view all' filter back
     2099    add_filter( 'bbp_get_forum_permalink', 'bbp_add_view_all' );
     2100
     2101    // Combine the elements together
     2102    $retstr = $r['before'] . $retstr . $r['after'];
     2103
     2104    // Filter & return
     2105    return apply_filters( 'bbp_get_single_forum_description', $retstr, $r, $args );
     2106}
    20582107
    20592108/** Forms *********************************************************************/
     
    20672116    echo bbp_get_form_forum_title();
    20682117}
    2069     /**
    2070      * Return the value of forum title field
    2071      *
    2072      * @since 2.1.0 bbPress (r3551)
    2073      *
    2074      * @return string Value of forum title field
    2075      */
    2076     function bbp_get_form_forum_title() {
     2118
     2119/**
     2120 * Return the value of forum title field
     2121 *
     2122 * @since 2.1.0 bbPress (r3551)
     2123 *
     2124 * @return string Value of forum title field
     2125 */
     2126function bbp_get_form_forum_title() {
    20772127
    20782128    // Get _POST data
     
    20802130        $forum_title = wp_unslash( $_POST['bbp_forum_title'] );
    20812131
    2082         // Get edit data
    2083         } elseif ( bbp_is_forum_edit() ) {
     2132    // Get edit data
     2133    } elseif ( bbp_is_forum_edit() ) {
    20842134        $forum_title = bbp_get_global_post_field( 'post_title', 'raw' );
    20852135
    2086         // No data
    2087         } else {
     2136    // No data
     2137    } else {
    20882138        $forum_title = '';
    2089         }
     2139    }
    20902140
    20912141    // Filter & return
    20922142    return apply_filters( 'bbp_get_form_forum_title', $forum_title );
    2093     }
     2143}
    20942144
    20952145/**
     
    21012151    echo bbp_get_form_forum_content();
    21022152}
    2103     /**
    2104      * Return the value of forum content field
    2105      *
    2106      * @since 2.1.0 bbPress (r3551)
    2107      *
    2108      * @return string Value of forum content field
    2109      */
    2110     function bbp_get_form_forum_content() {
     2153
     2154/**
     2155 * Return the value of forum content field
     2156 *
     2157 * @since 2.1.0 bbPress (r3551)
     2158 *
     2159 * @return string Value of forum content field
     2160 */
     2161function bbp_get_form_forum_content() {
    21112162
    21122163    // Get _POST data
     
    21142165        $forum_content = wp_unslash( $_POST['bbp_forum_content'] );
    21152166
    2116         // Get edit data
    2117         } elseif ( bbp_is_forum_edit() ) {
     2167    // Get edit data
     2168    } elseif ( bbp_is_forum_edit() ) {
    21182169        $forum_content = bbp_get_global_post_field( 'post_content', 'raw' );
    21192170
    2120         // No data
    2121         } else {
     2171    // No data
     2172    } else {
    21222173        $forum_content = '';
    2123         }
     2174    }
    21242175
    21252176    // Filter & return
    21262177    return apply_filters( 'bbp_get_form_forum_content', $forum_content );
    2127     }
     2178}
    21282179
    21292180/**
     
    21352186    echo bbp_get_form_forum_moderators();
    21362187}
    2137     /**
    2138      * Return value of forum moderators field
    2139      *
    2140      * @since 2.6.0 bbPress (r5837)
    2141      *
    2142      * @return string Value of forum mods field
    2143      */
    2144     function bbp_get_form_forum_moderators() {
     2188
     2189/**
     2190 * Return value of forum moderators field
     2191 *
     2192 * @since 2.6.0 bbPress (r5837)
     2193 *
     2194 * @return string Value of forum mods field
     2195 */
     2196function bbp_get_form_forum_moderators() {
    21452197
    21462198    // Default return value
     
    21512203        $forum_mods = wp_unslash( $_POST['bbp_moderators'] );
    21522204
    2153         // Get edit data
    2154         } elseif ( bbp_is_single_forum() || bbp_is_forum_edit() ) {
     2205    // Get edit data
     2206    } elseif ( bbp_is_single_forum() || bbp_is_forum_edit() ) {
    21552207
    21562208        // Get the forum ID
     
    21682220                if ( ! empty( $user_nicenames ) ) {
    21692221                    $forum_mods = implode( ', ', wp_list_pluck( $user_nicenames, 'user_nicename' ) );
    2170                     }
    21712222                }
    21722223            }
    21732224        }
     2225    }
    21742226
    21752227    // Filter & return
    21762228    return apply_filters( 'bbp_get_form_forum_moderators', $forum_mods );
    2177     }
     2229}
    21782230
    21792231/**
     
    21852237    echo bbp_get_form_forum_parent();
    21862238}
    2187     /**
    2188      * Return value of forum parent
    2189      *
    2190      * @since 2.1.0 bbPress (r3551)
    2191      *
    2192      * @return string Value of topic content field
    2193      */
    2194     function bbp_get_form_forum_parent() {
     2239
     2240/**
     2241 * Return value of forum parent
     2242 *
     2243 * @since 2.1.0 bbPress (r3551)
     2244 *
     2245 * @return string Value of topic content field
     2246 */
     2247function bbp_get_form_forum_parent() {
    21952248
    21962249    // Get _POST data
     
    21982251        $forum_parent = (int) $_POST['bbp_forum_id'];
    21992252
    2200         // Get edit data
    2201         } elseif ( bbp_is_forum_edit() ) {
     2253    // Get edit data
     2254    } elseif ( bbp_is_forum_edit() ) {
    22022255        $forum_parent = bbp_get_forum_parent_id();
    22032256
    2204         // No data
    2205         } else {
     2257    // No data
     2258    } else {
    22062259        $forum_parent = 0;
    2207         }
     2260    }
    22082261
    22092262    // Filter & return
    22102263    return apply_filters( 'bbp_get_form_forum_parent', $forum_parent );
    2211     }
     2264}
    22122265
    22132266/**
     
    22192272    echo bbp_get_form_forum_type();
    22202273}
    2221     /**
    2222      * Return value of forum type
    2223      *
    2224      * @since 2.1.0 bbPress (r3563)
    2225      *
    2226      * @return string Value of topic content field
    2227      */
    2228     function bbp_get_form_forum_type() {
     2274
     2275/**
     2276 * Return value of forum type
     2277 *
     2278 * @since 2.1.0 bbPress (r3563)
     2279 *
     2280 * @return string Value of topic content field
     2281 */
     2282function bbp_get_form_forum_type() {
    22292283
    22302284    // Get _POST data
     
    22322286        $forum_type = sanitize_key( $_POST['bbp_forum_type'] );
    22332287
    2234         // Get edit data
    2235         } elseif ( bbp_is_forum_edit() ) {
     2288    // Get edit data
     2289    } elseif ( bbp_is_forum_edit() ) {
    22362290        $forum_type = bbp_get_forum_type();
    22372291
    2238         // No data
    2239         } else {
     2292    // No data
     2293    } else {
    22402294        $forum_type = 'forum';
    2241         }
     2295    }
    22422296
    22432297    // Filter & return
    22442298    return apply_filters( 'bbp_get_form_forum_type', $forum_type );
    2245     }
     2299}
    22462300
    22472301/**
     
    22532307    echo bbp_get_form_forum_visibility();
    22542308}
    2255     /**
    2256      * Return value of forum visibility
    2257      *
    2258      * @since 2.1.0 bbPress (r3563)
    2259      *
    2260      * @return string Value of topic content field
    2261      */
    2262     function bbp_get_form_forum_visibility() {
     2309
     2310/**
     2311 * Return value of forum visibility
     2312 *
     2313 * @since 2.1.0 bbPress (r3563)
     2314 *
     2315 * @return string Value of topic content field
     2316 */
     2317function bbp_get_form_forum_visibility() {
    22632318
    22642319    // Get _POST data
     
    22662321        $forum_visibility = sanitize_key( $_POST['bbp_forum_visibility'] );
    22672322
    2268         // Get edit data
    2269         } elseif ( bbp_is_forum_edit() ) {
     2323    // Get edit data
     2324    } elseif ( bbp_is_forum_edit() ) {
    22702325        $forum_visibility = bbp_get_forum_visibility();
    22712326
    2272         // No data
    2273         } else {
     2327    // No data
     2328    } else {
    22742329        $forum_visibility = bbpress()->public_status_id;
    2275         }
     2330    }
    22762331
    22772332    // Filter & return
    22782333    return apply_filters( 'bbp_get_form_forum_visibility', $forum_visibility );
    2279     }
     2334}
    22802335
    22812336/**
     
    22872342    echo bbp_get_form_forum_subscribed();
    22882343}
    2289     /**
    2290      * Return checked value of forum subscription
    2291      *
    2292      * @since 2.5.0 bbPress (r5156)
    2293      *
    2294      * @return string Checked value of forum subscription
    2295      */
    2296     function bbp_get_form_forum_subscribed() {
     2344
     2345/**
     2346 * Return checked value of forum subscription
     2347 *
     2348 * @since 2.5.0 bbPress (r5156)
     2349 *
     2350 * @return string Checked value of forum subscription
     2351 */
     2352function bbp_get_form_forum_subscribed() {
    22972353
    22982354    // Default value
     
    23032359        $forum_subscribed = (bool) $_POST['bbp_forum_subscription'];
    23042360
    2305         // Get edit data
    2306         } elseif ( bbp_is_forum_edit() || bbp_is_reply_edit() ) {
     2361    // Get edit data
     2362    } elseif ( bbp_is_forum_edit() || bbp_is_reply_edit() ) {
    23072363        $post_author      = (int) bbp_get_global_post_field( 'post_author', 'raw' );
    23082364        $forum_subscribed = bbp_is_user_subscribed( $post_author, bbp_get_forum_id() );
    23092365
    2310         // Get current status
    2311         } elseif ( bbp_is_single_forum() ) {
     2366    // Get current status
     2367    } elseif ( bbp_is_single_forum() ) {
    23122368        $forum_subscribed = bbp_is_user_subscribed( bbp_get_current_user_id(), bbp_get_forum_id() );
    2313         }
     2369    }
    23142370
    23152371    // Get checked output
     
    23182374    // Filter & return
    23192375    return apply_filters( 'bbp_get_form_forum_subscribed', $checked, $forum_subscribed );
    2320     }
     2376}
    23212377
    23222378/** Form Dropdowns ************************************************************/
     
    23362392    echo bbp_get_form_forum_type_dropdown( $args );
    23372393}
    2338     /**
    2339      * Return the forum type dropdown
    2340      *
    2341      * @since 2.1.0 bbPress (r3563)
    2342      *
    2343      * @param $args This function supports these arguments:
    2344      *  - select_id: Select id. Defaults to bbp_forum_type
    2345      *  - tab: Deprecated. Tabindex
    2346      *  - forum_id: Forum id
    2347      *  - selected: Override the selected option
    2348      * @return string HTML select list for selecting forum type
    2349      */
    2350     function bbp_get_form_forum_type_dropdown( $args = array() ) {
     2394
     2395/**
     2396 * Return the forum type dropdown
     2397 *
     2398 * @since 2.1.0 bbPress (r3563)
     2399 *
     2400 * @param $args This function supports these arguments:
     2401 *  - select_id: Select id. Defaults to bbp_forum_type
     2402 *  - tab: Deprecated. Tabindex
     2403 *  - forum_id: Forum id
     2404 *  - selected: Override the selected option
     2405 * @return string HTML select list for selecting forum type
     2406 */
     2407function bbp_get_form_forum_type_dropdown( $args = array() ) {
    23512408
    23522409    // Backpat for handling passing of a forum ID as integer
     
    23542411        $forum_id = (int) $args;
    23552412        $args     = array();
    2356         } else {
     2413    } else {
    23572414        $forum_id = 0;
    2358         }
     2415    }
    23592416
    23602417    // Parse arguments against default values
    23612418    $r = bbp_parse_args( $args, array(
    2362     'select_id'    => 'bbp_forum_type',
    2363     'select_class' => 'bbp_dropdown',
    2364     'tab'          => false,
    2365     'forum_id'     => $forum_id,
    2366     'selected'     => false
     2419        'select_id'    => 'bbp_forum_type',
     2420        'select_class' => 'bbp_dropdown',
     2421        'tab'          => false,
     2422        'forum_id'     => $forum_id,
     2423        'selected'     => false
    23672424    ), 'forum_type_select' );
    23682425
    2369 // No specific selected value passed
    2370 if ( empty( $r['selected'] ) ) {
    2371 
    2372     // Post value is passed
    2373     if ( bbp_is_forum_form_post_request() && isset( $_POST[ $r['select_id'] ] ) ) {
    2374         $r['selected'] = sanitize_key( $_POST[ $r['select_id'] ] );
     2426    // No specific selected value passed
     2427    if ( empty( $r['selected'] ) ) {
     2428
     2429        // Post value is passed
     2430        if ( bbp_is_forum_form_post_request() && isset( $_POST[ $r['select_id'] ] ) ) {
     2431            $r['selected'] = sanitize_key( $_POST[ $r['select_id'] ] );
    23752432
    23762433        // No Post value was passed
    23772434        } else {
    23782435
    2379         // Edit topic
    2380         if ( bbp_is_forum_edit() ) {
    2381             $r['forum_id'] = bbp_get_forum_id( $r['forum_id'] );
    2382             $r['selected'] = bbp_get_forum_type( $r['forum_id'] );
     2436            // Edit topic
     2437            if ( bbp_is_forum_edit() ) {
     2438                $r['forum_id'] = bbp_get_forum_id( $r['forum_id'] );
     2439                $r['selected'] = bbp_get_forum_type( $r['forum_id'] );
    23832440
    23842441            // New topic
    23852442            } else {
    2386             $r['selected'] = bbp_get_public_status_id();
     2443                $r['selected'] = bbp_get_public_status_id();
    23872444            }
    2388             }
    2389     }
    2390 
    2391 // Start an output buffer, we'll finish it after the select loop
    2392 ob_start(); ?>
    2393 
    2394         <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'] ); ?>>
    2395 
    2396             <?php foreach ( bbp_get_forum_types( $r['forum_id'] ) as $key => $label ) : ?>
    2397 
    2398                 <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $r['selected'] ); ?>><?php echo esc_html( $label ); ?></option>
    2399 
    2400             <?php endforeach; ?>
    2401 
    2402         </select>
    2403 
    2404         <?php
    2405 
    2406         // Filter & return
    2407         return apply_filters( 'bbp_get_form_forum_type_dropdown', ob_get_clean(), $r, $args );
    2408     }
     2445        }
     2446    }
     2447
     2448    // Start an output buffer, we'll finish it after the select loop
     2449    ob_start(); ?>
     2450
     2451    <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'] ); ?>>
     2452
     2453        <?php foreach ( bbp_get_forum_types( $r['forum_id'] ) as $key => $label ) : ?>
     2454
     2455            <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $r['selected'] ); ?>><?php echo esc_html( $label ); ?></option>
     2456
     2457        <?php endforeach; ?>
     2458
     2459    </select>
     2460
     2461    <?php
     2462
     2463    // Filter & return
     2464    return apply_filters( 'bbp_get_form_forum_type_dropdown', ob_get_clean(), $r, $args );
     2465}
    24092466
    24102467/**
     
    24222479    echo bbp_get_form_forum_status_dropdown( $args );
    24232480}
    2424     /**
    2425      * Return the forum status dropdown
    2426      *
    2427      * @since 2.1.0 bbPress (r3563)
    2428      *
    2429      * @param $args This function supports these arguments:
    2430      *  - select_id: Select id. Defaults to bbp_forum_status
    2431      *  - tab: Deprecated. Tabindex
    2432      *  - forum_id: Forum id
    2433      *  - selected: Override the selected option
    2434      * @return string HTML select list for selecting forum status
    2435      */
    2436     function bbp_get_form_forum_status_dropdown( $args = array() ) {
     2481
     2482/**
     2483 * Return the forum status dropdown
     2484 *
     2485 * @since 2.1.0 bbPress (r3563)
     2486 *
     2487 * @param $args This function supports these arguments:
     2488 *  - select_id: Select id. Defaults to bbp_forum_status
     2489 *  - tab: Deprecated. Tabindex
     2490 *  - forum_id: Forum id
     2491 *  - selected: Override the selected option
     2492 * @return string HTML select list for selecting forum status
     2493 */
     2494function bbp_get_form_forum_status_dropdown( $args = array() ) {
    24372495
    24382496    // Backpat for handling passing of a forum ID
     
    24402498        $forum_id = (int) $args;
    24412499        $args     = array();
    2442         } else {
     2500    } else {
    24432501        $forum_id = 0;
    2444         }
     2502    }
    24452503
    24462504    // Parse arguments against default values
    24472505    $r = bbp_parse_args( $args, array(
    2448     'select_id'    => 'bbp_forum_status',
    2449     'select_class' => 'bbp_dropdown',
    2450     'tab'          => false,
    2451     'forum_id'     => $forum_id,
    2452     'selected'     => false
     2506        'select_id'    => 'bbp_forum_status',
     2507        'select_class' => 'bbp_dropdown',
     2508        'tab'          => false,
     2509        'forum_id'     => $forum_id,
     2510        'selected'     => false
    24532511    ), 'forum_status_select' );
    24542512
    2455 // No specific selected value passed
    2456 if ( empty( $r['selected'] ) ) {
    2457 
    2458     // Post value is passed
    2459     if ( bbp_is_forum_form_post_request() && isset( $_POST[ $r['select_id'] ] ) ) {
    2460         $r['selected'] = sanitize_key( $_POST[ $r['select_id'] ] );
     2513    // No specific selected value passed
     2514    if ( empty( $r['selected'] ) ) {
     2515
     2516        // Post value is passed
     2517        if ( bbp_is_forum_form_post_request() && isset( $_POST[ $r['select_id'] ] ) ) {
     2518            $r['selected'] = sanitize_key( $_POST[ $r['select_id'] ] );
    24612519
    24622520        // No Post value was passed
    24632521        } else {
    24642522
    2465         // Edit topic
    2466         if ( bbp_is_forum_edit() ) {
    2467             $r['forum_id'] = bbp_get_forum_id( $r['forum_id'] );
    2468             $r['selected'] = bbp_get_forum_status( $r['forum_id'] );
     2523            // Edit topic
     2524            if ( bbp_is_forum_edit() ) {
     2525                $r['forum_id'] = bbp_get_forum_id( $r['forum_id'] );
     2526                $r['selected'] = bbp_get_forum_status( $r['forum_id'] );
    24692527
    24702528            // New topic
    24712529            } else {
    2472             $r['selected'] = bbp_get_public_status_id();
     2530                $r['selected'] = bbp_get_public_status_id();
    24732531            }
    2474             }
    2475     }
    2476 
    2477 // Start an output buffer, we'll finish it after the select loop
    2478 ob_start(); ?>
    2479 
    2480         <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'] ); ?>>
    2481 
    2482             <?php foreach ( bbp_get_forum_statuses( $r['forum_id'] ) as $key => $label ) : ?>
    2483 
    2484                 <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $r['selected'] ); ?>><?php echo esc_html( $label ); ?></option>
    2485 
    2486             <?php endforeach; ?>
    2487 
    2488         </select>
    2489 
    2490         <?php
    2491 
    2492         // Filter & return
    2493         return apply_filters( 'bbp_get_form_forum_status_dropdown', ob_get_clean(), $r, $args );
    2494     }
     2532        }
     2533    }
     2534
     2535    // Start an output buffer, we'll finish it after the select loop
     2536    ob_start(); ?>
     2537
     2538    <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'] ); ?>>
     2539
     2540        <?php foreach ( bbp_get_forum_statuses( $r['forum_id'] ) as $key => $label ) : ?>
     2541
     2542            <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $r['selected'] ); ?>><?php echo esc_html( $label ); ?></option>
     2543
     2544        <?php endforeach; ?>
     2545
     2546    </select>
     2547
     2548    <?php
     2549
     2550    // Filter & return
     2551    return apply_filters( 'bbp_get_form_forum_status_dropdown', ob_get_clean(), $r, $args );
     2552}
    24952553
    24962554/**
     
    25082566    echo bbp_get_form_forum_visibility_dropdown( $args );
    25092567}
    2510     /**
    2511      * Return the forum visibility dropdown
    2512      *
    2513      * @since 2.1.0 bbPress (r3563)
    2514      *
    2515      * @param $args This function supports these arguments:
    2516      *  - select_id: Select id. Defaults to bbp_forum_visibility
    2517      *  - tab: Deprecated. Tabindex
    2518      *  - forum_id: Forum id
    2519      *  - selected: Override the selected option
    2520      * @return string HTML select list for selecting forum visibility
    2521      */
    2522     function bbp_get_form_forum_visibility_dropdown( $args = array() ) {
     2568
     2569/**
     2570 * Return the forum visibility dropdown
     2571 *
     2572 * @since 2.1.0 bbPress (r3563)
     2573 *
     2574 * @param $args This function supports these arguments:
     2575 *  - select_id: Select id. Defaults to bbp_forum_visibility
     2576 *  - tab: Deprecated. Tabindex
     2577 *  - forum_id: Forum id
     2578 *  - selected: Override the selected option
     2579 * @return string HTML select list for selecting forum visibility
     2580 */
     2581function bbp_get_form_forum_visibility_dropdown( $args = array() ) {
    25232582
    25242583    // Backpat for handling passing of a forum ID
     
    25262585        $forum_id = (int) $args;
    25272586        $args     = array();
    2528         } else {
     2587    } else {
    25292588        $forum_id = 0;
    2530         }
     2589    }
    25312590
    25322591    // Parse arguments against default values
    25332592    $r = bbp_parse_args( $args, array(
    2534     'select_id'    => 'bbp_forum_visibility',
    2535     'select_class' => 'bbp_dropdown',
    2536     'tab'          => false,
    2537     'forum_id'     => $forum_id,
    2538     'selected'     => false
     2593        'select_id'    => 'bbp_forum_visibility',
     2594        'select_class' => 'bbp_dropdown',
     2595        'tab'          => false,
     2596        'forum_id'     => $forum_id,
     2597        'selected'     => false
    25392598    ), 'forum_type_select' );
    25402599
    2541 // No specific selected value passed
    2542 if ( empty( $r['selected'] ) ) {
    2543 
    2544     // Post value is passed
    2545     if ( bbp_is_forum_form_post_request() && isset( $_POST[ $r['select_id'] ] ) ) {
    2546         $r['selected'] = sanitize_key( $_POST[ $r['select_id'] ] );
     2600    // No specific selected value passed
     2601    if ( empty( $r['selected'] ) ) {
     2602
     2603        // Post value is passed
     2604        if ( bbp_is_forum_form_post_request() && isset( $_POST[ $r['select_id'] ] ) ) {
     2605            $r['selected'] = sanitize_key( $_POST[ $r['select_id'] ] );
    25472606
    25482607        // No Post value was passed
    25492608        } else {
    25502609
    2551         // Edit topic
    2552         if ( bbp_is_forum_edit() ) {
    2553             $r['forum_id'] = bbp_get_forum_id( $r['forum_id'] );
    2554             $r['selected'] = bbp_get_forum_visibility( $r['forum_id'] );
     2610            // Edit topic
     2611            if ( bbp_is_forum_edit() ) {
     2612                $r['forum_id'] = bbp_get_forum_id( $r['forum_id'] );
     2613                $r['selected'] = bbp_get_forum_visibility( $r['forum_id'] );
    25552614
    25562615            // New topic
    25572616            } else {
    2558             $r['selected'] = bbp_get_public_status_id();
     2617                $r['selected'] = bbp_get_public_status_id();
    25592618            }
    2560             }
    2561     }
    2562 
    2563 // Start an output buffer, we'll finish it after the select loop
    2564 ob_start(); ?>
    2565 
    2566         <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'] ); ?>>
    2567 
    2568             <?php foreach ( bbp_get_forum_visibilities( $r['forum_id'] ) as $key => $label ) : ?>
    2569 
    2570                 <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $r['selected'] ); ?>><?php echo esc_html( $label ); ?></option>
    2571 
    2572             <?php endforeach; ?>
    2573 
    2574         </select>
    2575 
    2576         <?php
    2577 
    2578         // Filter & return
    2579         return apply_filters( 'bbp_get_form_forum_type_dropdown', ob_get_clean(), $r, $args );
    2580     }
     2619        }
     2620    }
     2621
     2622    // Start an output buffer, we'll finish it after the select loop
     2623    ob_start(); ?>
     2624
     2625    <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'] ); ?>>
     2626
     2627        <?php foreach ( bbp_get_forum_visibilities( $r['forum_id'] ) as $key => $label ) : ?>
     2628
     2629            <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $r['selected'] ); ?>><?php echo esc_html( $label ); ?></option>
     2630
     2631        <?php endforeach; ?>
     2632
     2633    </select>
     2634
     2635    <?php
     2636
     2637    // Filter & return
     2638    return apply_filters( 'bbp_get_form_forum_type_dropdown', ob_get_clean(), $r, $args );
     2639}
    25812640
    25822641/**
     
    26242683    echo bbp_get_forum_topics_feed_link( $forum_id );
    26252684}
    2626     /**
    2627      * Retrieve the link for the forum feed
    2628      *
    2629      * @since 2.0.0 bbPress (r3172)
    2630      *
    2631      * @param int $forum_id Optional. Forum ID.
    2632      *
    2633      * @return string
    2634      */
    2635     function bbp_get_forum_topics_feed_link( $forum_id = 0 ) {
     2685
     2686/**
     2687 * Retrieve the link for the forum feed
     2688 *
     2689 * @since 2.0.0 bbPress (r3172)
     2690 *
     2691 * @param int $forum_id Optional. Forum ID.
     2692 *
     2693 * @return string
     2694 */
     2695function bbp_get_forum_topics_feed_link( $forum_id = 0 ) {
    26362696
    26372697    // Validate forum id
     
    26522712
    26532713            // Unpretty permalinks
    2654             } else {
     2714        } else {
    26552715            $url = home_url( add_query_arg( array(
    2656             'feed'                    => 'rss2',
    2657             bbp_get_forum_post_type() => get_post_field( 'post_name', $forum_id )
     2716                'feed'                    => 'rss2',
     2717                bbp_get_forum_post_type() => get_post_field( 'post_name', $forum_id )
    26582718            ) ) );
    2659             }
     2719        }
    26602720
    26612721        $link = '<a href="' . esc_url( $url ) . '" class="bbp-forum-rss-link topics"><span>' . esc_attr__( 'Topics', 'bbpress' ) . '</span></a>';
    2662         }
     2722    }
    26632723
    26642724    // Filter & return
    26652725    return apply_filters( 'bbp_get_forum_topics_feed_link', $link, $url, $forum_id );
    2666     }
     2726}
    26672727
    26682728/**
     
    26762736    echo bbp_get_forum_replies_feed_link( $forum_id );
    26772737}
    2678     /**
    2679      * Retrieve the link for the forum replies feed
    2680      *
    2681      * @since 2.0.0 bbPress (r3172)
    2682      *
    2683      * @param int $forum_id Optional. Forum ID.
    2684      *
    2685      * @return string
    2686      */
    2687     function bbp_get_forum_replies_feed_link( $forum_id = 0 ) {
     2738
     2739/**
     2740 * Retrieve the link for the forum replies feed
     2741 *
     2742 * @since 2.0.0 bbPress (r3172)
     2743 *
     2744 * @param int $forum_id Optional. Forum ID.
     2745 *
     2746 * @return string
     2747 */
     2748function bbp_get_forum_replies_feed_link( $forum_id = 0 ) {
    26882749
    26892750    // Validate forum id
     
    27042765            $url = add_query_arg( array( 'type' => 'reply' ), $url );
    27052766
    2706             // Unpretty permalinks
    2707             } else {
     2767        // Unpretty permalinks
     2768        } else {
    27082769            $url = home_url( add_query_arg( array(
    2709             'type'                    => 'reply',
    2710             'feed'                    => 'rss2',
    2711             bbp_get_forum_post_type() => get_post_field( 'post_name', $forum_id )
     2770                'type'                    => 'reply',
     2771                'feed'                    => 'rss2',
     2772                bbp_get_forum_post_type() => get_post_field( 'post_name', $forum_id )
    27122773            ) ) );
    2713             }
     2774        }
    27142775
    27152776        $link = '<a href="' . esc_url( $url ) . '" class="bbp-forum-rss-link replies"><span>' . esc_html__( 'Replies', 'bbpress' ) . '</span></a>';
    2716         }
     2777    }
    27172778
    27182779    // Filter & return
    27192780    return apply_filters( 'bbp_get_forum_replies_feed_link', $link, $url, $forum_id );
    2720     }
     2781}
  • trunk/src/includes/replies/functions.php

    r7357 r7360  
    507507    // WP_Error
    508508    } elseif ( is_wp_error( $reply_id ) ) {
     509        /* translators: %s: Error message(s) */
    509510        bbp_add_error( 'bbp_reply_error', sprintf( __( '<strong>Error</strong>: The following problem(s) occurred: %s', 'bbpress' ), $reply_id->get_error_message() ) );
    510511
     
    824825
    825826    } else {
    826         $append_error = ( is_wp_error( $reply_id ) && $reply_id->get_error_message() ) ? $reply_id->get_error_message() . ' ' : '';
     827        $append_error = ( is_wp_error( $reply_id ) && $reply_id->get_error_message() )
     828            ? $reply_id->get_error_message() . ' '
     829            : '';
     830
     831        /* translators: %s: Error message(s) */
    827832        bbp_add_error( 'bbp_reply_error', sprintf( __( '<strong>Error</strong>: The following problem(s) have been found with your reply: %s. Please try again.', 'bbpress' ) ), $append_error );
    828833    }
     
    22412246                        <description>
    22422247                            <![CDATA[
    2243                             <p><?php printf( __( 'Replies: %s', 'bbpress' ), bbp_get_topic_reply_count() ); ?></p>
     2248                            <p>
     2249                                <?php
     2250                                printf(
     2251                                    /* translators: %s: Number of replies */
     2252                                    __( 'Replies: %s', 'bbpress' ),
     2253                                    bbp_get_topic_reply_count()
     2254                                    );
     2255                                ?>
     2256                            </p>
    22442257                            <?php bbp_topic_content(); ?>
    22452258                            ]]>
  • 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 .= '&hellip;';
    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/**
  • trunk/src/includes/search/template.php

    r7357 r7360  
    174174        // Include search terms in title
    175175        } else {
     176            /* translators: %s: Search query terms */
    176177            $title = sprintf( esc_html__( "Search Results for '%s'", 'bbpress' ), esc_attr( $search_terms ) );
    177178        }
     
    381382}
    382383
    383     /**
    384      * Return the search results pagination count
    385      *
    386      * @since 2.3.0 bbPress (r4579)
    387      *
    388      * @return string Search pagination count
    389      */
    390     function bbp_get_search_pagination_count() {
    391         $bbp = bbpress();
    392 
    393         // Define local variable(s)
    394         $retstr = '';
    395 
    396         // Set pagination values
    397         $total_int = intval( $bbp->search_query->found_posts    );
    398         $ppp_int   = intval( $bbp->search_query->posts_per_page );
    399         $start_int = intval( ( $bbp->search_query->paged - 1 ) * $ppp_int ) + 1;
    400         $to_int    = intval( ( $start_int + ( $ppp_int - 1 ) > $total_int )
    401                 ? $total_int
    402                 : $start_int + ( $ppp_int - 1 ) );
    403 
    404         // Format numbers for display
    405         $total_num = bbp_number_format( $total_int );
    406         $from_num  = bbp_number_format( $start_int );
    407         $to_num    = bbp_number_format( $to_int    );
    408 
    409         // Single page of results
    410         if ( empty( $to_num ) ) {
    411             $retstr = sprintf( _n( 'Viewing %1$s result', 'Viewing %1$s results', $total_int, 'bbpress' ), $total_num );
    412 
    413         // Several pages of results
    414         } else {
    415             $retstr = sprintf( _n( 'Viewing %2$s results (of %4$s total)', 'Viewing %1$s results - %2$s through %3$s (of %4$s total)', $bbp->search_query->post_count, 'bbpress' ), $bbp->search_query->post_count, $from_num, $to_num, $total_num );  //phpcs:ignore
    416         }
     384/**
     385 * Return the search results pagination count
     386 *
     387 * @since 2.3.0 bbPress (r4579)
     388 *
     389 * @return string Search pagination count
     390 */
     391function bbp_get_search_pagination_count() {
     392    $bbp = bbpress();
     393
     394    // Define local variable(s)
     395    $retstr = '';
     396
     397    // Set pagination values
     398    $total_int = intval( $bbp->search_query->found_posts    );
     399    $ppp_int   = intval( $bbp->search_query->posts_per_page );
     400    $start_int = intval( ( $bbp->search_query->paged - 1 ) * $ppp_int ) + 1;
     401    $to_int    = intval( ( $start_int + ( $ppp_int - 1 ) > $total_int )
     402            ? $total_int
     403            : $start_int + ( $ppp_int - 1 ) );
     404
     405    // Format numbers for display
     406    $total_num = bbp_number_format( $total_int );
     407    $from_num  = bbp_number_format( $start_int );
     408    $to_num    = bbp_number_format( $to_int    );
     409
     410    // Single page of results
     411    if ( empty( $to_num ) ) {
     412        $retstr = sprintf(
     413            /* translators: %1$s: Number of results */
     414            _n( 'Viewing %1$s result', 'Viewing %1$s results', $total_int, 'bbpress' ),
     415            $total_num
     416        );
     417
     418    // Several pages of results
     419    } else {
     420        $retstr = sprintf(
     421            /* translators: 1: Number of results being viewed, 2: First result number, 3: Last result number, 4: Total results */
     422            _n(
     423                'Viewing %1$s result - %2$s through %3$s (of %4$s total)',
     424                'Viewing %1$s results - %2$s through %3$s (of %4$s total)',
     425                $bbp->search_query->post_count,
     426                'bbpress'
     427            ),
     428            $bbp->search_query->post_count,
     429            $from_num,
     430            $to_num,
     431            $total_num
     432        );
    417433
    418434        // Filter & return
    419435        return apply_filters( 'bbp_get_search_pagination_count', esc_html( $retstr ) );
    420436    }
     437}
    421438
    422439/**
  • trunk/src/includes/topics/functions.php

    r7357 r7360  
    413413    // WP_Error
    414414    } elseif ( is_wp_error( $topic_id ) ) {
     415        /* translators: %s: Error message(s) */
    415416        bbp_add_error( 'bbp_topic_error', sprintf( __( '<strong>Error</strong>: The following problem(s) occurred: %s', 'bbpress' ), $topic_id->get_error_message() ) );
    416417
     
    760761    } else {
    761762        $append_error = ( is_wp_error( $topic_id ) && $topic_id->get_error_message() ) ? $topic_id->get_error_message() . ' ' : '';
     763        /* translators: %s: Error message(s) */
    762764        bbp_add_error( 'bbp_topic_error', sprintf( esc_html_e( '<strong>Error</strong>: The following problem(s) have been found with your topic: %s. Please try again.', 'bbpress' ) ), $append_error );
    763765    }
     
    17461748    // Tag does not exist
    17471749    if ( is_wp_error( $tag ) && $tag->get_error_message() ) {
     1750        /* translators: %s: Error message(s) */
    17481751        bbp_add_error( 'bbp_manage_topic_invalid_tag', sprintf( __( '<strong>Error</strong>: The following problem(s) have been found while getting the tag: %s', 'bbpress' ), $tag->get_error_message() ) );
    17491752        return;
     
    17851788            // Cannot update tag
    17861789            if ( is_wp_error( $tag ) && $tag->get_error_message() ) {
     1790                /* translators: %s: Error message(s) */
    17871791                bbp_add_error( 'bbp_manage_topic_tag_update_error', sprintf( __( '<strong>Error</strong>: The following problem(s) have been found while updating the tag: %s', 'bbpress' ), $tag->get_error_message() ) );
    17881792                return;
     
    18251829            // Problem inserting the new term
    18261830            if ( is_wp_error( $tag ) && $tag->get_error_message() ) {
     1831                /* translators: %s: Error message(s) */
    18271832                bbp_add_error( 'bbp_manage_topic_tag_merge_error', sprintf( __( '<strong>Error</strong>: The following problem(s) have been found while merging the tags: %s', 'bbpress' ), $tag->get_error_message() ) );
    18281833                return;
     
    18461851            // Error merging the terms
    18471852            if ( is_wp_error( $tag ) && $tag->get_error_message() ) {
     1853                /* translators: %s: Error message(s) */
    18481854                bbp_add_error( 'bbp_manage_topic_tag_merge_error', sprintf( __( '<strong>Error</strong>: The following problem(s) have been found while merging the tags: %s', 'bbpress' ), $tag->get_error_message() ) );
    18491855                return;
     
    18781884            // Error deleting term
    18791885            if ( is_wp_error( $tag ) && $tag->get_error_message() ) {
     1886                /* translators: %s: Error message(s) */
    18801887                bbp_add_error( 'bbp_manage_topic_tag_delete_error', sprintf( __( '<strong>Error</strong>: The following problem(s) have been found while deleting the tag: %s', 'bbpress' ), $tag->get_error_message() ) );
    18811888                return;
     
    38563863                    <description>
    38573864                        <![CDATA[
    3858                         <p><?php printf( esc_html__( 'Replies: %s', 'bbpress' ), bbp_get_topic_reply_count() ); ?></p>
     3865                        <p>
     3866                            <?php
     3867                            printf(
     3868                                /* translators: %s: Number of replies to the topic */
     3869                                esc_html__( 'Replies: %s', 'bbpress' ),
     3870                                bbp_get_topic_reply_count()
     3871                            );
     3872                            ?>
     3873                        </p>
    38593874                        <?php bbp_topic_content(); ?>
    38603875                        ]]>
  • trunk/src/includes/topics/template.php

    r7357 r7360  
    764764            $date   = get_post_time( get_option( 'date_format' ), $gmt, $topic_id, true );
    765765            $time   = get_post_time( get_option( 'time_format' ), $gmt, $topic_id, true );
     766            /* translators: 1: Date, 2: Time */
    766767            $result = sprintf( _x( '%1$s at %2$s', 'date at time', 'bbpress' ), $date, $time );
    767768        }
     
    930931            $retval .= "\t" . '<li id="bbp-topic-revision-log-' . esc_attr( $topic_id ) . '-item-' . esc_attr( $revision->ID ) . '" class="bbp-topic-revision-log-item">' . "\n";
    931932            if ( ! empty( $reason ) ) {
     933                /* translators: 1: Time since modification, 2: Author link, 3: Modification reason */
    932934                $retval .= "\t\t" . sprintf( esc_html__( 'This topic was modified %1$s by %2$s. Reason: %3$s', 'bbpress' ), esc_html( $since ), $author, esc_html( $reason ) ) . "\n";
    933935            } else {
     936                /* translators: 1: Time since modification, 2: Author link */
    934937                $retval .= "\t\t" . sprintf( esc_html__( 'This topic was modified %1$s by %2$s.',              'bbpress' ), esc_html( $since ), $author ) . "\n";
    935938            }
     
    12381241 */
    12391242function bbp_topic_author( $topic_id = 0 ) {
    1240     echo bbp_get_topic_author( $topic_id );
     1243    echo bbp_get_topic_author_display_name( $topic_id );
    12411244}
    12421245    /**
     
    14261429                $author = bbp_get_topic_author_display_name( $topic_id );
    14271430                $title  = empty( $anonymous )
     1431                    /* translators: %s: Author's name */
    14281432                    ? esc_attr__( "View %s's profile",  'bbpress' )
     1433                    /* translators: %s: Author's name */
    14291434                    : esc_attr__( "Visit %s's website", 'bbpress' );
    14301435
     
    20132018        $topic_id = bbp_get_topic_id( $topic_id );
    20142019        $link     = bbp_get_topic_permalink( $topic_id );
     2020        /* translators: %s: Number of replies */
    20152021        $replies  = sprintf( _n( '%s reply', '%s replies', bbp_get_topic_reply_count( $topic_id, true ), 'bbpress' ), bbp_get_topic_reply_count( $topic_id, false ) );
    20162022
     
    20282034            // Hidden replies
    20292035            $deleted_num = bbp_get_topic_reply_count_hidden( $topic_id, false );
     2036            /* translators: %s: Number of hidden replies */
    20302037            $extra       = ' ' . sprintf( _n( '(+%s hidden)', '(+%s hidden)', $deleted_int, 'bbpress' ), $deleted_num );
    20312038
     
    29922999            // Several topics in a forum with a single page
    29933000            if ( empty( $to_num ) ) {
     3001                /* translators: %1$s: Total number of topics */
    29943002                $retstr = sprintf( _n( 'Viewing %1$s topic', 'Viewing %1$s topics', $total_int, 'bbpress' ), $total );
    29953003
     
    33133321
    33143322        // Singular/Plural
     3323        /* translators: %s: Number of voices/participants */
    33153324        $voice_count = sprintf( _n( '%s voice', '%s voices', $vc_int, 'bbpress' ), $voice_count );
    33163325
     
    33203329
    33213330            // Last-updated-by should always exist if last-active does
    3322             $last_updated_by = bbp_get_author_link( array(
    3323                 'post_id' => $last_active,
    3324                 'size'    => $r['size']
    3325             ) );
     3331            $last_updated_by = bbp_get_author_link(
     3332                array(
     3333                    'post_id' => $last_active,
     3334                    'size'    => $r['size']
     3335                )
     3336            );
    33263337
    33273338            // Voice count is non-zero (registered users engaged)
    33283339            if ( ! empty( $vc_int ) ) {
     3340                /* translators: 1: Reply count, 2: Voice count, 3: Last updated time, 4: Last updated by */
    33293341                $retstr = sprintf( esc_html__( 'This topic has %1$s, %2$s, and was last updated %3$s by %4$s.', 'bbpress' ), $reply_count, $voice_count, $time_since, $last_updated_by );
    33303342
    33313343            // Voice count is zero (anonymous users only)
    33323344            } else {
     3345                /* translators: 1: Last updated time, 2: Last updated by */
    33333346                $retstr = sprintf( esc_html__( 'This topic was last updated %1$s by %2$s.', 'bbpress' ), $time_since, $last_updated_by );
    33343347            }
     
    33363349        // Topic has no replies
    33373350        } elseif ( ! empty( $vc_int ) && ! empty( $reply_count ) ) {
     3351            /* translators: 1: Voice count, 2: Reply count */
    33383352            $retstr = sprintf( esc_html__( 'This topic has %1$s and %2$s.', 'bbpress' ), $voice_count, $reply_count );
    33393353
     
    40354049
    40364050        // Get the text
     4051        /* translators: %1$s: Person who is editing (user profile link or "Nobody") */
    40374052        $text = sprintf( esc_html__( '%1$s is currently editing this topic.', 'bbpress' ), $person );
    40384053
  • trunk/src/includes/users/functions.php

    r7245 r7360  
    416416    ), $user_url );
    417417
     418    /* translators: 1: Username, 2: Confirmation URL, 3: New email address, 4: Site name, 5: Site URL */
    418419    $email_text = __( '%1$s
    419420
     
    451452
    452453    // Build the email subject
     454    /* translators: %s: Site name */
    453455    $subject = sprintf( __( '[%s] New Email Address', 'bbpress' ), wp_specialchars_decode( get_option( 'blogname' ) ) );
    454456
  • trunk/src/includes/users/template.php

    r7352 r7360  
    14491449    <div class="bbp-template-notice info">
    14501450        <ul>
    1451             <li><?php printf( esc_html__( 'There is a pending email address change to %1$s. %2$s', 'bbpress' ), $coded_email, $dismiss_link ); ?></li>
     1451            <li>
     1452                <?php
     1453                printf(
     1454                    /* translators: 1: New email address, 2: Dismiss change link */
     1455                    esc_html__( 'There is a pending email address change to %1$s. %2$s', 'bbpress' ),
     1456                    $coded_email,
     1457                    $dismiss_link
     1458                );
     1459                ?></li>
    14521460        </ul>
    14531461    </div>
     
    20352043                $author = get_the_author_meta( 'display_name', $user_id );
    20362044                $title  = empty( $anonymous )
     2045                    /* translators: %s: Author's display name */
    20372046                    ? esc_attr__( "View %s's profile",  'bbpress' )
     2047                    /* translators: %s: Author's display name */
    20382048                    : esc_attr__( "Visit %s's website", 'bbpress' );
    20392049
  • trunk/src/templates/default/bbpress/form-allowed-tags.php

    r7268 r7360  
    1414
    1515    <p class="form-allowed-tags">
    16         <label><?php printf( esc_html__( 'You may use these %s tags and attributes:', 'bbpress' ), '<abbr title="HyperText Markup Language">HTML</abbr>' ); ?></label><br />
     16        <label>
     17            <?php
     18            printf(
     19                /* translators: %s: Literally the "HTML" string */
     20                esc_html__( 'You may use these %s tags and attributes:', 'bbpress' ), '<abbr title="HyperText Markup Language">HTML</abbr>' );
     21            ?>
     22        </label>
     23        <br />
    1724        <code><?php bbp_allowed_tags(); ?></code>
    1825    </p>
  • trunk/src/templates/default/bbpress/form-forum.php

    r7347 r7360  
    3434                    <?php
    3535                        if ( bbp_is_forum_edit() ) :
     36                            /* translators: %s: Forum title */
    3637                            printf( esc_html__( 'Editing &ldquo;%s&rdquo;', 'bbpress' ), bbp_get_forum_title() );
    3738                        else :
    3839                            ( bbp_is_single_forum() && bbp_get_forum_title() )
     40                                /* translators: %s: Forum title */
    3941                                ? printf( esc_html__( 'Add Forum in &ldquo;%s&rdquo;', 'bbpress' ), bbp_get_forum_title() )
    4042                                : esc_html_e( 'Add Forum', 'bbpress' );
     
    7375
    7476                    <p>
    75                         <label for="bbp_forum_title"><?php printf( esc_html__( 'Forum Name (Maximum Length: %d):', 'bbpress' ), bbp_get_title_max_length() ); ?></label><br />
     77                        <label for="bbp_forum_title">
     78                            <?php
     79                            printf(
     80                                /* translators: %s: Maximum length of forum title */
     81                                esc_html__( 'Forum Name (Maximum Length: %d):', 'bbpress' ),
     82                                bbp_get_title_max_length()
     83                            );
     84                            ?>
     85                        </label><br />
    7686                        <input type="text" id="bbp_forum_title" value="<?php bbp_form_forum_title(); ?>" size="40" name="bbp_forum_title" maxlength="<?php bbp_title_max_length(); ?>" />
    7787                    </p>
     
    174184        <div class="bbp-template-notice">
    175185            <ul>
    176                 <li><?php printf( esc_html__( 'The forum &#8216;%s&#8217; is closed to new content.', 'bbpress' ), bbp_get_forum_title() ); ?></li>
     186                <li>
     187                    <?php
     188                    printf(
     189                        /* translators: %s: Forum title */
     190                        esc_html__( 'The forum &#8216;%s&#8217; is closed to new content.', 'bbpress' ),
     191                        bbp_get_forum_title()
     192                    );
     193                    ?>
     194                </li>
    177195            </ul>
    178196        </div>
  • trunk/src/templates/default/bbpress/form-reply-move.php

    r6806 r7360  
    2525                <fieldset class="bbp-form">
    2626
    27                     <legend><?php printf( esc_html__( 'Move reply "%s"', 'bbpress' ), bbp_get_reply_title() ); ?></legend>
     27                    <legend>
     28                        <?php
     29                        printf(
     30                            /* translators: %s: Reply title */
     31                            esc_html__( 'Move reply "%s"', 'bbpress' ), bbp_get_reply_title()
     32                        );
     33                        ?>
     34                    </legend>
    2835
    2936                    <div>
     
    4653                            <div>
    4754                                <input name="bbp_reply_move_option" id="bbp_reply_move_option_reply" type="radio" checked="checked" value="topic" />
    48                                 <label for="bbp_reply_move_option_reply"><?php printf( esc_html__( 'New topic in %s titled:', 'bbpress' ), bbp_get_forum_title( bbp_get_reply_forum_id( bbp_get_reply_id() ) ) ); ?></label>
    49                                 <input type="text" id="bbp_reply_move_destination_title" value="<?php printf( esc_html__( 'Moved: %s', 'bbpress' ), bbp_get_reply_title() ); ?>" size="35" name="bbp_reply_move_destination_title" />
     55                                <label for="bbp_reply_move_option_reply">
     56                                    <?php
     57                                    printf(
     58                                        /* translators: %s: Forum title */
     59                                        esc_html__( 'New topic in %s titled:', 'bbpress' ), bbp_get_forum_title( bbp_get_reply_forum_id( bbp_get_reply_id() ) )
     60                                    );
     61                                    ?>
     62                                </label>
     63                                <input type="text" id="bbp_reply_move_destination_title" value="
     64                                    <?php
     65                                    printf(
     66                                        /* translators: %s: Reply title */
     67                                        esc_html__( 'Moved: %s', 'bbpress' ), bbp_get_reply_title()
     68                                    );
     69                                    ?>" size="35" name="bbp_reply_move_destination_title" />
    5070                            </div>
    5171
  • trunk/src/templates/default/bbpress/form-reply.php

    r7268 r7360  
    2828
    2929            <fieldset class="bbp-form">
    30                 <legend><?php printf( esc_html__( 'Reply To: %s', 'bbpress' ), ( bbp_get_form_reply_to() ) ? sprintf( esc_html__( 'Reply #%1$s in %2$s', 'bbpress' ), bbp_get_form_reply_to(), bbp_get_topic_title() ) : bbp_get_topic_title() ); ?></legend>
     30            <legend>
     31                <?php
     32                if ( bbp_get_form_reply_to() ) {
     33
     34                    printf(
     35                        /* translators: %s: Reply reference (includes reply number and topic title) */
     36                        esc_html__( 'Reply To: %s', 'bbpress' ),
     37                        sprintf(
     38                            /* translators: 1: Reply number, 2: Topic title */
     39                            esc_html__( 'Reply #%1$s in %2$s', 'bbpress' ),
     40                            bbp_get_form_reply_to(),
     41                            bbp_get_topic_title()
     42                        )
     43                    );
     44                } else {
     45
     46                    printf(
     47                        /* translators: %s: Topic title */
     48                        esc_html__( 'Reply To: %s', 'bbpress' ),
     49                        bbp_get_topic_title()
     50                    );
     51                }
     52                ?>
     53            </legend>
    3154
    3255                <?php do_action( 'bbp_theme_before_reply_form_notices' ); ?>
     
    191214        <div class="bbp-template-notice">
    192215            <ul>
    193                 <li><?php printf( esc_html__( 'The topic &#8216;%s&#8217; is closed to new replies.', 'bbpress' ), bbp_get_topic_title() ); ?></li>
     216                <li>
     217                    <?php
     218                    printf(
     219                        /* translators: %s: Topic title */
     220                        esc_html__( 'The topic &#8216;%s&#8217; is closed to new replies.', 'bbpress' ),
     221                        bbp_get_topic_title()
     222                    );
     223                    ?>
     224                </li>
    194225            </ul>
    195226        </div>
     
    201232        <div class="bbp-template-notice">
    202233            <ul>
    203                 <li><?php printf( esc_html__( 'The forum &#8216;%s&#8217; is closed to new topics and replies.', 'bbpress' ), bbp_get_forum_title( bbp_get_topic_forum_id() ) ); ?></li>
     234                <li>
     235                    <?php
     236                    printf(
     237                        /* translators: %s: Forum title */
     238                        esc_html__( 'The forum &#8216;%s&#8217; is closed to new topics and replies.', 'bbpress' ),
     239                        bbp_get_forum_title( bbp_get_topic_forum_id() )
     240                    );
     241                    ?>
     242                </li>
    204243            </ul>
    205244        </div>
  • trunk/src/templates/default/bbpress/form-topic-merge.php

    r6806 r7360  
    2525                <fieldset class="bbp-form">
    2626
    27                     <legend><?php printf( esc_html__( 'Merge topic "%s"', 'bbpress' ), bbp_get_topic_title() ); ?></legend>
     27                    <legend>
     28                        <?php
     29                        printf(
     30                            /* translators: %s: Topic title */
     31                            esc_html__( 'Merge topic "%s"', 'bbpress' ),
     32                            bbp_get_topic_title()
     33                        );
     34                        ?>
     35                    </legend>
    2836
    2937                    <div>
  • trunk/src/templates/default/bbpress/form-topic-split.php

    r6806 r7360  
    2525                <fieldset class="bbp-form">
    2626
    27                     <legend><?php printf( esc_html__( 'Split topic "%s"', 'bbpress' ), bbp_get_topic_title() ); ?></legend>
     27                    <legend>
     28                        <?php
     29                        printf(
     30                            /* translators: %s: Topic title */
     31                            esc_html__( 'Split topic "%s"', 'bbpress' ),
     32                            bbp_get_topic_title()
     33                        );
     34                        ?>
     35                    </legend>
    2836
    2937                    <div>
     
    4654                            <div>
    4755                                <input name="bbp_topic_split_option" id="bbp_topic_split_option_reply" type="radio" checked="checked" value="reply" />
    48                                 <label for="bbp_topic_split_option_reply"><?php printf( esc_html__( 'New topic in %s titled:', 'bbpress' ), bbp_get_forum_title( bbp_get_topic_forum_id( bbp_get_topic_id() ) ) ); ?></label>
    49                                 <input type="text" id="bbp_topic_split_destination_title" value="<?php printf( esc_html__( 'Split: %s', 'bbpress' ), bbp_get_topic_title() ); ?>" size="35" name="bbp_topic_split_destination_title" />
     56                                <label for="bbp_topic_split_option_reply">
     57                                    <?php
     58                                    printf(
     59                                        /* translators: %s: Forum title */
     60                                        esc_html__( 'New topic in %s titled:', 'bbpress' ), bbp_get_forum_title( bbp_get_topic_forum_id( bbp_get_topic_id() ) )
     61                                    );
     62                                    ?>
     63                                </label>
     64                                <input type="text" id="bbp_topic_split_destination_title" value="
     65                                <?php
     66                                printf(
     67                                    /* translators: %s: Original topic title */
     68                                    esc_html__( 'Split: %s', 'bbpress' ), bbp_get_topic_title()
     69                                );
     70                                ?>" size="35" name="bbp_topic_split_destination_title" />
    5071                            </div>
    5172
     
    5778
    5879                                    <?php
    59                                         bbp_dropdown( array(
    60                                             'post_type'   => bbp_get_topic_post_type(),
    61                                             'post_parent' => bbp_get_topic_forum_id( bbp_get_topic_id() ),
    62                                             'post_status' => bbp_get_public_topic_statuses(),
    63                                             'selected'    => -1,
    64                                             'exclude'     => bbp_get_topic_id(),
    65                                             'select_id'   => 'bbp_destination_topic'
    66                                         ) );
     80                                        bbp_dropdown(
     81                                            array(
     82                                                'post_type' => bbp_get_topic_post_type(),
     83                                                'post_parent' => bbp_get_topic_forum_id( bbp_get_topic_id() ),
     84                                                'post_status' => bbp_get_public_topic_statuses(),
     85                                                'selected' => -1,
     86                                                'exclude' => bbp_get_topic_id(),
     87                                                'select_id' => 'bbp_destination_topic'
     88                                            )
     89                                        );
    6790                                    ?>
    6891
  • trunk/src/templates/default/bbpress/form-topic-tag.php

    r6806 r7360  
    1717        <fieldset class="bbp-form" id="bbp-edit-topic-tag">
    1818
    19             <legend><?php printf( esc_html__( 'Manage Tag: "%s"', 'bbpress' ), bbp_get_topic_tag_name() ); ?></legend>
     19            <legend>
     20                <?php
     21                printf(
     22                    /* translators: %s: Topic tag name */
     23                    esc_html__( 'Manage Tag: "%s"', 'bbpress' ),
     24                    bbp_get_topic_tag_name()
     25                );
     26                ?>
     27            </legend>
    2028
    2129            <fieldset class="bbp-form" id="tag-rename">
     
    8391
    8492                    <div class="bbp-submit-wrapper">
    85                         <button type="submit" class="button submit" onclick="return confirm('<?php echo esc_js( sprintf( esc_html__( 'Are you sure you want to merge the "%s" tag into the tag you specified?', 'bbpress' ), bbp_get_topic_tag_name() ) ); ?>');"><?php esc_attr_e( 'Merge', 'bbpress' ); ?></button>
     93                        <button type="submit"
     94                                class="button submit"
     95                                onclick="return confirm('<?php
     96                                   
     97                                    echo esc_js(
     98                                        sprintf(
     99                                        /* translators: %s: Topic tag name */
     100                                            esc_html__(
     101                                                'Are you sure you want to merge the "%s" tag into the tag you specified?',
     102                                                'bbpress'
     103                                            ),
     104                                            bbp_get_topic_tag_name()
     105                                        )
     106                                    );
     107                                ?>');">
     108                            <?php esc_attr_e( 'Merge', 'bbpress' ); ?>
     109                        </button>
    86110
    87                         <input type="hidden" name="tag-id" value="<?php bbp_topic_tag_id(); ?>" />
    88                         <input type="hidden" name="action" value="bbp-merge-topic-tag" />
     111                        <input type="hidden"
     112                            name="tag-id"
     113                            value="<?php bbp_topic_tag_id(); ?>" />
     114                       
     115                        <input type="hidden"
     116                            name="action"
     117                            value="bbp-merge-topic-tag" />
    89118
    90119                        <?php wp_nonce_field( 'merge-tag_' . bbp_get_topic_tag_id() ); ?>
     
    113142
    114143                    <form id="delete_tag" name="delete_tag" method="post">
     144                        <div class="bbp-submit-wrapper">
     145                            <button type="submit"
     146                                    class="button submit"
     147                                    onclick="return confirm('<?php
     148                                        echo esc_js(
     149                                            sprintf(
     150                                                /* translators: %s: Topic tag name */
     151                                                esc_html__(
     152                                                    'Are you sure you want to delete the "%s" tag? This is permanent and cannot be undone.',
     153                                                    'bbpress'
     154                                                ),
     155                                                bbp_get_topic_tag_name()
     156                                            )
     157                                        );
     158                                    ?>');">
     159                                <?php esc_attr_e( 'Delete', 'bbpress' ); ?>
     160                            </button>
    115161
    116                         <div class="bbp-submit-wrapper">
    117                             <button type="submit" class="button submit" onclick="return confirm('<?php echo esc_js( sprintf( esc_html__( 'Are you sure you want to delete the "%s" tag? This is permanent and cannot be undone.', 'bbpress' ), bbp_get_topic_tag_name() ) ); ?>');"><?php esc_attr_e( 'Delete', 'bbpress' ); ?></button>
     162                            <input type="hidden"
     163                                name="tag-id"
     164                                value="<?php bbp_topic_tag_id(); ?>" />
    118165
    119                             <input type="hidden" name="tag-id" value="<?php bbp_topic_tag_id(); ?>" />
    120                             <input type="hidden" name="action" value="bbp-delete-topic-tag" />
     166                            <input type="hidden"
     167                                name="action"
     168                                value="bbp-delete-topic-tag" />
    121169
    122170                            <?php wp_nonce_field( 'delete-tag_' . bbp_get_topic_tag_id() ); ?>
  • trunk/src/templates/default/bbpress/form-topic.php

    r7347 r7360  
    4242                    <?php
    4343                        if ( bbp_is_topic_edit() ) :
     44                            /* translators: %s: Topic title */
    4445                            printf( esc_html__( 'Editing &ldquo;%s&rdquo;', 'bbpress' ), bbp_get_topic_title() );
    4546                        else :
    4647                            ( bbp_is_single_forum() && bbp_get_forum_title() )
     48                                /* translators: %s: Topic title */
    4749                                ? printf( esc_html__( 'Add Topic in &ldquo;%s&rdquo;', 'bbpress' ), bbp_get_forum_title() )
    4850                                : esc_html_e( 'Add Topic', 'bbpress' );
     
    8385
    8486                    <p>
    85                         <label for="bbp_topic_title"><?php printf( esc_html__( 'Topic Title (Maximum Length: %d):', 'bbpress' ), bbp_get_title_max_length() ); ?></label><br />
    86                         <input type="text" id="bbp_topic_title" value="<?php bbp_form_topic_title(); ?>" size="40" name="bbp_topic_title" maxlength="<?php bbp_title_max_length(); ?>" />
     87                        <label for="bbp_topic_title">
     88                            <?php
     89                            printf(
     90                                /* translators: %d: Maximum allowed length for topic title */
     91                                esc_html__( 'Topic Title (Maximum Length: %d):', 'bbpress' ),
     92                                bbp_get_title_max_length()
     93                            );
     94                            ?>
     95                        </label>
     96                        <br />
     97                        <input type="text" id="bbp_topic_title" value="<?php bbp_form_topic_title(); ?>" size="40" name="bbp_topic_title" maxlength="<?php bbp_title_max_length(); ?>"
     98                        />
    8799                    </p>
    88100
     
    228240        <div class="bbp-template-notice">
    229241            <ul>
    230                 <li><?php printf( esc_html__( 'The forum &#8216;%s&#8217; is closed to new topics and replies.', 'bbpress' ), bbp_get_forum_title() ); ?></li>
     242                <li>
     243                    <?php
     244                    printf(
     245                        /* translators: %s: Forum title */
     246                        esc_html__( 'The forum &#8216;%s&#8217; is closed to new topics and replies.', 'bbpress' ),
     247                        bbp_get_forum_title()
     248                    );
     249                    ?>
     250                </li>
    231251            </ul>
    232252        </div>
  • trunk/src/templates/default/bbpress/loop-search-forum.php

    r6258 r7360  
    1515<div class="bbp-forum-header">
    1616    <div class="bbp-meta">
    17         <span class="bbp-forum-post-date"><?php printf( esc_html__( 'Last updated %s', 'bbpress' ), bbp_get_forum_last_active_time() ); ?></span>
     17        <span class="bbp-forum-post-date">
     18            <?php
     19            printf(
     20                /* translators: %s: Time since last forum update */
     21                esc_html__( 'Last updated %s', 'bbpress' ), bbp_get_forum_last_active_time()
     22            );
     23            ?>
     24        </span>
    1825        <a href="<?php bbp_forum_permalink(); ?>" class="bbp-forum-permalink">#<?php bbp_forum_id(); ?></a>
    1926    </div><!-- .bbp-meta -->
  • trunk/src/templates/default/bbpress/loop-single-topic.php

    r6258 r7360  
    6060            <?php do_action( 'bbp_theme_before_topic_started_by' ); ?>
    6161
    62             <span class="bbp-topic-started-by"><?php printf( esc_html__( 'Started by: %1$s', 'bbpress' ), bbp_get_topic_author_link( array( 'size' => '14' ) ) ); ?></span>
     62            <span class="bbp-topic-started-by">
     63                <?php
     64                printf(
     65                    /* translators: %1$s: Topic author link */
     66                    esc_html__( 'Started by: %1$s', 'bbpress' ),
     67                    bbp_get_topic_author_link( array( 'size' => '14' ) )
     68                );
     69                ?>
     70            </span>
    6371
    6472            <?php do_action( 'bbp_theme_after_topic_started_by' ); ?>
     
    6876                <?php do_action( 'bbp_theme_before_topic_started_in' ); ?>
    6977
    70                 <span class="bbp-topic-started-in"><?php printf( esc_html__( 'in: %1$s', 'bbpress' ), '<a href="' . bbp_get_forum_permalink( bbp_get_topic_forum_id() ) . '">' . bbp_get_forum_title( bbp_get_topic_forum_id() ) . '</a>' ); ?></span>
     78                <span class="bbp-topic-started-in">
     79                    <?php
     80                    printf(
     81                        /* translators: %1$s: Forum link with title */
     82                        esc_html__( 'in: %1$s', 'bbpress' ),
     83                        '<a href="' . bbp_get_forum_permalink( bbp_get_topic_forum_id() ) . '">' . bbp_get_forum_title( bbp_get_topic_forum_id() ) . '</a>'
     84                    );
     85                    ?>
     86                </span>
    7187                <?php do_action( 'bbp_theme_after_topic_started_in' ); ?>
    7288
  • trunk/src/templates/default/bbpress/user-details.php

    r7006 r7360  
    2727        <ul>
    2828            <li class="<?php if ( bbp_is_single_user_profile() ) : ?>current<?php endif; ?>">
    29                 <span class="vcard bbp-user-profile-link">
    30                     <a class="url fn n" href="<?php bbp_user_profile_url(); ?>" title="<?php printf( esc_attr__( "%s's Profile", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' ) ); ?>" rel="me"><?php esc_html_e( 'Profile', 'bbpress' ); ?></a>
     29                <span class="vcard bbp-user-profile-link">                 
     30                    <a class="url fn n" href="<?php bbp_user_profile_url(); ?>" title="
     31                        <?php
     32                        printf(
     33                            /* translators: %s: User's display name */
     34                            esc_attr__( "%s's Profile", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' )
     35                        );
     36                        ?>" rel="me">
     37                        <?php esc_html_e( 'Profile', 'bbpress' ); ?>
     38                    </a>
    3139                </span>
    3240            </li>
     
    3442            <li class="<?php if ( bbp_is_single_user_topics() ) : ?>current<?php endif; ?>">
    3543                <span class='bbp-user-topics-created-link'>
    36                     <a href="<?php bbp_user_topics_created_url(); ?>" title="<?php printf( esc_attr__( "%s's Topics Started", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' ) ); ?>"><?php esc_html_e( 'Topics Started', 'bbpress' ); ?></a>
     44                    <a href="<?php bbp_user_topics_created_url(); ?>" title="
     45                        <?php
     46                        printf(
     47                            /* translators: %s: User's display name */
     48                            esc_attr__( "%s's Topics Started", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' )
     49                        );
     50                        ?>">
     51                        <?php esc_html_e( 'Topics Started', 'bbpress' ); ?>
     52                    </a>
    3753                </span>
    3854            </li>
     
    4056            <li class="<?php if ( bbp_is_single_user_replies() ) : ?>current<?php endif; ?>">
    4157                <span class='bbp-user-replies-created-link'>
    42                     <a href="<?php bbp_user_replies_created_url(); ?>" title="<?php printf( esc_attr__( "%s's Replies Created", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' ) ); ?>"><?php esc_html_e( 'Replies Created', 'bbpress' ); ?></a>
     58                    <a href="<?php bbp_user_replies_created_url(); ?>" title="
     59                        <?php
     60                        printf(
     61                            /* translators: %s: User's display name */
     62                            esc_attr__( "%s's Replies Created", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' )
     63                        );
     64                        ?>">
     65                        <?php esc_html_e( 'Replies Created', 'bbpress' ); ?>
     66                    </a>
    4367                </span>
    4468            </li>
     
    4771                <li class="<?php if ( bbp_is_single_user_engagements() ) : ?>current<?php endif; ?>">
    4872                    <span class='bbp-user-engagements-created-link'>
    49                         <a href="<?php bbp_user_engagements_url(); ?>" title="<?php printf( esc_attr__( "%s's Engagements", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' ) ); ?>"><?php esc_html_e( 'Engagements', 'bbpress' ); ?></a>
     73                        <a href="<?php bbp_user_engagements_url(); ?>" title="
     74                            <?php
     75                            printf(
     76                                /* translators: %s: User's display name */
     77                                esc_attr__( "%s's Engagements", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' )
     78                            );
     79                            ?>">
     80                            <?php esc_html_e( 'Engagements', 'bbpress' ); ?>
     81                        </a>
    5082                    </span>
    5183                </li>
     
    5587                <li class="<?php if ( bbp_is_favorites() ) : ?>current<?php endif; ?>">
    5688                    <span class="bbp-user-favorites-link">
    57                         <a href="<?php bbp_favorites_permalink(); ?>" title="<?php printf( esc_attr__( "%s's Favorites", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' ) ); ?>"><?php esc_html_e( 'Favorites', 'bbpress' ); ?></a>
     89                        <a href="<?php bbp_favorites_permalink(); ?>" title="
     90                            <?php
     91                            printf(
     92                                /* translators: %s: User's display name */
     93                                esc_attr__( "%s's Favorites", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' )
     94                            );
     95                            ?>">
     96                            <?php esc_html_e( 'Favorites', 'bbpress' ); ?></a>
    5897                    </span>
    5998                </li>
     
    65104                    <li class="<?php if ( bbp_is_subscriptions() ) : ?>current<?php endif; ?>">
    66105                        <span class="bbp-user-subscriptions-link">
    67                             <a href="<?php bbp_subscriptions_permalink(); ?>" title="<?php printf( esc_attr__( "%s's Subscriptions", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' ) ); ?>"><?php esc_html_e( 'Subscriptions', 'bbpress' ); ?></a>
     106                            <a href="<?php bbp_subscriptions_permalink(); ?>" title="
     107                                <?php
     108                                printf(
     109                                    /* translators: %s: User's display name */
     110                                    esc_attr__( "%s's Subscriptions", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' )
     111                                );
     112                                ?>">
     113                                <?php esc_html_e( 'Subscriptions', 'bbpress' ); ?>
     114                            </a>
    68115                        </span>
    69116                    </li>
     
    72119                <li class="<?php if ( bbp_is_single_user_edit() ) : ?>current<?php endif; ?>">
    73120                    <span class="bbp-user-edit-link">
    74                         <a href="<?php bbp_user_profile_edit_url(); ?>" title="<?php printf( esc_attr__( "Edit %s's Profile", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' ) ); ?>"><?php esc_html_e( 'Edit', 'bbpress' ); ?></a>
     121                        <a href="<?php bbp_user_profile_edit_url(); ?>" title="
     122                            <?php
     123                            printf(
     124                                /* translators: %s: User's display name */
     125                                esc_attr__( "Edit %s's Profile", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' ) );
     126                            ?>">
     127                            <?php esc_html_e( 'Edit', 'bbpress' ); ?>
     128                        </a>
    75129                    </span>
    76130                </li>
  • trunk/src/templates/default/bbpress/user-profile.php

    r7146 r7360  
    1717    <div class="bbp-user-section">
    1818        <h3><?php esc_html_e( 'Profile', 'bbpress' ); ?></h3>
    19         <p class="bbp-user-forum-role"><?php printf( esc_html__( 'Registered: %s', 'bbpress' ), bbp_get_time_since( bbp_get_displayed_user_field( 'user_registered' ) ) ); ?></p>
     19
     20        <p class="bbp-user-forum-role">
     21            <?php
     22            printf(
     23                /* translators: %s: Registration date in "time ago" format */
     24                esc_html__( 'Registered: %s', 'bbpress' ),
     25                bbp_get_time_since( bbp_get_displayed_user_field( 'user_registered' ) )
     26            );
     27            ?>
     28        </p>
    2029
    2130        <?php if ( bbp_get_displayed_user_field( 'description' ) ) : ?>
    22 
    23             <p class="bbp-user-description"><?php echo bbp_rel_nofollow( bbp_get_displayed_user_field( 'description' ) ); ?></p>
    24 
     31            <p class="bbp-user-description">
     32                <?php echo bbp_rel_nofollow( bbp_get_displayed_user_field( 'description' ) ); ?>
     33            </p>
    2534        <?php endif; ?>
    2635
    2736        <?php if ( bbp_get_displayed_user_field( 'user_url' ) ) : ?>
    28 
    29             <p class="bbp-user-website"><?php printf( esc_html__( 'Website: %s', 'bbpress' ), bbp_rel_nofollow( bbp_make_clickable( bbp_get_displayed_user_field( 'user_url' ) ) ) ); ?></p>
    30 
     37            <p class="bbp-user-website">
     38                <?php
     39                printf(
     40                    /* translators: %s: User's website URL */
     41                    esc_html__( 'Website: %s', 'bbpress' ),
     42                    bbp_rel_nofollow( bbp_make_clickable( bbp_get_displayed_user_field( 'user_url' ) ) )
     43                );
     44                ?>
     45            </p>
    3146        <?php endif; ?>
    3247
     
    3550
    3651        <?php if ( bbp_get_user_last_posted() ) : ?>
    37 
    38             <p class="bbp-user-last-activity"><?php printf( esc_html__( 'Last Activity: %s',  'bbpress' ), bbp_get_time_since( bbp_get_user_last_posted(), false, true ) ); ?></p>
    39 
     52            <p class="bbp-user-last-activity">
     53                <?php
     54                printf(
     55                    /* translators: %s: Last activity time in "time ago" format */
     56                    esc_html__( 'Last Activity: %s', 'bbpress' ),
     57                    bbp_get_time_since( bbp_get_user_last_posted(), false, true )
     58                );
     59                ?>
     60            </p>
    4061        <?php endif; ?>
    4162
    42         <p class="bbp-user-topic-count"><?php printf( esc_html__( 'Topics Started: %s',  'bbpress' ), bbp_get_user_topic_count() ); ?></p>
    43         <p class="bbp-user-reply-count"><?php printf( esc_html__( 'Replies Created: %s', 'bbpress' ), bbp_get_user_reply_count() ); ?></p>
    44         <p class="bbp-user-forum-role"><?php  printf( esc_html__( 'Forum Role: %s',      'bbpress' ), bbp_get_user_display_role() ); ?></p>
     63        <p class="bbp-user-topic-count">
     64            <?php
     65            printf(
     66                /* translators: %s: Number of topics */
     67                esc_html__( 'Topics Started: %s', 'bbpress' ),
     68                bbp_get_user_topic_count()
     69            );
     70            ?>
     71        </p>
     72        <p class="bbp-user-reply-count">
     73            <?php
     74            printf(
     75                /* translators: %s: Number of replies */
     76                esc_html__( 'Replies Created: %s', 'bbpress' ),
     77                bbp_get_user_reply_count()
     78            );
     79            ?>
     80        </p>
     81        <p class="bbp-user-forum-role">
     82            <?php
     83            printf(
     84                /* translators: %s: User's forum role */
     85                esc_html__( 'Forum Role: %s', 'bbpress' ),
     86                bbp_get_user_display_role()
     87            );
     88            ?>
     89        </p>
    4590    </div>
    4691</div><!-- #bbp-author-topics-started -->
  • trunk/src/templates/default/extras/taxonomy-topic-tag-edit.php

    r6371 r7360  
    1515
    1616    <div id="topic-tag" class="bbp-topic-tag">
    17         <h1 class="entry-title"><?php printf( esc_html__( 'Topic Tag: %s', 'bbpress' ), '<span>' . bbp_get_topic_tag_name() . '</span>' ); ?></h1>
     17
     18        <h1 class="entry-title">
     19            <?php
     20            printf(
     21                /* translators: %s: Topic current tag name wrapped in span tags */
     22                esc_html__( 'Topic Tag: %s', 'bbpress' ), '<span>' . bbp_get_topic_tag_name() . '</span>'
     23            );
     24            ?>
     25        </h1>
    1826
    1927        <div class="entry-content">
  • trunk/src/templates/default/extras/taxonomy-topic-tag.php

    r6371 r7360  
    1515
    1616    <div id="topic-tag" class="bbp-topic-tag">
    17         <h1 class="entry-title"><?php printf( esc_html__( 'Topic Tag: %s', 'bbpress' ), '<span>' . bbp_get_topic_tag_name() . '</span>' ); ?></h1>
     17        <h1 class="entry-title">
     18            <?php
     19            printf(
     20                /* translators: %s - topic tag name */
     21                esc_html__( 'Topic Tag: %s', 'bbpress' ),
     22                '<span>' . bbp_get_topic_tag_name() . '</span>'
     23            );
     24            ?>
     25        </h1>
    1826        <div class="entry-content">
    1927
Note: See TracChangeset for help on using the changeset viewer.