Skip to:
Content

BuddyPress.org

Changeset 5080


Ignore:
Timestamp:
08/31/2011 07:09:52 PM (14 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

Location:
trunk
Files:
2 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 *
  • trunk/bp-themes/bp-default/groups/single/forum/topic.php

    r5079 r5080  
    88            <ul>
    99                <li>
    10                     <a href="#post-topic-reply" class="new-reply-link"><?php _e( 'New Reply', 'buddypress' ) ?></a>
     10                    <a href="<?php bp_forum_topic_new_reply_link() ?>" class="new-reply-link"><?php _e( 'New Reply', 'buddypress' ) ?></a>
    1111                </li>
    1212
Note: See TracChangeset for help on using the changeset viewer.