Ejemplo n.º 1
0
/**
 * Return the merge link of the topic
 *
 * @since 2.0.0 bbPress (r2756)
 *
 * @param array $args This function supports these args:
 *  - id: Optional. Topic id
 *  - link_before: Before the link
 *  - link_after: After the link
 *  - merge_text: Merge text
 * @uses bbp_get_topic_id() To get the topic id
 * @uses bbp_get_topic() To get the topic
 * @uses bbp_get_topic_edit_url() To get the topic edit url
 * @uses add_query_arg() To add custom args to the url
 * @uses esc_url() To escape the url
 * @uses apply_filters() Calls 'bbp_get_topic_merge_link' with the link
 *                        and args
 * @return string Topic merge link
 */
function bbp_get_topic_merge_link($args = array())
{
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('id' => 0, 'link_before' => '', 'link_after' => '', 'merge_text' => esc_html__('Merge', 'bbpress')), 'get_topic_merge_link');
    $topic = bbp_get_topic($r['id']);
    if (empty($topic) || !current_user_can('moderate', $topic->ID)) {
        return;
    }
    $uri = add_query_arg(array('action' => 'merge'), bbp_get_topic_edit_url($topic->ID));
    $retval = $r['link_before'] . '<a href="' . esc_url($uri) . '" class="bbp-topic-merge-link">' . $r['merge_text'] . '</a>' . $r['link_after'];
    return apply_filters('bbp_get_topic_merge_link', $retval, $r, $args);
}
Ejemplo n.º 2
0
/**
 * Return the merge link of the topic
 *
 * @since bbPress (r2756)
 *
 * @param mixed $args This function supports these args:
 *  - id: Optional. Topic id
 *  - link_before: Before the link
 *  - link_after: After the link
 *  - merge_text: Merge text
 * @uses bbp_get_topic_id() To get the topic id
 * @uses bbp_get_topic() To get the topic
 * @uses bbp_get_topic_edit_url() To get the topic edit url
 * @uses add_query_arg() To add custom args to the url
 * @uses esc_url() To escape the url
 * @uses apply_filters() Calls 'bbp_get_topic_merge_link' with the link
 *                        and args
 * @return string Topic merge link
 */
function bbp_get_topic_merge_link($args = '')
{
    $defaults = array('id' => 0, 'link_before' => '', 'link_after' => '', 'merge_text' => __('Merge', 'bbpress'));
    $r = bbp_parse_args($args, $defaults, 'get_topic_merge_link');
    extract($r);
    $topic = bbp_get_topic(bbp_get_topic_id((int) $id));
    if (empty($topic) || !current_user_can('moderate', $topic->ID)) {
        return;
    }
    $uri = esc_url(add_query_arg(array('action' => 'merge'), bbp_get_topic_edit_url($topic->ID)));
    $retval = $link_before . '<a href="' . $uri . '">' . $merge_text . '</a>' . $link_after;
    return apply_filters('bbp_get_topic_merge_link', $retval, $args);
}
Ejemplo n.º 3
0
/**
 * Get split topic link
 *
 * Return the split link of the topic (but is bundled with each reply)
 *
 * @since bbPress (r2756)
 *
 * @param mixed $args This function supports these arguments:
 *  - id: Reply id
 *  - link_before: HTML before the link
 *  - link_after: HTML after the link
 *  - split_text: Split text
 *  - split_title: Split title attribute
 * @uses bbp_get_reply_id() To get the reply id
 * @uses bbp_get_reply() To get the reply
 * @uses current_user_can() To check if the current user can edit the
 *                           topic
 * @uses bbp_get_reply_topic_id() To get the reply topic id
 * @uses bbp_get_topic_edit_url() To get the topic edit url
 * @uses add_query_arg() To add custom args to the url
 * @uses wp_nonce_url() To nonce the url
 * @uses esc_url() To escape the url
 * @uses apply_filters() Calls 'bbp_get_topic_split_link' with the topic
 *                        split link and args
 * @return string Topic split link
 */
function bbp_get_topic_split_link($args = '')
{
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('id' => 0, 'link_before' => '', 'link_after' => '', 'split_text' => esc_html__('Split', 'bbpress'), 'split_title' => esc_attr__('Split the topic from this reply', 'bbpress')), 'get_topic_split_link');
    $reply_id = bbp_get_reply_id($r['id']);
    $topic_id = bbp_get_reply_topic_id($reply_id);
    if (empty($reply_id) || !current_user_can('moderate', $topic_id)) {
        return;
    }
    $uri = add_query_arg(array('action' => 'split', 'reply_id' => $reply_id), bbp_get_topic_edit_url($topic_id));
    $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'];
    return apply_filters('bbp_get_topic_split_link', $retval, $r);
}
Ejemplo n.º 4
0
/**
 * Get split topic link
 *
 * Return the split link of the topic (but is bundled with each reply)
 *
 * @since bbPress (r2756)
 *
 * @param mixed $args This function supports these arguments:
 *  - id: Reply id
 *  - link_before: HTML before the link
 *  - link_after: HTML after the link
 *  - split_text: Split text
 *  - split_title: Split title attribute
 * @uses bbp_get_reply_id() To get the reply id
 * @uses bbp_get_reply() To get the reply
 * @uses current_user_can() To check if the current user can edit the
 *                           topic
 * @uses bbp_get_reply_topic_id() To get the reply topic id
 * @uses bbp_get_topic_edit_url() To get the topic edit url
 * @uses add_query_arg() To add custom args to the url
 * @uses wp_nonce_url() To nonce the url
 * @uses esc_url() To escape the url
 * @uses apply_filters() Calls 'bbp_get_topic_split_link' with the topic
 *                        split link and args
 * @return string Reply spam link
 */
function bbp_get_topic_split_link($args = '')
{
    $defaults = array('id' => 0, 'link_before' => '', 'link_after' => '', 'split_text' => __('Split', 'bbpress'), 'split_title' => __('Split the topic from this reply', 'bbpress'));
    $r = bbp_parse_args($args, $defaults, 'get_topic_split_link');
    extract($r);
    $reply_id = bbp_get_reply_id($id);
    $topic_id = bbp_get_reply_topic_id($reply_id);
    if (empty($reply_id) || !current_user_can('moderate', $topic_id)) {
        return;
    }
    $uri = esc_url(add_query_arg(array('action' => 'split', 'reply_id' => $reply_id), bbp_get_topic_edit_url($topic_id)));
    $retval = $link_before . '<a href="' . $uri . '" title="' . esc_attr($split_title) . '">' . $split_text . '</a>' . $link_after;
    return apply_filters('bbp_get_topic_split_link', $retval, $args);
}