Esempio n. 1
0
/**
 * Return URL to the reply edit page
 *
 * @since bbPress (r2753)
 *
 * @param int $reply_id Optional. Reply id
 * @uses bbp_get_reply_id() To get the reply id
 * @uses bbp_get_reply() To get the reply
 * @uses bbp_get_reply_post_type() To get the reply post type
 * @uses add_query_arg() To add custom args to the url
 * @uses apply_filters() Calls 'bbp_get_reply_edit_url' with the edit
 *                        url and reply id
 * @return string Reply edit url
 */
function bbp_get_reply_edit_url($reply_id = 0)
{
    global $wp_rewrite;
    $bbp = bbpress();
    $reply = bbp_get_reply(bbp_get_reply_id($reply_id));
    if (empty($reply)) {
        return;
    }
    $reply_link = bbp_remove_view_all(bbp_get_reply_permalink($reply_id));
    // Pretty permalinks
    if ($wp_rewrite->using_permalinks()) {
        $url = trailingslashit($reply_link) . $bbp->edit_id;
        $url = trailingslashit($url);
        // Unpretty permalinks
    } else {
        $url = add_query_arg(array(bbp_get_reply_post_type() => $reply->post_name, $bbp->edit_id => '1'), $reply_link);
    }
    // Maybe add view all
    $url = bbp_add_view_all($url);
    return apply_filters('bbp_get_reply_edit_url', $url, $reply_id);
}
Esempio n. 2
0
/**
 * Return URL to the topic edit page
 *
 * @since 2.0.0 bbPress (r2753)
 *
 * @param int $topic_id Optional. Topic id
 * @uses bbp_get_topic_id() To get the topic id
 * @uses bbp_get_topic() To get the topic
 * @uses add_query_arg() To add custom args to the url
 * @uses apply_filters() Calls 'bbp_get_topic_edit_url' with the edit
 *                        url and topic id
 * @return string Topic edit url
 */
function bbp_get_topic_edit_url($topic_id = 0)
{
    $topic = bbp_get_topic($topic_id);
    if (empty($topic)) {
        return;
    }
    // Remove view=all link from edit
    $topic_link = bbp_remove_view_all(bbp_get_topic_permalink($topic_id));
    // Pretty permalinks
    if (bbp_use_pretty_urls()) {
        $url = trailingslashit($topic_link) . bbp_get_edit_rewrite_id();
        $url = user_trailingslashit($url);
        // Unpretty permalinks
    } else {
        $url = add_query_arg(array(bbp_get_topic_post_type() => $topic->post_name, bbp_get_edit_rewrite_id() => '1'), $topic_link);
    }
    // Maybe add view=all
    $url = bbp_add_view_all($url);
    return apply_filters('bbp_get_topic_edit_url', $url, $topic_id);
}
Esempio n. 3
0
/**
 * Return the topics link of the forum
 *
 * @since bbPress (r2883)
 *
 * @param int $forum_id Optional. Topic id
 * @uses bbp_get_forum_id() To get the forum id
 * @uses bbp_get_forum() To get the forum
 * @uses bbp_get_forum_topic_count() To get the forum topic count
 * @uses bbp_get_forum_permalink() To get the forum permalink
 * @uses remove_query_arg() To remove args from the url
 * @uses bbp_get_forum_topic_count_hidden() To get the forum hidden
 *                                           topic count
 * @uses current_user_can() To check if the current user can edit others
 *                           topics
 * @uses add_query_arg() To add custom args to the url
 * @uses apply_filters() Calls 'bbp_get_forum_topics_link' with the
 *                        topics link and forum id
 */
function bbp_get_forum_topics_link($forum_id = 0)
{
    $forum = bbp_get_forum($forum_id);
    $forum_id = $forum->ID;
    $topics = bbp_get_forum_topic_count($forum_id);
    $topics = sprintf(_n('%s topic', '%s topics', $topics, 'bbpress'), $topics);
    $retval = '';
    // First link never has view=all
    if (bbp_get_view_all('edit_others_topics')) {
        $retval .= "<a href='" . esc_url(bbp_remove_view_all(bbp_get_forum_permalink($forum_id))) . "'>{$topics}</a>";
    } else {
        $retval .= $topics;
    }
    // Get deleted topics
    $deleted = bbp_get_forum_topic_count_hidden($forum_id);
    // This forum has hidden topics
    if (!empty($deleted) && current_user_can('edit_others_topics')) {
        // Extra text
        $extra = sprintf(__(' (+ %d hidden)', 'bbpress'), $deleted);
        // No link
        if (bbp_get_view_all()) {
            $retval .= " {$extra}";
            // Link
        } else {
            $retval .= " <a href='" . esc_url(bbp_add_view_all(bbp_get_forum_permalink($forum_id), true)) . "'>{$extra}</a>";
        }
    }
    return apply_filters('bbp_get_forum_topics_link', $retval, $forum_id);
}