コード例 #1
0
/**
 * Plugin Name: WP Slack bbPress
 * Plugin URI:  https://github.com/rolfkleef/wp-slack-bbpress
 * Description: Send notifications to Slack channels for events in bbPress.
 * Version:     0.5
 * Author:      Rolf Kleef
 * Author URI:  https://drostan.org
 * License:     GPL2
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: wp-slack-bbpress
 */
function wp_slack_bbpress($events)
{
    $events['wp_slack_bbp_new_topic'] = array('action' => 'bbp_new_topic', 'description' => __('When a new topic is added in bbPress', 'wp-slack-bbpress'), 'message' => function ($topic_id, $forum_id, $anonymous_data, $topic_author) {
        return array(array('fallback' => sprintf(__('<%1$s|New topic "%2$s"> in forum <%3$s|%4$s>', 'wp-slack-bbpress'), bbp_get_topic_permalink($topic_id), bbp_get_topic_title($topic_id), bbp_get_forum_permalink($forum_id), bbp_get_forum_title($forum_id)), 'pretext' => sprintf(__('New topic in forum <%1$s|%2$s>', 'wp-slack-bbpress'), bbp_get_forum_permalink($forum_id), bbp_get_forum_title($forum_id)), 'author_name' => bbp_get_topic_author_display_name($topic_id), 'author_link' => bbp_get_topic_author_link($topic_id), 'author_icon' => get_avatar_url($topic_author, array('size' => 16)), 'title' => sprintf('%1$s', bbp_get_topic_title($topic_id)), 'title_link' => bbp_get_topic_permalink($topic_id), 'text' => html_entity_decode(bbp_get_topic_excerpt($topic_id, 150))));
    });
    $events['wp_slack_bbp_new_reply'] = array('action' => 'bbp_new_reply', 'description' => __('When a new reply is added in bbPress', 'wp-slack-bbpress'), 'message' => function ($reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author, $bool, $reply_to) {
        return array(array('fallback' => sprintf(__('<%1$s|New reply> in forum <%2$s|%3$s> on topic <%4$s|%5$s>', 'wp-slack-bbpress'), bbp_get_reply_url($reply_id), bbp_get_forum_permalink($forum_id), bbp_get_forum_title($forum_id), bbp_get_topic_permalink($topic_id), bbp_get_topic_title($topic_id)), 'pretext' => sprintf(__('New reply in forum <%1$s|%2$s> on topic <%3$s|%4$s>', 'wp-slack-bbpress'), bbp_get_forum_permalink($forum_id), bbp_get_forum_title($forum_id), bbp_get_topic_permalink($topic_id), bbp_get_topic_title($topic_id)), 'author_name' => bbp_get_reply_author_display_name($reply_id), 'author_link' => bbp_get_reply_author_link($reply_id), 'author_icon' => get_avatar_url($reply_author, array('size' => 16)), 'title' => sprintf(__('New reply to "%1$s"', 'wp-slack-bbpress'), bbp_get_topic_title($topic_id)), 'title_link' => bbp_get_reply_url($reply_id), 'text' => html_entity_decode(bbp_get_reply_excerpt($reply_id, 150))));
    });
    return $events;
}
コード例 #2
0
function dtbaker_vote_bbp_template_before_topics_loop()
{
    // a tab to display resolved or unresilved voted items within this forum.
    $forum_id = bbp_get_forum_id();
    if (bbps_is_voting_forum($forum_id)) {
        ?>
        <a href="<?php 
        echo add_query_arg(array('show_resolved' => 0), bbp_get_forum_permalink($forum_id));
        ?>
">Pending Feature Requests</a> |
        <a href="<?php 
        echo add_query_arg(array('show_resolved' => 1), bbp_get_forum_permalink($forum_id));
        ?>
">Resolved Requests</a>
        <?php 
    }
}
コード例 #3
0
ファイル: forum.php プロジェクト: joeyblake/bbpress
 /**
  * @covers ::bbp_forum_permalink
  * @covers ::bbp_get_forum_permalink
  */
 public function test_bbp_get_forum_permalink()
 {
     if (is_multisite()) {
         $this->markTestSkipped('Skipping URL tests in multiste for now.');
     }
     // Public category.
     $c = $this->factory->forum->create(array('post_title' => 'Public Category'));
     $category = bbp_get_forum_permalink($c);
     $this->assertSame('http://' . WP_TESTS_DOMAIN . '/?forum=public-category', $category);
     // Public forum of public category.
     $f = $this->factory->forum->create(array('post_title' => 'Public Forum', 'post_parent' => $c));
     $forum_permalink = bbp_get_forum_permalink($f);
     $this->expectOutputString($forum_permalink);
     bbp_forum_permalink($f);
     $forum = bbp_get_forum_permalink($f);
     $this->assertSame('http://' . WP_TESTS_DOMAIN . '/?forum=public-category/public-forum', $forum);
     // Private category.
     $c = $this->factory->forum->create(array('post_title' => 'Private Category'));
     $category = bbp_get_forum_permalink($c);
     $forum = bbp_get_forum_permalink($f);
     $this->assertSame('http://' . WP_TESTS_DOMAIN . '/?forum=private-category', $category);
     // Private forum of private category.
     $f = $this->factory->forum->create(array('post_title' => 'Private Forum', 'post_parent' => $c));
     bbp_privatize_forum($c);
     $forum = bbp_get_forum_permalink($f);
     $this->assertSame('http://' . WP_TESTS_DOMAIN . '/?forum=private-category/private-forum', $forum);
     // Hidden category.
     $c = $this->factory->forum->create(array('post_title' => 'Hidden Category'));
     bbp_hide_forum($c);
     $category = bbp_get_forum_permalink($c);
     $this->assertSame('http://' . WP_TESTS_DOMAIN . '/?forum=hidden-category', $category);
     // Hidden forum of hidden category.
     $f = $this->factory->forum->create(array('post_title' => 'Hidden Forum', 'post_parent' => $c));
     $forum = bbp_get_forum_permalink($f);
     $this->assertSame('http://' . WP_TESTS_DOMAIN . '/?forum=hidden-category/hidden-forum', $forum);
 }
コード例 #4
0
function custom_list_forums($args = '')
{
    // Define used variables
    global $rpg_settingsg;
    global $rpg_settingsf;
    $output = $sub_forums = $topic_count = $reply_count = $counts = '';
    $i = 0;
    $count = array();
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('before' => '<ul class="bbp-forums-list">', 'after' => '</ul>', 'link_before' => '<li class="bbp-forum">', 'link_after' => '</li>', 'count_before' => ' (', 'count_after' => ')', 'count_sep' => ', ', 'separator' => '<br> ', 'forum_id' => '', 'show_topic_count' => true, 'show_reply_count' => true), 'listb_forums');
    // Loop through forums and create a list
    $sub_forums = bbp_forum_get_subforums($r['forum_id']);
    if (!empty($sub_forums)) {
        // Total count (for separator)
        $total_subs = count($sub_forums);
        foreach ($sub_forums as $sub_forum) {
            $i++;
            // Separator count
            // Get forum details
            $count = array();
            $show_sep = $total_subs > $i ? $r['separator'] : '';
            $permalink = bbp_get_forum_permalink($sub_forum->ID);
            $title = bbp_get_forum_title($sub_forum->ID);
            $content = bbp_get_forum_content($sub_forum->ID);
            if ($rpg_settingsg['activate_descriptions'] == true) {
                $content = bbp_get_forum_content($sub_forum->ID);
            } else {
                $content = '';
            }
            // Show topic count
            if (!empty($r['show_topic_count']) && !bbp_is_forum_category($sub_forum->ID)) {
                $count['topic'] = bbp_get_forum_topic_count($sub_forum->ID);
            }
            // Show reply count
            if (!empty($r['show_reply_count']) && !bbp_is_forum_category($sub_forum->ID)) {
                $count['reply'] = bbp_get_forum_reply_count($sub_forum->ID);
            }
            // Counts to show
            if (!empty($count)) {
                $counts = $r['count_before'] . implode($r['count_sep'], $count) . $r['count_after'];
            }
            if ($rpg_settingsg['hide_counts'] == true) {
                $counts = '';
            }
            //Build this sub forums link
            if (bbp_is_forum_private($sub_forum->ID)) {
                if (!current_user_can('read_private_forums')) {
                    if (!$rpg_settingsf['redirect_page']) {
                        $link = '/home';
                    } else {
                        $link = $rpg_settingsf['redirect_page'];
                    }
                    $output .= $r['before'] . $r['link_before'] . '<a href="' . $link . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $r['link_after'] . '<div class="bbp-forum-content">' . $content . '</div>' . $r['after'];
                } else {
                    $output .= $r['before'] . $r['link_before'] . '<a href="' . esc_url($permalink) . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $r['link_after'] . '<div class="bbp-forum-content">' . $content . '</div>' . $r['after'];
                }
            } else {
                $output .= $r['before'] . $r['link_before'] . '<a href="' . esc_url($permalink) . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $r['link_after'] . '<div class="bbp-forum-content">' . $content . '</div>' . $r['after'];
            }
        }
        //Output the list
        return $output;
    }
}
コード例 #5
0
/**
 * Handles the front end opening/closing, spamming/unspamming,
 * sticking/unsticking and trashing/untrashing/deleting of topics
 *
 * @since bbPress (r2727)
 *
 * @param string $action The requested action to compare this function to
 * @uses bbp_get_topic() To get the topic
 * @uses current_user_can() To check if the user is capable of editing or
 *                           deleting the topic
 * @uses bbp_get_topic_post_type() To get the topic post type
 * @uses check_ajax_referer() To verify the nonce and check the referer
 * @uses bbp_is_topic_open() To check if the topic is open
 * @uses bbp_close_topic() To close the topic
 * @uses bbp_open_topic() To open the topic
 * @uses bbp_is_topic_sticky() To check if the topic is a sticky
 * @uses bbp_unstick_topic() To unstick the topic
 * @uses bbp_stick_topic() To stick the topic
 * @uses bbp_is_topic_spam() To check if the topic is marked as spam
 * @uses bbp_spam_topic() To make the topic as spam
 * @uses bbp_unspam_topic() To unmark the topic as spam
 * @uses wp_trash_post() To trash the topic
 * @uses wp_untrash_post() To untrash the topic
 * @uses wp_delete_post() To delete the topic
 * @uses do_action() Calls 'bbp_toggle_topic_handler' with success, post data
 *                    and action
 * @uses bbp_get_forum_permalink() To get the forum link
 * @uses bbp_get_topic_permalink() To get the topic link
 * @uses wp_safe_redirect() To redirect to the topic
 * @uses bbPress::errors:add() To log the error messages
 */
function bbp_toggle_topic_handler($action = '')
{
    // Bail if required GET actions aren't passed
    if (empty($_GET['topic_id'])) {
        return;
    }
    // Setup possible get actions
    $possible_actions = array('bbp_toggle_topic_close', 'bbp_toggle_topic_stick', 'bbp_toggle_topic_spam', 'bbp_toggle_topic_trash');
    // Bail if actions aren't meant for this function
    if (!in_array($action, $possible_actions)) {
        return;
    }
    $failure = '';
    // Empty failure string
    $view_all = false;
    // Assume not viewing all
    $topic_id = (int) $_GET['topic_id'];
    // What's the topic id?
    $success = false;
    // Flag
    $post_data = array('ID' => $topic_id);
    // Prelim array
    $redirect = '';
    // Empty redirect URL
    // Make sure topic exists
    $topic = bbp_get_topic($topic_id);
    if (empty($topic)) {
        return;
    }
    // What is the user doing here?
    if (!current_user_can('edit_topic', $topic->ID) || 'bbp_toggle_topic_trash' === $action && !current_user_can('delete_topic', $topic->ID)) {
        bbp_add_error('bbp_toggle_topic_permission', __('<strong>ERROR:</strong> You do not have the permission to do that.', 'bbpress'));
        return;
    }
    // What action are we trying to perform?
    switch ($action) {
        // Toggle open/close
        case 'bbp_toggle_topic_close':
            check_ajax_referer('close-topic_' . $topic_id);
            $is_open = bbp_is_topic_open($topic_id);
            $success = true === $is_open ? bbp_close_topic($topic_id) : bbp_open_topic($topic_id);
            $failure = true === $is_open ? __('<strong>ERROR</strong>: There was a problem closing the topic.', 'bbpress') : __('<strong>ERROR</strong>: There was a problem opening the topic.', 'bbpress');
            break;
            // Toggle sticky/super-sticky/unstick
        // Toggle sticky/super-sticky/unstick
        case 'bbp_toggle_topic_stick':
            check_ajax_referer('stick-topic_' . $topic_id);
            $is_sticky = bbp_is_topic_sticky($topic_id);
            $is_super = false === $is_sticky && !empty($_GET['super']) && "1" === $_GET['super'] ? true : false;
            $success = true === $is_sticky ? bbp_unstick_topic($topic_id) : bbp_stick_topic($topic_id, $is_super);
            $failure = true === $is_sticky ? __('<strong>ERROR</strong>: There was a problem unsticking the topic.', 'bbpress') : __('<strong>ERROR</strong>: There was a problem sticking the topic.', 'bbpress');
            break;
            // Toggle spam
        // Toggle spam
        case 'bbp_toggle_topic_spam':
            check_ajax_referer('spam-topic_' . $topic_id);
            $is_spam = bbp_is_topic_spam($topic_id);
            $success = true === $is_spam ? bbp_unspam_topic($topic_id) : bbp_spam_topic($topic_id);
            $failure = true === $is_spam ? __('<strong>ERROR</strong>: There was a problem unmarking the topic as spam.', 'bbpress') : __('<strong>ERROR</strong>: There was a problem marking the topic as spam.', 'bbpress');
            $view_all = !$is_spam;
            break;
            // Toggle trash
        // Toggle trash
        case 'bbp_toggle_topic_trash':
            $sub_action = !empty($_GET['sub_action']) && in_array($_GET['sub_action'], array('trash', 'untrash', 'delete')) ? $_GET['sub_action'] : false;
            if (empty($sub_action)) {
                break;
            }
            switch ($sub_action) {
                case 'trash':
                    check_ajax_referer('trash-' . bbp_get_topic_post_type() . '_' . $topic_id);
                    $view_all = true;
                    $success = wp_trash_post($topic_id);
                    $failure = __('<strong>ERROR</strong>: There was a problem trashing the topic.', 'bbpress');
                    break;
                case 'untrash':
                    check_ajax_referer('untrash-' . bbp_get_topic_post_type() . '_' . $topic_id);
                    $success = wp_untrash_post($topic_id);
                    $failure = __('<strong>ERROR</strong>: There was a problem untrashing the topic.', 'bbpress');
                    break;
                case 'delete':
                    check_ajax_referer('delete-' . bbp_get_topic_post_type() . '_' . $topic_id);
                    $success = wp_delete_post($topic_id);
                    $failure = __('<strong>ERROR</strong>: There was a problem deleting the topic.', 'bbpress');
                    break;
            }
            break;
    }
    // Do additional topic toggle actions
    do_action('bbp_toggle_topic_handler', $success, $post_data, $action);
    // No errors
    if (false !== $success && !is_wp_error($success)) {
        // Redirect back to the topic's forum
        if (isset($sub_action) && 'delete' === $sub_action) {
            $redirect = bbp_get_forum_permalink($success->post_parent);
            // Redirect back to the topic
        } else {
            // Get the redirect detination
            $permalink = bbp_get_topic_permalink($topic_id);
            $redirect = bbp_add_view_all($permalink, $view_all);
        }
        wp_safe_redirect($redirect);
        // For good measure
        exit;
        // Handle errors
    } else {
        bbp_add_error('bbp_toggle_topic', $failure);
    }
}
コード例 #6
0
/**
 * Return a breadcrumb ( forum -> topic -> reply )
 *
 * @since bbPress (r2589)
 *
 * @param string $sep Separator. Defaults to '&larr;'
 * @param bool $current_page Include the current item
 * @param bool $root Include the root page if one exists
 *
 * @uses get_post() To get the post
 * @uses bbp_get_forum_permalink() To get the forum link
 * @uses bbp_get_topic_permalink() To get the topic link
 * @uses bbp_get_reply_permalink() To get the reply link
 * @uses get_permalink() To get the permalink
 * @uses bbp_get_forum_post_type() To get the forum post type
 * @uses bbp_get_topic_post_type() To get the topic post type
 * @uses bbp_get_reply_post_type() To get the reply post type
 * @uses bbp_get_forum_title() To get the forum title
 * @uses bbp_get_topic_title() To get the topic title
 * @uses bbp_get_reply_title() To get the reply title
 * @uses get_the_title() To get the title
 * @uses apply_filters() Calls 'bbp_get_breadcrumb' with the crumbs
 * @return string Breadcrumbs
 */
function bbp_get_breadcrumb($args = array())
{
    // Turn off breadcrumbs
    if (apply_filters('bbp_no_breadcrumb', is_front_page())) {
        return;
    }
    // Define variables
    $front_id = $root_id = 0;
    $ancestors = $crumbs = $tag_data = array();
    $pre_root_text = $pre_front_text = $pre_current_text = '';
    $pre_include_root = $pre_include_home = $pre_include_current = true;
    /** Home Text *********************************************************/
    // No custom home text
    if (empty($args['home_text'])) {
        // Set home text to page title
        $front_id = get_option('page_on_front');
        if (!empty($front_id)) {
            $pre_front_text = get_the_title($front_id);
            // Default to 'Home'
        } else {
            $pre_front_text = __('Home', 'bbpress');
        }
    }
    /** Root Text *********************************************************/
    // No custom root text
    if (empty($args['root_text'])) {
        $page = bbp_get_page_by_path(bbp_get_root_slug());
        if (!empty($page)) {
            $root_id = $page->ID;
        }
        $pre_root_text = bbp_get_forum_archive_title();
    }
    /** Includes **********************************************************/
    // Root slug is also the front page
    if (!empty($front_id) && $front_id == $root_id) {
        $pre_include_root = false;
    }
    // Don't show root if viewing forum archive
    if (bbp_is_forum_archive()) {
        $pre_include_root = false;
    }
    // Don't show root if viewing page in place of forum archive
    if (!empty($root_id) && ((is_single() || is_page()) && $root_id == get_the_ID())) {
        $pre_include_root = false;
    }
    /** Current Text ******************************************************/
    // Forum archive
    if (bbp_is_forum_archive()) {
        $pre_current_text = bbp_get_forum_archive_title();
        // Topic archive
    } elseif (bbp_is_topic_archive()) {
        $pre_current_text = bbp_get_topic_archive_title();
        // View
    } elseif (bbp_is_single_view()) {
        $pre_current_text = bbp_get_view_title();
        // Single Forum
    } elseif (bbp_is_single_forum()) {
        $pre_current_text = bbp_get_forum_title();
        // Single Topic
    } elseif (bbp_is_single_topic()) {
        $pre_current_text = bbp_get_topic_title();
        // Single Topic
    } elseif (bbp_is_single_reply()) {
        $pre_current_text = bbp_get_reply_title();
        // Topic Tag (or theme compat topic tag)
    } elseif (bbp_is_topic_tag() || get_query_var('bbp_topic_tag') && !bbp_is_topic_tag_edit()) {
        // Always include the tag name
        $tag_data[] = bbp_get_topic_tag_name();
        // If capable, include a link to edit the tag
        if (current_user_can('manage_topic_tags')) {
            $tag_data[] = '<a href="' . bbp_get_topic_tag_edit_link() . '" class="bbp-edit-topic-tag-link">' . __('(Edit)', 'bbpress') . '</a>';
        }
        // Implode the results of the tag data
        $pre_current_text = sprintf(__('Topic Tag: %s', 'bbpress'), implode(' ', $tag_data));
        // Edit Topic Tag
    } elseif (bbp_is_topic_tag_edit()) {
        $pre_current_text = __('Edit', 'bbpress');
        // Single
    } else {
        $pre_current_text = get_the_title();
    }
    /** Parse Args ********************************************************/
    // Parse args
    $defaults = array('before' => '<div class="bbp-breadcrumb"><p>', 'after' => '</p></div>', 'sep' => __('&rsaquo;', 'bbpress'), 'pad_sep' => 1, 'include_home' => $pre_include_home, 'home_text' => $pre_front_text, 'include_root' => $pre_include_root, 'root_text' => $pre_root_text, 'include_current' => $pre_include_current, 'current_text' => $pre_current_text);
    $r = bbp_parse_args($args, $defaults, 'get_breadcrumb');
    extract($r);
    /** Ancestors *********************************************************/
    // Get post ancestors
    if (is_page() || is_single() || bbp_is_forum_edit() || bbp_is_topic_edit() || bbp_is_reply_edit()) {
        $ancestors = array_reverse(get_post_ancestors(get_the_ID()));
    }
    // Do we want to include a link to home?
    if (!empty($include_home) || empty($home_text)) {
        $crumbs[] = '<a href="' . trailingslashit(home_url()) . '" class="bbp-breadcrumb-home">' . $home_text . '</a>';
    }
    // Do we want to include a link to the forum root?
    if (!empty($include_root) || empty($root_text)) {
        // Page exists at root slug path, so use its permalink
        $page = bbp_get_page_by_path(bbp_get_root_slug());
        if (!empty($page)) {
            $root_url = get_permalink($page->ID);
            // Use the root slug
        } else {
            $root_url = get_post_type_archive_link(bbp_get_forum_post_type());
        }
        // Add the breadcrumb
        $crumbs[] = '<a href="' . $root_url . '" class="bbp-breadcrumb-root">' . $root_text . '</a>';
    }
    // Ancestors exist
    if (!empty($ancestors)) {
        // Loop through parents
        foreach ((array) $ancestors as $parent_id) {
            // Parents
            $parent = get_post($parent_id);
            // Switch through post_type to ensure correct filters are applied
            switch ($parent->post_type) {
                // Forum
                case bbp_get_forum_post_type():
                    $crumbs[] = '<a href="' . bbp_get_forum_permalink($parent->ID) . '" class="bbp-breadcrumb-forum">' . bbp_get_forum_title($parent->ID) . '</a>';
                    break;
                    // Topic
                // Topic
                case bbp_get_topic_post_type():
                    $crumbs[] = '<a href="' . bbp_get_topic_permalink($parent->ID) . '" class="bbp-breadcrumb-topic">' . bbp_get_topic_title($parent->ID) . '</a>';
                    break;
                    // Reply (Note: not in most themes)
                // Reply (Note: not in most themes)
                case bbp_get_reply_post_type():
                    $crumbs[] = '<a href="' . bbp_get_reply_permalink($parent->ID) . '" class="bbp-breadcrumb-reply">' . bbp_get_reply_title($parent->ID) . '</a>';
                    break;
                    // WordPress Post/Page/Other
                // WordPress Post/Page/Other
                default:
                    $crumbs[] = '<a href="' . get_permalink($parent->ID) . '" class="bbp-breadcrumb-item">' . get_the_title($parent->ID) . '</a>';
                    break;
            }
        }
        // Edit topic tag
    } elseif (bbp_is_topic_tag_edit()) {
        $crumbs[] = '<a href="' . get_term_link(bbp_get_topic_tag_id(), bbp_get_topic_tag_tax_id()) . '" class="bbp-breadcrumb-topic-tag">' . sprintf(__('Topic Tag: %s', 'bbpress'), bbp_get_topic_tag_name()) . '</a>';
    }
    /** Current ***********************************************************/
    // Add current page to breadcrumb
    if (!empty($include_current) || empty($pre_current_text)) {
        $crumbs[] = '<span class="bbp-breadcrumb-current">' . $current_text . '</span>';
    }
    /** Separator *********************************************************/
    // Wrap the separator in a span before padding and filter
    if (!empty($sep)) {
        $sep = '<span class="bbp-breadcrumb-separator">' . $sep . '</span>';
    }
    // Pad the separator
    if (!empty($pad_sep)) {
        $sep = str_pad($sep, strlen($sep) + (int) $pad_sep * 2, ' ', STR_PAD_BOTH);
    }
    /** Finish Up *********************************************************/
    // Filter the separator and breadcrumb
    $sep = apply_filters('bbp_breadcrumb_separator', $sep);
    $crumbs = apply_filters('bbp_breadcrumbs', $crumbs);
    // Build the trail
    $trail = !empty($crumbs) ? $before . implode($sep, $crumbs) . $after : '';
    return apply_filters('bbp_get_breadcrumb', $trail, $crumbs, $r);
}
コード例 #7
0
ファイル: activity.php プロジェクト: hscale/webento
 /**
  * Record an activity stream entry when a reply is created
  *
  * @since bbPress (r3395)
  * @param int $topic_id
  * @param int $forum_id
  * @param array $anonymous_data
  * @param int $topic_author_id
  * @uses bbp_get_reply_id()
  * @uses bbp_get_topic_id()
  * @uses bbp_get_forum_id()
  * @uses bbp_get_user_profile_link()
  * @uses bbp_get_reply_url()
  * @uses bbp_get_reply_content()
  * @uses bbp_get_topic_permalink()
  * @uses bbp_get_topic_title()
  * @uses bbp_get_forum_permalink()
  * @uses bbp_get_forum_title()
  * @uses bp_create_excerpt()
  * @uses apply_filters()
  * @return Bail early if topic is by anonywous user
  */
 public function reply_create($reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author_id)
 {
     // Do not log activity of anonymous users
     if (!empty($anonymous_data)) {
         return;
     }
     // Bail if site is private
     if (!bbp_is_site_public()) {
         return;
     }
     // Validate activity data
     $user_id = $reply_author_id;
     $reply_id = bbp_get_reply_id($reply_id);
     $topic_id = bbp_get_topic_id($topic_id);
     $forum_id = bbp_get_forum_id($forum_id);
     // Bail if user is not active
     if (bbp_is_user_inactive($user_id)) {
         return;
     }
     // Bail if reply is not published
     if (!bbp_is_reply_published($reply_id)) {
         return;
     }
     // Setup links for activity stream
     $user_link = bbp_get_user_profile_link($user_id);
     // Reply
     $reply_url = bbp_get_reply_url($reply_id);
     $reply_content = get_post_field('post_content', $reply_id, 'raw');
     // Topic
     $topic_permalink = bbp_get_topic_permalink($topic_id);
     $topic_title = get_post_field('post_title', $topic_id, 'raw');
     $topic_link = '<a href="' . $topic_permalink . '" title="' . $topic_title . '">' . $topic_title . '</a>';
     // Forum
     $forum_permalink = bbp_get_forum_permalink($forum_id);
     $forum_title = get_post_field('post_title', $forum_id, 'raw');
     $forum_link = '<a href="' . $forum_permalink . '" title="' . $forum_title . '">' . $forum_title . '</a>';
     // Activity action & text
     $activity_text = sprintf(__('%1$s replied to the topic %2$s in the forum %3$s', 'bbpress'), $user_link, $topic_link, $forum_link);
     $activity_action = apply_filters('bbp_activity_reply_create', $activity_text, $user_id, $reply_id, $topic_id);
     $activity_content = apply_filters('bbp_activity_reply_create_excerpt', bp_create_excerpt($reply_content), $reply_content);
     // Compile the activity stream results
     $activity = array('id' => $this->get_activity_id($reply_id), 'user_id' => $user_id, 'action' => $activity_action, 'content' => $activity_content, 'primary_link' => $reply_url, 'type' => $this->reply_create, 'item_id' => $reply_id, 'secondary_item_id' => $topic_id, 'recorded_time' => get_post_time('Y-m-d H:i:s', true, $reply_id), 'hide_sitewide' => !bbp_is_forum_public($forum_id, false));
     // Record the activity
     $activity_id = $this->record_activity($activity);
     // Add the activity entry ID as a meta value to the reply
     if (!empty($activity_id)) {
         update_post_meta($reply_id, '_bbp_activity_id', $activity_id);
     }
 }
コード例 #8
0
ファイル: bbp-forum-template.php プロジェクト: hscale/webento
/**
 * Retrieve the link for the forum replies feed
 *
 * @since bbPress (r3172)
 *
 * @param int $forum_id Optional. Forum ID.
 *
 * @uses bbp_get_forum_id()
 * @uses get_option()
 * @uses trailingslashit()
 * @uses bbp_get_forum_permalink()
 * @uses user_trailingslashit()
 * @uses bbp_get_forum_post_type()
 * @uses get_post_field()
 * @uses apply_filters()
 *
 * @return string
 */
function bbp_get_forum_replies_feed_link($forum_id = 0)
{
    // Validate forum id
    $forum_id = bbp_get_forum_id($forum_id);
    // Forum is valid
    if (!empty($forum_id)) {
        // Define local variable(s)
        $link = '';
        // Pretty permalinks
        if (get_option('permalink_structure')) {
            // Forum link
            $url = trailingslashit(bbp_get_forum_permalink($forum_id)) . 'feed';
            $url = user_trailingslashit($url, 'single_feed');
            $url = add_query_arg(array('type' => 'reply'), $url);
            // Unpretty permalinks
        } else {
            $url = home_url(add_query_arg(array('type' => 'reply', 'feed' => 'rss2', bbp_get_forum_post_type() => get_post_field('post_name', $forum_id))));
        }
        $link = '<a href="' . $url . '" class="bbp-forum-rss-link replies"><span>' . __('Replies', 'bbpress') . '</span></a>';
    }
    return apply_filters('bbp_get_forum_replies_feed_link', $link, $url, $forum_id);
}
コード例 #9
0
/**
 * Return the link to subscribe/unsubscribe from a forum or topic
 *
 * @since 2.0.0 bbPress (r2668)
 *
 * @param array $args This function supports these arguments:
 *  - subscribe: Subscribe text
 *  - unsubscribe: Unsubscribe text
 *  - user_id: User id
 *  - topic_id: Topic id
 *  - forum_id: Forum id
 *  - before: Before the link
 *  - after: After the link
 * @param int $user_id Optional. User id
 * @param bool $wrap Optional. If you want to wrap the link in <span id="subscription-toggle">.
 * @uses bbp_is_subscriptions_active() to check if subscriptions are active
 * @uses bbp_get_user_id() To get the user id
 * @uses bbp_get_user_id() To get the user id
 * @uses bbp_get_topic_id() To get the topic id
 * @uses bbp_get_forum_id() To get the forum id
 * @uses current_user_can() To check if the current user can edit user
 * @uses bbp_is_user_subscribed_to_forum() To check if the user is subscribed to the forum
 * @uses bbp_is_user_subscribed_to_topic() To check if the user is subscribed to the topic
 * @uses bbp_is_subscriptions() To check if it's the subscriptions page
 * @uses bbp_get_subscriptions_permalink() To get subscriptions link
 * @uses bbp_get_topic_permalink() To get topic link
 * @uses apply_filters() Calls 'bbp_get_user_subscribe_link' with the
 *                        link, args, user id & topic id
 * @return string Permanent link to topic
 */
function bbp_get_user_subscribe_link($args = array(), $user_id = 0, $wrap = true)
{
    if (!bbp_is_subscriptions_active()) {
        return;
    }
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('subscribe' => __('Subscribe', 'bbpress'), 'unsubscribe' => __('Unsubscribe', 'bbpress'), 'user_id' => 0, 'topic_id' => 0, 'forum_id' => 0, 'before' => '&nbsp;|&nbsp;', 'after' => ''), 'get_user_subscribe_link');
    // Validate user and object ID's
    $user_id = bbp_get_user_id($r['user_id'], true, true);
    $topic_id = bbp_get_topic_id($r['topic_id']);
    $forum_id = bbp_get_forum_id($r['forum_id']);
    if (empty($user_id) || empty($topic_id) && empty($forum_id)) {
        return false;
    }
    // No link if you can't edit yourself
    if (!current_user_can('edit_user', $user_id)) {
        return false;
    }
    // Check if viewing a single forum
    if (empty($topic_id) && !empty($forum_id)) {
        // Decide which link to show
        $is_subscribed = bbp_is_user_subscribed_to_forum($user_id, $forum_id);
        if (!empty($is_subscribed)) {
            $text = $r['unsubscribe'];
            $query_args = array('action' => 'bbp_unsubscribe', 'forum_id' => $forum_id);
        } else {
            $text = $r['subscribe'];
            $query_args = array('action' => 'bbp_subscribe', 'forum_id' => $forum_id);
        }
        // Create the link based where the user is and if the user is
        // subscribed already
        if (bbp_is_subscriptions()) {
            $permalink = bbp_get_subscriptions_permalink($user_id);
        } elseif (bbp_is_single_forum() || bbp_is_single_reply()) {
            $permalink = bbp_get_forum_permalink($forum_id);
        } else {
            $permalink = get_permalink();
        }
        $url = esc_url(wp_nonce_url(add_query_arg($query_args, $permalink), 'toggle-subscription_' . $forum_id));
        $sub = $is_subscribed ? ' class="is-subscribed"' : '';
        $html = sprintf('%s<span id="subscribe-%d"  %s><a href="%s" class="subscription-toggle" data-forum="%d">%s</a></span>%s', $r['before'], $forum_id, $sub, $url, $forum_id, $text, $r['after']);
        // Initial output is wrapped in a span, ajax output is hooked to this
        if (!empty($wrap)) {
            $html = '<span id="subscription-toggle">' . $html . '</span>';
        }
    } else {
        // Decide which link to show
        $is_subscribed = bbp_is_user_subscribed_to_topic($user_id, $topic_id);
        if (!empty($is_subscribed)) {
            $text = $r['unsubscribe'];
            $query_args = array('action' => 'bbp_unsubscribe', 'topic_id' => $topic_id);
        } else {
            $text = $r['subscribe'];
            $query_args = array('action' => 'bbp_subscribe', 'topic_id' => $topic_id);
        }
        // Create the link based where the user is and if the user is
        // subscribed already
        if (bbp_is_subscriptions()) {
            $permalink = bbp_get_subscriptions_permalink($user_id);
        } elseif (bbp_is_single_topic() || bbp_is_single_reply()) {
            $permalink = bbp_get_topic_permalink($topic_id);
        } else {
            $permalink = get_permalink();
        }
        $url = esc_url(wp_nonce_url(add_query_arg($query_args, $permalink), 'toggle-subscription_' . $topic_id));
        $sub = $is_subscribed ? ' class="is-subscribed"' : '';
        $html = sprintf('%s<span id="subscribe-%d"  %s><a href="%s" class="subscription-toggle" data-topic="%d">%s</a></span>%s', $r['before'], $topic_id, $sub, $url, $topic_id, $text, $r['after']);
        // Initial output is wrapped in a span, ajax output is hooked to this
        if (!empty($wrap)) {
            $html = '<span id="subscription-toggle">' . $html . '</span>';
        }
    }
    // Return the link
    return apply_filters('bbp_get_user_subscribe_link', $html, $r, $user_id, $topic_id);
}
コード例 #10
0
ファイル: functions.php プロジェクト: 082net/bbpresskr
function bbp_get_topic_forum_link($args = '')
{
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('id' => 0, 'link_before' => '', 'link_after' => '', 'edit_text' => esc_html__('List', 'bbpress')), 'get_topic_forum_link');
    // Get uri
    $uri = bbp_get_forum_permalink(bbp_get_topic_forum_id($r['id']));
    // Bail if no uri
    if (empty($uri)) {
        return;
    }
    $retval = $r['link_before'] . '<a href="' . esc_url($uri) . '" class="bbp-topic-forum-link">' . $r['edit_text'] . '</a>' . $r['link_after'];
    return apply_filters('bbp_get_topic_forum_link', $retval, $r);
}
コード例 #11
0
ファイル: bbpress.php プロジェクト: tamriel-foundry/apoc2
/**
 * Display nested subforums with a hierarchical structure using their parent category
 * @version 2.0
 */
function apoc_loop_subforums()
{
    // Exclude private forums
    $private = apoc_private_forum_ids();
    // Check for subforums
    $subs = bbp_forum_get_subforums(array('post__not_in' => $private));
    if (empty($subs)) {
        return;
    }
    // Buffer output
    ob_start();
    // Print a header
    ?>
	<header class="forum-header">
		<div class="forum-content"><h2><?php 
    bbp_forum_title();
    ?>
</h2></div>
		<div class="forum-count">Topics</div>
		<div class="forum-freshness">Latest Post</div>
	</header>
	<ol class="forums category <?php 
    bbp_forum_status();
    ?>
"><?php 
    // Loop over forums
    foreach ($subs as $count => $sub) {
        // Get forum details
        $sub_id = $sub->ID;
        $title = $sub->post_title;
        $desc = $sub->post_content;
        $permalink = bbp_get_forum_permalink($sub_id);
        // Get topic counts
        $topics = bbp_get_forum_topic_count($sub_id, false);
        // Get the most recent reply and its topic
        $reply_id = bbp_get_forum_last_reply_id($sub_id);
        $topic_id = bbp_is_reply($reply_id) ? bbp_get_reply_topic_id($reply_id) : $reply_id;
        $topic_title = bbp_get_topic_title($topic_id);
        $link = bbp_get_reply_url($reply_id);
        // Get the author avatar
        $user_id = bbp_get_reply_author_id($reply_id);
        $avatar = apoc_get_avatar(array('user_id' => $user_id, 'link' => true, 'size' => 50));
        // Toggle html class
        $class = $count % 2 ? 'odd' : 'even';
        // Print output
        ?>
		<li id="forum-<?php 
        echo $sub_id;
        ?>
" class="forum <?php 
        echo $class;
        ?>
">
			<div class="forum-content">
				<h3 class="forum-title"><a href="<?php 
        echo $permalink;
        ?>
" title="Browse <?php 
        echo $title;
        ?>
"><?php 
        echo $title;
        ?>
</a></h3>
				<p class="forum-description"><?php 
        echo $desc;
        ?>
</p>
			</div>

			<div class="forum-count">
				<?php 
        echo $topics;
        ?>
			</div>

			<div class="forum-freshness">
				<?php 
        echo $avatar;
        ?>
				<div class="freshest-meta">
					<a class="freshest-title" href="<?php 
        echo $link;
        ?>
" title="<?php 
        echo $topic_title;
        ?>
"><?php 
        echo $topic_title;
        ?>
</a>
					<span class="freshest-author">By <?php 
        bbp_author_link(array('post_id' => $reply_id, 'type' => 'name'));
        ?>
</span>
					<span class="freshest-time"><?php 
        bbp_topic_last_active_time($topic_id);
        ?>
</span>
				</div>
			</div>
		</li>
	<?php 
    }
    ?>
	</ol>
		
	<?php 
    // Retrieve from buffer
    $output = ob_get_contents();
    ob_end_clean();
    echo $output;
}
コード例 #12
0
function ajax_custom_load_posts()
{
    if (check_ajax_referer(__FUNCTION__, 'nonce', false)) {
        $query = $_POST['query'] ? $_POST['query'] : array();
        $posts = get_posts($query);
        echo '<hr />';
        foreach ($posts as $post) {
            setup_postdata($post);
            ?>
		  	<?php 
            if (BBPMC_get_reviewed_status($post->ID) == 'yes') {
                $reviewText = '<span style="color:green">&#9679; Reviewed </span>';
            } else {
                $reviewText = '<span style="color:red">&#9679; Not Reviewed </span>';
            }
            ?>
			<li class="clearfix post-<?php 
            echo $post->ID;
            ?>
">
				<div class="mainInfo">
					<a class="contentExpander">
						<?php 
            echo get_the_title($post->ID);
            ?>
					</a>
					<div style="display:none;" class="expandContent">
						<?php 
            echo $post->post_content;
            ?>
					</div>
					<span>

						<?php 
            echo mysql2date('Y-m-d h:i:s', $post->post_date);
            ?>
					</span>
				</div>
				<div class="actions">
					<a class="reviewLink" onClick="BBPMC_modConsole.setReviewed(<?php 
            echo $post->ID;
            ?>
,'<?php 
            echo BBPMC_get_reviewed_status($post->ID);
            ?>
' )"><?php 
            echo $reviewText;
            ?>
</a>
					<div class="note">
						<a href="<?php 
            echo bbp_get_forum_permalink($post->post_parent);
            ?>
#post-<?php 
            echo $post->ID;
            ?>
">Go to thread</a> | <a onclick="BBPMC_modConsole.moveToTrash(<?php 
            echo $post->ID;
            ?>
)">Move to trash</a>
					</div>
				</div>
			</li>
		<?php 
        }
        wp_reset_postdata();
        echo '<div id="nonce" style="display: none">' . wp_create_nonce(__FUNCTION__) . '</div>';
    } else {
        die('Invalid request.');
    }
    die;
}
コード例 #13
0
			<th>Posts</th>
			<th>Last Post</th>
		</tr>

		<?php 
		// Buffer output
		ob_start();
		
			// Loop over forums
		foreach ( $subs as $count => $sub ) :

				// Get forum details
			$sub_id			= $sub->ID;
			$title			= $sub->post_title;
			$desc			= $sub->post_content;
			$permalink		= bbp_get_forum_permalink( $sub_id );

					// Get topic counts
			$topics	 		= bbp_get_forum_topic_count( $sub_id , true );

					// Get the most recent reply and its topic
			$reply_id		= bbp_get_forum_last_reply_id( $sub_id );
			$topic_id		= bbp_is_reply( $reply_id ) ? bbp_get_reply_topic_id( $reply_id ) : $reply_id;
			$topic_title	= bbp_get_topic_title( $topic_id );
			$link 			= bbp_get_reply_url( $reply_id );

					// Get the author 
			$user_id 		= bbp_get_reply_author_id( $reply_id );

					// Toggle html class?>
コード例 #14
0
    public static function roost_bbp_forum_subscription( $post ) {
        global $post;
        $post_id = $post->ID;

        $url = bbp_get_forum_permalink( $post_id );

        $roost_bbp_subscriptions = get_post_meta( $post_id, '_roost_bbp_subscription', true );

        echo( sprintf( "<span id='roost-subscribe-%d' style='display:none;'><a href='%s' data-post='%d' class='roost-forum-subscribe-link' class='subscription-toggle'></a></span>", $post_id, $url, $post_id ) );
        ?>
        <script>
            jQuery(document).ready(function($) {
                var subscribeLink = $('.roost-forum-subscribe-link');
                var subscribeWrap = $('#roost-subscribe-<?php echo( $post_id ); ?>');
                <?php
                    if ( ! empty( $roost_bbp_subscriptions ) ) {
                        $reply_bbp_subscriptions = json_encode( $roost_bbp_subscriptions );
                ?>
                        var registrations = <?php echo( $reply_bbp_subscriptions ); ?>;
                <?php
                    } else {
                ?>
                        var registrations = [];
                <?php
                    }
                ?>

                setTimeout(function(){
                    if ( window.roostEnabled ){
                        if ( 'undefined' !== typeof registrations[window.roostToken] ) {
                            if ( true === registrations[window.roostToken] ) {
                                subscribeLink.text( 'Unsubscribe from Push Notifications' );
                                subscribeLink.data( 'action', 'roost_bbp_unsubscribe' );
                            }
                        } else {
                            subscribeLink.text( 'Subscribe with Push Notifications' );
                            subscribeLink.data( 'action', 'roost_bbp_subscribe' );
                        }
                        <?php
                            if ( true === bbp_is_subscriptions_active() && true === is_user_logged_in() ) {
                        ?>
                            subscribeWrap.detach().appendTo( '#subscription-toggle' ).show();
                            subscribeWrap.prepend( ' | ' );
                        <?php
                            } else {
                        ?>
                            subscribeWrap.wrap( "<div id='subscription-toggle'></div>" ).show();
                        <?php
                            }
                        ?>
                    }
                }, 1500);

                subscribeLink.on( 'click', function( e ){
                    e.preventDefault();
                    var data = {
                        link: subscribeLink.attr( 'href' ),
                        action: subscribeLink.data( 'action' ),
                        roostToken: window.roostToken,
                        postID: subscribeLink.data( 'post' ),
                    };
                    if ( 'roost_bbp_subscribe' === subscribeLink.data( 'action' ) ){
                        subscribeLink.text( 'Unsubscribe from Push Notifications' );
                        subscribeLink.data( 'action', 'roost_bbp_unsubscribe' );
                    } else {
                        subscribeLink.text( 'Subscribe with Push Notifications' );
                        subscribeLink.data( 'action', 'roost_bbp_subscribe' );
                    }

                    $.post( ajaxurl, data, function( response ) {

                    });
                });
            });
        </script>
        <?php
    }
コード例 #15
0
ファイル: list-table.php プロジェクト: 082net/bbpresskr
 protected function get_views()
 {
     global $post;
     $views = array();
     if (bbp_is_forum_category() && bbp_has_forums()) {
         $views['all'] = '<a class="current bbp-forum-title" href="' . bbp_get_forum_permalink() . '">' . __('All', 'bbpresskr') . '</a>';
         while (bbp_forums()) {
             bbp_the_forum();
             $views[] = '<a class="bbp-forum-title" href="' . bbp_get_forum_permalink() . '">' . bbp_get_forum_title() . '</a>';
         }
     } else {
         $forum_id = bbp_get_forum_id();
         $forum = get_post($forum_id);
         if ($forum->post_parent && bbp_has_forums(array('post_parent' => $forum->post_parent))) {
             $views['all'] = '<a class="bbp-forum-title" href="' . bbp_get_forum_permalink($forum->post_parent) . '">' . __('All', 'bbpresskr') . '</a>';
             while (bbp_forums()) {
                 bbp_the_forum();
                 $current = $forum_id == $post->ID ? ' current' : '';
                 $views[$post->post_name] = '<a class="bbp-forum-title' . $current . '" href="' . bbp_get_forum_permalink() . '">' . bbp_get_forum_title() . '</a>';
             }
         }
     }
     return $views;
 }
コード例 #16
0
ファイル: bbpress.php プロジェクト: datracka/datalook.io
    function x_bbpress_add_actions_replies()
    {
        ?>

    <?php 
        if (!bbp_show_lead_topic() && !bbp_is_single_user_replies() && !x_is_buddypress_user()) {
            ?>

      <div class="x-bbp-header">
        <div class="actions">
          <a href="<?php 
            echo bbp_get_forum_permalink(bbp_get_topic_forum_id());
            ?>
"><?php 
            _e('To Parent Forum', '__x__');
            ?>
</a>
          <?php 
            bbp_topic_subscription_link();
            ?>
          <?php 
            bbp_user_favorites_link();
            ?>
        </div>
      </div>

    <?php 
        }
        ?>

  <?php 
    }
コード例 #17
0
 /**
  * Handles the front end reporting/un-reporting of topics
  *
  * @since 1.0.0
  *
  * @param string $action The requested action to compare this function to
  */
 public function toggle_topic_handler($action = '')
 {
     // Bail if required GET actions aren't passed
     if (empty($_GET['topic_id'])) {
         return;
     }
     // Setup possible get actions
     $possible_actions = array('bbp_rc_toggle_topic_report');
     // Bail if actions aren't meant for this function
     if (!in_array($action, $possible_actions)) {
         return;
     }
     $failure = '';
     // Empty failure string
     $view_all = false;
     // Assume not viewing all
     $topic_id = (int) $_GET['topic_id'];
     // What's the topic id?
     $success = false;
     // Flag
     $post_data = array('ID' => $topic_id);
     // Prelim array
     $redirect = '';
     // Empty redirect URL
     // Make sure topic exists
     $topic = bbp_get_topic($topic_id);
     if (empty($topic)) {
         return;
     }
     // Bail if non-logged-in user
     if (!is_user_logged_in()) {
         return;
     }
     // What action are we trying to perform?
     switch ($action) {
         // Toggle reported
         case 'bbp_rc_toggle_topic_report':
             check_ajax_referer('report-topic_' . $topic_id);
             $is_reported = $this->is_topic_reported($topic_id);
             $success = true === $is_reported ? $this->unreport_topic($topic_id) : $this->report_topic($topic_id);
             $failure = true === $is_reported ? __('<strong>ERROR</strong>: There was a problem unmarking the topic as reported.', 'bbpress-report-content') : __('<strong>ERROR</strong>: There was a problem reporting the topic.', 'bbpress-report-content');
             // $view_all = !$is_reported; // Only need this if we want to hide it, like spam
             break;
     }
     // No errors
     if (false !== $success && !is_wp_error($success)) {
         // Redirect back to the topic's forum
         if (isset($sub_action) && 'delete' === $sub_action) {
             $redirect = bbp_get_forum_permalink($success->post_parent);
             // Redirect back to the topic
         } else {
             // Get the redirect destination
             $permalink = bbp_get_topic_permalink($topic_id);
             $redirect = bbp_add_view_all($permalink, $view_all);
         }
         wp_safe_redirect($redirect);
         // For good measure
         exit;
         // Handle errors
     } else {
         bbp_add_error('bbp_rc_toggle_topic', $failure);
     }
 }
コード例 #18
0
ファイル: bbp-core-classes.php プロジェクト: hscale/webento
 /**
  * @see Walker::start_el()
  *
  * @since bbPress (r2514)
  *
  * @param string $output Passed by reference. Used to append additional
  *                        content.
  * @param object $forum Page data object.
  * @param int $depth Depth of page. Used for padding.
  * @param int $current_forum Page ID.
  * @param array $args
  */
 public function start_el(&$output, $forum, $depth, $args, $current_forum)
 {
     $indent = $depth ? str_repeat("\t", $depth) : '';
     extract($args, EXTR_SKIP);
     $css_class = array('bbp-forum-item', 'bbp-forum-item-' . $forum->ID);
     if (!empty($current_forum)) {
         $_current_page = bbp_get_forum($current_forum);
         if (isset($_current_page->ancestors) && in_array($forum->ID, (array) $_current_page->ancestors)) {
             $css_class[] = 'bbp-current-forum-ancestor';
         }
         if ($forum->ID == $current_forum) {
             $css_class[] = 'bbp_current_forum_item';
         } elseif ($_current_page && $forum->ID == $_current_page->post_parent) {
             $css_class[] = 'bbp-current-forum-parent';
         }
     } elseif ($forum->ID == get_option('page_for_posts')) {
         $css_class[] = 'bbp-current-forum-parent';
     }
     $css_class = implode(' ', apply_filters('bbp_forum_css_class', $css_class, $forum));
     $output .= $indent . '<li class="' . $css_class . '"><a href="' . bbp_get_forum_permalink($forum->ID) . '" title="' . esc_attr(wp_strip_all_tags(apply_filters('the_title', $forum->post_title, $forum->ID))) . '">' . $link_before . apply_filters('the_title', $forum->post_title, $forum->ID) . $link_after . '</a>';
     if (!empty($show_date)) {
         $time = 'modified' == $show_date ? $forum->post_modified : ($time = $forum->post_date);
         $output .= " " . mysql2date($date_format, $time);
     }
 }
コード例 #19
0
<div id="bbpress-forums">

	<?php 
    bbp_breadcrumb();
    ?>

<?php 
}
?>
	<div id="no-reply-<?php 
bbp_topic_id();
?>
" class="bbp-no-reply">
		<div class="bbp-template-notice">
			<?php 
$permalink = bbp_get_forum_permalink(bbp_get_topic_forum_id(bbp_get_topic_id())) . '#new-post';
?>
			<p><?php 
printf(__('You cannot reply to this support topic. <a href="%s">Please open your own support topic.</a>', 'bbpress'), $permalink);
?>
</p>
		</div>
	</div>

<?php 
if (bbp_is_reply_edit()) {
    ?>

</div>

<?php 
コード例 #20
0
/**
 * Do the actual topic toggling
 *
 * This function is used by `bbp_toggle_topic_handler()` to do the actual heavy
 * lifting when it comes to toggling topic. It only really makes sense to call
 * within that context, so if you need to call this function directly, make sure
 * you're also doing what the handler does too.
 *
 * @since 2.6.0  bbPress (r6133)
 * @access private
 *
 * @param array $args
 */
function bbp_toggle_topic($args = array())
{
    // Parse the arguments
    $r = bbp_parse_args($args, array('id' => 0, 'action' => '', 'sub_action' => '', 'data' => array()));
    // Build the nonce suffix
    $nonce_suffix = bbp_get_topic_post_type() . '_' . (int) $r['id'];
    // Default return values
    $retval = array('status' => 0, 'message' => '', 'redirect_to' => bbp_get_topic_permalink($r['id'], bbp_get_redirect_to()), 'view_all' => false);
    // What action are we trying to perform?
    switch ($r['action']) {
        // Toggle approve/unapprove
        case 'bbp_toggle_topic_approve':
            check_ajax_referer("approve-{$nonce_suffix}");
            $is_pending = bbp_is_topic_pending($r['id']);
            $retval['view_all'] = !$is_pending;
            // Toggle
            $retval['status'] = true === $is_pending ? bbp_approve_topic($r['id']) : bbp_unapprove_topic($r['id']);
            // Feedback
            $retval['message'] = true === $is_pending ? __('<strong>ERROR</strong>: There was a problem approving the topic.', 'bbpress') : __('<strong>ERROR</strong>: There was a problem unapproving the topic.', 'bbpress');
            break;
            // Toggle open/close
        // Toggle open/close
        case 'bbp_toggle_topic_close':
            check_ajax_referer("close-{$nonce_suffix}");
            $is_open = bbp_is_topic_open($r['id']);
            // Toggle
            $retval['status'] = true === $is_open ? bbp_close_topic($r['id']) : bbp_open_topic($r['id']);
            // Feedback
            $retval['message'] = true === $is_open ? __('<strong>ERROR</strong>: There was a problem closing the topic.', 'bbpress') : __('<strong>ERROR</strong>: There was a problem opening the topic.', 'bbpress');
            break;
            // Toggle sticky/super-sticky/unstick
        // Toggle sticky/super-sticky/unstick
        case 'bbp_toggle_topic_stick':
            check_ajax_referer("stick-{$nonce_suffix}");
            $is_sticky = bbp_is_topic_sticky($r['id']);
            $is_super = false === $is_sticky && !empty($_GET['super']) && "1" === $_GET['super'] ? true : false;
            // Toggle
            $retval['status'] = true === $is_sticky ? bbp_unstick_topic($r['id']) : bbp_stick_topic($r['id'], $is_super);
            // Feedback
            $retval['message'] = true === $is_sticky ? __('<strong>ERROR</strong>: There was a problem unsticking the topic.', 'bbpress') : __('<strong>ERROR</strong>: There was a problem sticking the topic.', 'bbpress');
            break;
            // Toggle spam
        // Toggle spam
        case 'bbp_toggle_topic_spam':
            check_ajax_referer("spam-{$nonce_suffix}");
            $is_spam = bbp_is_topic_spam($r['id']);
            $retval['view_all'] = !$is_spam;
            // Toggle
            $retval['status'] = true === $is_spam ? bbp_unspam_topic($r['id']) : bbp_spam_topic($r['id']);
            // Feedback
            $retval['message'] = true === $is_spam ? __('<strong>ERROR</strong>: There was a problem unmarking the topic as spam.', 'bbpress') : __('<strong>ERROR</strong>: There was a problem marking the topic as spam.', 'bbpress');
            break;
            // Toggle trash
        // Toggle trash
        case 'bbp_toggle_topic_trash':
            switch ($r['sub_action']) {
                case 'trash':
                    check_ajax_referer("trash-{$nonce_suffix}");
                    $retval['view_all'] = true;
                    $retval['status'] = wp_trash_post($r['id']);
                    $retval['message'] = __('<strong>ERROR</strong>: There was a problem trashing the topic.', 'bbpress');
                    break;
                case 'untrash':
                    check_ajax_referer("untrash-{$nonce_suffix}");
                    $retval['status'] = wp_untrash_post($r['id']);
                    $retval['message'] = __('<strong>ERROR</strong>: There was a problem untrashing the topic.', 'bbpress');
                    break;
                case 'delete':
                    check_ajax_referer("delete-{$nonce_suffix}");
                    $retval['status'] = wp_delete_post($r['id']);
                    $retval['message'] = __('<strong>ERROR</strong>: There was a problem deleting the topic.', 'bbpress');
                    break;
            }
            break;
    }
    // Maybe redirect back to the topic's forum
    if (isset($r['sub_action']) && 'delete' === $r['sub_action']) {
        $retval['redirect_to'] = bbp_get_forum_permalink($retval['status']->post_parent);
    }
    // Add view all if needed
    if (!empty($retval['view_all'])) {
        $retval['redirect_to'] = bbp_add_view_all($retval['redirect_to'], true);
    }
    // Filter & return
    return apply_filters('bbp_toggle_topic', $retval, $r, $args);
}
コード例 #21
0
ファイル: bbp-forums.php プロジェクト: hscale/webento
 /**
  * Custom user feedback messages for forum post type
  *
  * @since bbPress (r3080)
  *
  * @global int $post_ID
  * @uses bbp_get_forum_permalink()
  * @uses wp_post_revision_title()
  * @uses esc_url()
  * @uses add_query_arg()
  *
  * @param array $messages
  *
  * @return array
  */
 public function updated_messages($messages)
 {
     global $post_ID;
     if ($this->bail()) {
         return $messages;
     }
     // URL for the current forum
     $forum_url = bbp_get_forum_permalink($post_ID);
     // Current forum's post_date
     $post_date = bbp_get_global_post_field('post_date', 'raw');
     // Messages array
     $messages[$this->post_type] = array(0 => '', 1 => sprintf(__('Forum updated. <a href="%s">View forum</a>', 'bbpress'), $forum_url), 2 => __('Custom field updated.', 'bbpress'), 3 => __('Custom field deleted.', 'bbpress'), 4 => __('Forum updated.', 'bbpress'), 5 => isset($_GET['revision']) ? sprintf(__('Forum restored to revision from %s', 'bbpress'), wp_post_revision_title((int) $_GET['revision'], false)) : false, 6 => sprintf(__('Forum created. <a href="%s">View forum</a>', 'bbpress'), $forum_url), 7 => __('Forum saved.', 'bbpress'), 8 => sprintf(__('Forum submitted. <a target="_blank" href="%s">Preview forum</a>', 'bbpress'), esc_url(add_query_arg('preview', 'true', $forum_url))), 9 => sprintf(__('Forum scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview forum</a>', 'bbpress'), date_i18n(__('M j, Y @ G:i', 'bbpress'), strtotime($post_date)), $forum_url), 10 => sprintf(__('Forum draft updated. <a target="_blank" href="%s">Preview forum</a>', 'bbpress'), esc_url(add_query_arg('preview', 'true', $forum_url))));
     return $messages;
 }
コード例 #22
0
function my_topic_edit_handler()
{
    //error_log("og reply id:".$_POST['bbp_reply_id']);
    //error_log("og redirect:".bbp_get_redirect_to());
    //error_log("page uri:".$_SERVER['REQUEST_URI']);
    // Edit replies do not have the url that we don't want to cache (unlike new posts).
    // In order to disable the cache for the editing user for this topic, we need to obtain
    // its url
    // Get the post id
    $mytopicid = (int) $_POST['bbp_topic_id'];
    // Get the full redirect url
    $myredirect = bbp_get_redirect_to();
    $myreplyurl = bbp_get_topic_permalink($mytopicid);
    $myforumid = bbp_get_topic_forum_id($mytopicid);
    error_log("topic url: " . $myreplyurl . " og topic id: " . $_POST['bbp_topic_id'] . " og forumid: " . $myforumid);
    // Get rid of the extras (such as the domain name and the #post123)
    $myreplyurlpart = trim(preg_replace("/([^\\/]+\$)/", "", preg_replace("/^https?:\\/\\/[^\\/]+(\\/*.+\\/).*/", " \$1 ", $myreplyurl)));
    $myforumurl = bbp_get_forum_permalink($myforumid);
    $myforumurlpart = trim(preg_replace("/([^\\/]+\$)/", "", preg_replace("/^https?:\\/\\/[^\\/]+(\\/*.+\\/).*/", " \$1 ", $myforumurl)));
    //error_log("og reply url:".home_url());
    // Don't cache the topic so that the user can see their updated content and title
    error_log("og topic uri:" . $myreplyurlpart);
    my_disable_page_cache($myreplyurlpart);
    error_log("og topic uri:" . $myreplyurlpart);
    error_log("og forum uri:" . $myforumurlpart);
    // Don't cache the forum so that the user can see their updated title
    my_disable_page_cache($myreplyurlpart);
}
コード例 #23
0
<?php

/** Single topic meta */
?>


<div class="bbp-single-topic-meta">
	
	<div class="back-to">
		<a href="<?php 
echo bbp_get_forum_permalink();
?>
">&larr; Back to discussions</a>
	</div>


	<div class="posted-in">
		Posted in: <?php 
echo '<a href="' . bbp_get_forum_permalink() . '" class="parent-forum">' . bbp_get_forum_title(bbp_get_topic_forum_id()) . '</a>';
?>
 &nbsp;
	</div>
	
</div>
コード例 #24
0
ファイル: groups.php プロジェクト: luskyj89/mt-wordpress
        /**
         * Output the forums for a group in the edit screens
         *
         * As of right now, bbPress only supports 1-to-1 group forum relationships.
         * In the future, many-to-many should be allowed.
         *
         * @since bbPress (r3653)
         * @uses bp_get_current_group_id()
         * @uses bbp_get_group_forum_ids()
         * @uses bbp_has_forums()
         * @uses bbp_get_template_part()
         */
        public function display_forums($offset = 0)
        {
            global $wp_query;
            // Allow actions immediately before group forum output
            do_action('bbp_before_group_forum_display');
            // Load up bbPress once
            $bbp = bbpress();
            /** Query Resets ******************************************************/
            // Forum data
            $forum_action = bp_action_variable($offset);
            $forum_ids = bbp_get_group_forum_ids(bp_get_current_group_id());
            $forum_id = array_shift($forum_ids);
            // Always load up the group forum
            bbp_has_forums(array('p' => $forum_id, 'post_parent' => null));
            // Set the global forum ID
            $bbp->current_forum_id = $forum_id;
            // Assume forum query
            bbp_set_query_name('bbp_single_forum');
            ?>

		<div id="bbpress-forums">

			<?php 
            switch ($forum_action) {
                /** Single Forum **********************************************/
                case false:
                case 'page':
                    // Strip the super stickies from topic query
                    add_filter('bbp_get_super_stickies', array($this, 'no_super_stickies'), 10, 1);
                    // Unset the super sticky option on topic form
                    add_filter('bbp_get_topic_types', array($this, 'unset_super_sticky'), 10, 1);
                    // Query forums and show them if they exist
                    if (bbp_forums()) {
                        // Setup the forum
                        bbp_the_forum();
                        ?>

						<h3><?php 
                        bbp_forum_title();
                        ?>
</h3>

						<?php 
                        bbp_get_template_part('content', 'single-forum');
                        // No forums found
                    } else {
                        ?>

						<div id="message" class="info">
							<p><?php 
                        esc_html_e('This group does not currently have a forum.', 'bbpress');
                        ?>
</p>
						</div>

					<?php 
                    }
                    break;
                    /** Single Topic **********************************************/
                /** Single Topic **********************************************/
                case $this->topic_slug:
                    // hide the 'to front' admin links
                    add_filter('bbp_get_topic_stick_link', array($this, 'hide_super_sticky_admin_link'), 10, 2);
                    // Get the topic
                    bbp_has_topics(array('name' => bp_action_variable($offset + 1), 'posts_per_page' => 1, 'show_stickies' => false));
                    // If no topic, 404
                    if (!bbp_topics()) {
                        bp_do_404(bbp_get_forum_permalink($forum_id));
                        ?>
						<h3><?php 
                        bbp_forum_title();
                        ?>
</h3>
						<?php 
                        bbp_get_template_part('feedback', 'no-topics');
                        return;
                    }
                    // Setup the topic
                    bbp_the_topic();
                    ?>

					<h3><?php 
                    bbp_topic_title();
                    ?>
</h3>

					<?php 
                    // Topic edit
                    if (bp_action_variable($offset + 2) === bbp_get_edit_rewrite_id()) {
                        // Unset the super sticky link on edit topic template
                        add_filter('bbp_get_topic_types', array($this, 'unset_super_sticky'), 10, 1);
                        // Set the edit switches
                        $wp_query->bbp_is_edit = true;
                        $wp_query->bbp_is_topic_edit = true;
                        // Setup the global forum ID
                        $bbp->current_topic_id = get_the_ID();
                        // Merge
                        if (!empty($_GET['action']) && 'merge' === $_GET['action']) {
                            bbp_set_query_name('bbp_topic_merge');
                            bbp_get_template_part('form', 'topic-merge');
                            // Split
                        } elseif (!empty($_GET['action']) && 'split' === $_GET['action']) {
                            bbp_set_query_name('bbp_topic_split');
                            bbp_get_template_part('form', 'topic-split');
                            // Edit
                        } else {
                            bbp_set_query_name('bbp_topic_form');
                            bbp_get_template_part('form', 'topic');
                        }
                        // Single Topic
                    } else {
                        bbp_set_query_name('bbp_single_topic');
                        bbp_get_template_part('content', 'single-topic');
                    }
                    break;
                    /** Single Reply **********************************************/
                /** Single Reply **********************************************/
                case $this->reply_slug:
                    // Get the reply
                    bbp_has_replies(array('name' => bp_action_variable($offset + 1), 'posts_per_page' => 1));
                    // If no topic, 404
                    if (!bbp_replies()) {
                        bp_do_404(bbp_get_forum_permalink($forum_id));
                        ?>
						<h3><?php 
                        bbp_forum_title();
                        ?>
</h3>
						<?php 
                        bbp_get_template_part('feedback', 'no-replies');
                        return;
                    }
                    // Setup the reply
                    bbp_the_reply();
                    ?>

					<h3><?php 
                    bbp_reply_title();
                    ?>
</h3>

					<?php 
                    if (bp_action_variable($offset + 2) === bbp_get_edit_rewrite_id()) {
                        // Set the edit switches
                        $wp_query->bbp_is_edit = true;
                        $wp_query->bbp_is_reply_edit = true;
                        // Setup the global reply ID
                        $bbp->current_reply_id = get_the_ID();
                        // Move
                        if (!empty($_GET['action']) && 'move' === $_GET['action']) {
                            bbp_set_query_name('bbp_reply_move');
                            bbp_get_template_part('form', 'reply-move');
                            // Edit
                        } else {
                            bbp_set_query_name('bbp_reply_form');
                            bbp_get_template_part('form', 'reply');
                        }
                    }
                    break;
            }
            // Reset the query
            wp_reset_query();
            ?>

		</div>

		<?php 
            // Allow actions immediately after group forum output
            do_action('bbp_after_group_forum_display');
        }
コード例 #25
0
ファイル: plugin.php プロジェクト: nickstewart95/wpmt
 function hook_bbp_new_topic($topic_id)
 {
     $topic_url = bbp_get_topic_permalink($topic_id);
     //$dir = $this->get_folder() . '' . substr($topic_url, strlen(get_option('home'))) . '/';
     $dir = $this->get_folder() . '/' . substr($topic_url, strpos($topic_url, '://') + 3) . '/';
     $this->remove_dir($dir);
     $forum_id = bbp_get_topic_forum_id($topic_id);
     $forum_url = bbp_get_forum_permalink($forum_id);
     $dir = $this->get_folder() . '/' . substr($topic_url, strpos($forum_url, '://') + 3) . '/';
     //$dir = $this->get_folder() . '' . substr($forum_url, strlen(get_option('home'))) . '/';
     $this->remove_dir($dir);
 }
コード例 #26
0
function st_bbp_list_forums($args = '')
{
    // Define used variables
    $output = $sub_forums = $topic_count = $reply_count = $counts = '';
    $i = 0;
    $count = array();
    // Defaults and arguments
    $defaults = array('before' => '<ul class="bbp-forums-list">', 'after' => '</ul>', 'link_before' => '<li class="bbp-forum">', 'link_after' => '</li>', 'count_before' => ' (', 'count_after' => ')', 'count_sep' => ', ', 'separator' => ', ', 'forum_id' => '', 'show_topic_count' => true, 'show_reply_count' => true, 'show_freshness_link' => true);
    $r = bbp_parse_args($args, $defaults, 'list_forums');
    extract($r, EXTR_SKIP);
    // Bail if there are no subforums
    if (!bbp_get_forum_subforum_count($forum_id)) {
        return;
    }
    // Loop through forums and create a list
    $sub_forums = bbp_forum_get_subforums($forum_id);
    if (!empty($sub_forums)) {
        // Total count (for separator)
        $total_subs = count($sub_forums);
        foreach ($sub_forums as $sub_forum) {
            $i++;
            // Separator count
            // Get forum details
            $count = array();
            $show_sep = $total_subs > $i ? $separator : '';
            $permalink = bbp_get_forum_permalink($sub_forum->ID);
            $title = bbp_get_forum_title($sub_forum->ID);
            $description = bbp_get_forum_content($sub_forum->ID);
            // Show topic count
            if (!empty($show_topic_count) && !bbp_is_forum_category($sub_forum->ID)) {
                $count['topic'] = bbp_get_forum_topic_count($sub_forum->ID);
            }
            // Show reply count
            if (!empty($show_reply_count) && !bbp_is_forum_category($sub_forum->ID)) {
                $count['reply'] = bbp_get_forum_reply_count($sub_forum->ID);
            }
            // Counts to show
            if (!empty($count)) {
                $counts = $count_before . implode($count_sep, $count) . $count_after;
            }
            if (!empty($show_freshness_link)) {
                $freshness_link = "<div class='freshness-forum-link'>" . st_get_last_poster_block($sub_forum->ID) . "</div>";
            }
            // Build this sub forums link
            if ($i % 2) {
                $class = "odd-forum-row";
            } else {
                $class = "even-forum-row";
            }
            $output .= "<li class='{$class}'><ul>" . $link_before . '<div class="bbp-forum-title-container"><a href="' . $permalink . '" class="bbp-forum-link">' . $title . '</a><p class="bbp-forum-description">' . $description . '</p></div>' . $counts . $freshness_link . $link_after . "</ul></li>";
        }
        // Output the list
        echo apply_filters('bbp_list_forums', $before . $output . $after, $args);
    }
}
コード例 #27
0
/**
 * Redirect if unathorized user is attempting to edit a forum
 *
 * @since bbPress (r3607)
 *
 * @uses bbp_is_forum_edit()
 * @uses current_user_can()
 * @uses bbp_get_forum_id()
 * @uses wp_safe_redirect()
 * @uses bbp_get_forum_permalink()
 */
function bbp_check_forum_edit()
{
    // Bail if not editing a topic
    if (!bbp_is_forum_edit()) {
        return;
    }
    // User cannot edit topic, so redirect back to reply
    if (!current_user_can('edit_forum', bbp_get_forum_id())) {
        wp_safe_redirect(bbp_get_forum_permalink());
        exit;
    }
}
コード例 #28
0
ファイル: functions.php プロジェクト: sdh100shaun/pantheon
/**
 * Handles the front end subscribing and unsubscribing forums
 *
 * @since bbPress (r5156)
 *
 * @param string $action The requested action to compare this function to
 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
 * @uses bbp_get_user_id() To get the user id
 * @uses bbp_verify_nonce_request() To verify the nonce and check the request
 * @uses current_user_can() To check if the current user can edit the user
 * @uses bbPress:errors:add() To log the error messages
 * @uses bbp_is_user_subscribed() To check if the forum is in user's
 *                                 subscriptions
 * @uses bbp_remove_user_subscription() To remove the user subscription
 * @uses bbp_add_user_subscription() To add the user subscription
 * @uses do_action() Calls 'bbp_subscriptions_handler' with success, user id,
 *                    forum id and action
 * @uses bbp_is_subscription() To check if it's the subscription page
 * @uses bbp_get_forum_permalink() To get the forum permalink
 * @uses wp_safe_redirect() To redirect to the url
 */
function bbp_forum_subscriptions_handler($action = '')
{
    if (!bbp_is_subscriptions_active()) {
        return false;
    }
    // Bail if no forum ID is passed
    if (empty($_GET['forum_id'])) {
        return;
    }
    // Setup possible get actions
    $possible_actions = array('bbp_subscribe', 'bbp_unsubscribe');
    // Bail if actions aren't meant for this function
    if (!in_array($action, $possible_actions)) {
        return;
    }
    // Get required data
    $user_id = bbp_get_user_id(0, true, true);
    $forum_id = intval($_GET['forum_id']);
    // Check for empty forum
    if (empty($forum_id)) {
        bbp_add_error('bbp_subscription_forum_id', __('<strong>ERROR</strong>: No forum was found! Which forum are you subscribing/unsubscribing to?', 'bbpress'));
        // Check nonce
    } elseif (!bbp_verify_nonce_request('toggle-subscription_' . $forum_id)) {
        bbp_add_error('bbp_subscription_forum_id', __('<strong>ERROR</strong>: Are you sure you wanted to do that?', 'bbpress'));
        // Check current user's ability to edit the user
    } elseif (!current_user_can('edit_user', $user_id)) {
        bbp_add_error('bbp_subscription_permissions', __('<strong>ERROR</strong>: You don\'t have the permission to edit favorites of that user!', 'bbpress'));
    }
    // Bail if we have errors
    if (bbp_has_errors()) {
        return;
    }
    /** No errors *************************************************************/
    $is_subscription = bbp_is_user_subscribed($user_id, $forum_id);
    $success = false;
    if (true === $is_subscription && 'bbp_unsubscribe' === $action) {
        $success = bbp_remove_user_subscription($user_id, $forum_id);
    } elseif (false === $is_subscription && 'bbp_subscribe' === $action) {
        $success = bbp_add_user_subscription($user_id, $forum_id);
    }
    // Do additional subscriptions actions
    do_action('bbp_subscriptions_handler', $success, $user_id, $forum_id, $action);
    // Success!
    if (true === $success) {
        // Redirect back from whence we came
        if (bbp_is_subscriptions()) {
            $redirect = bbp_get_subscriptions_permalink($user_id);
        } elseif (bbp_is_single_user()) {
            $redirect = bbp_get_user_profile_url();
        } elseif (is_singular(bbp_get_forum_post_type())) {
            $redirect = bbp_get_forum_permalink($forum_id);
        } elseif (is_single() || is_page()) {
            $redirect = get_permalink();
        } else {
            $redirect = get_permalink($forum_id);
        }
        wp_safe_redirect($redirect);
        // For good measure
        exit;
        // Fail! Handle errors
    } elseif (true === $is_subscription && 'bbp_unsubscribe' === $action) {
        bbp_add_error('bbp_unsubscribe', __('<strong>ERROR</strong>: There was a problem unsubscribing from that forum!', 'bbpress'));
    } elseif (false === $is_subscription && 'bbp_subscribe' === $action) {
        bbp_add_error('bbp_subscribe', __('<strong>ERROR</strong>: There was a problem subscribing to that forum!', 'bbpress'));
    }
}
コード例 #29
0
</span>

			<?php 
do_action('bbp_theme_after_topic_started_by');
?>

			<?php 
if (!bbp_is_single_forum() || bbp_get_topic_forum_id() !== bbp_get_forum_id()) {
    ?>

				<?php 
    do_action('bbp_theme_before_topic_started_in');
    ?>

				<span class="bbp-topic-started-in"><?php 
    printf(__('in: <a href="%1$s">%2$s</a>', 'bbpress'), bbp_get_forum_permalink(bbp_get_topic_forum_id()), bbp_get_forum_title(bbp_get_topic_forum_id()));
    ?>
</span>

				<?php 
    do_action('bbp_theme_after_topic_started_in');
    ?>

			<?php 
}
?>

		</p>

		<?php 
do_action('bbp_theme_after_topic_meta');
コード例 #30
0
ファイル: loop-single-topic.php プロジェクト: melgar3d/wpsvse
</span>

			<?php 
do_action('bbp_theme_after_topic_started_by');
?>

			<?php 
if (!bbp_is_single_forum() || bbp_get_topic_forum_id() !== bbp_get_forum_id()) {
    ?>

				<?php 
    do_action('bbp_theme_before_topic_started_in');
    ?>

				<span class="bbp-topic-started-in"><?php 
    printf(__(' <i class="fa fa-folder-o"></i> <a href="%1$s">%2$s</a>', 'bbpress'), bbp_get_forum_permalink(bbp_get_topic_forum_id()), bbp_get_forum_title(bbp_get_topic_forum_id()));
    ?>
</span>

				<?php 
    do_action('bbp_theme_after_topic_started_in');
    ?>

			<?php 
}
?>

		</p>

		<?php 
do_action('bbp_theme_after_topic_meta');