Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/31/2011 07:09:52 PM (13 years ago)
Author:
boonebgorges
Message:

Introduces bp_forum_topic_new_reply_link() to get a proper last-page URL for New Reply topic buttons. Fixes #3535

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-forums/bp-forums-template.php

    r5072 r5080  
    861861
    862862/**
     863 * Echoes the output of bp_get_forum_topic_new_reply_link()
     864 *
     865 * @package BuddyPress
     866 * @since 1.5
     867 */
     868function bp_forum_topic_new_reply_link() {
     869    echo bp_get_forum_topic_new_reply_link();
     870}
     871    /**
     872     * Returns the permalink for the New Reply button at the top of forum topics
     873     *
     874     * @package BuddyPress
     875     * @since 1.5
     876     *
     877     * @uses apply_filters() Filter bp_get_forum_topic_new_reply_link to modify
     878     * @return str The URL for the New Reply link
     879     */
     880    function bp_get_forum_topic_new_reply_link() {
     881        global $topic_template;
     882
     883        if ( $topic_template->pag->total_pages == $topic_template->pag_page ) {
     884            // If we are on the last page, no need for a URL base
     885            $link = '';
     886        } else {
     887            // Create a link to the last page for the topic
     888            $link = add_query_arg( array(
     889                'topic_page' => $topic_template->pag->total_pages,
     890                'num'        => $topic_template->pag_num
     891            ), bp_get_the_topic_permalink() );
     892        }
     893
     894        // Tack on the #post-topic-reply anchor before returning
     895        return apply_filters( 'bp_get_forum_topic_new_reply_link', $link . '#post-topic-reply', $link );
     896    }
     897
     898/**
    863899 * Echoes the output of bp_get_forums_tag_name()
    864900 *
Note: See TracChangeset for help on using the changeset viewer.