Skip to:
Content

bbPress.org

Changeset 4966


Ignore:
Timestamp:
05/28/2013 07:18:30 PM (8 years ago)
Author:
johnjamesjacoby
Message:

Add topic reply link template functions. See #2340.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/topics/template-tags.php

    r4952 r4966  
    22722272                'trash' => bbp_get_topic_trash_link( $r ),
    22732273                'spam'  => bbp_get_topic_spam_link ( $r ),
     2274                'reply' => bbp_get_topic_reply_link( $r )
    22742275            ), $r['id'] );
    22752276        }
     
    27372738    }
    27382739
     2740/**
     2741 * Output the link to go directly to the reply form
     2742 *
     2743 * @since bbPress (r4966)
     2744 *
     2745 * @param array $args
     2746 * @uses bbp_get_reply_to_link() To get the reply to link
     2747 */
     2748function bbp_topic_reply_link( $args = array() ) {
     2749    echo bbp_get_topic_reply_link( $args );
     2750}
     2751
     2752    /**
     2753     * Return the link to go directly to the reply form
     2754     *
     2755     * @since bbPress (r4966)
     2756     *
     2757     * @param array $args Arguments
     2758     * @uses bbp_current_user_can_access_create_reply_form() To check permissions
     2759     * @uses bbp_get_topic_id() To validate the topic id
     2760     * @uses bbp_get_topic() To get the topic
     2761     * @uses apply_filters() Calls 'bbp_get_topic_reply_link' with the formatted link,
     2762     *                        the arguments array, and the topic
     2763     * @return string Link for a reply to a topic
     2764     */
     2765    function bbp_get_topic_reply_link( $args = array() ) {
     2766
     2767        // Parse arguments against default values
     2768        $r = bbp_parse_args( $args, array(
     2769            'id'           => 0,
     2770            'link_before'  => '',
     2771            'link_after'   => '',
     2772            'reply_text'   => __( 'Reply', 'bbpress' ),
     2773        ), 'get_topic_reply_link' );
     2774
     2775        // Get the reply to use it's ID and post_parent
     2776        $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) );
     2777
     2778        // Bail if no reply or user cannot reply
     2779        if ( empty( $topic ) || ! bbp_current_user_can_access_create_reply_form() )
     2780            return;
     2781
     2782        $uri = '#new-post';
     2783
     2784        // Add $uri to the array, to be passed through the filter
     2785        $r['uri'] = $uri;
     2786        $retval   = $r['link_before'] . '<a href="' . esc_url( $r['uri'] ) . '" class="bbp-topic-reply-link">' . esc_html( $r['reply_text'] ) . '</a>' . $r['link_after'];
     2787
     2788        return apply_filters( 'bbp_get_topic_reply_link', $retval, $r, $args );
     2789    }
     2790
    27392791/** Topic Pagination **********************************************************/
    27402792
Note: See TracChangeset for help on using the changeset viewer.