当前位置: 首页>>代码示例>>PHP>>正文


PHP bbp_get_forum_permalink函数代码示例

本文整理汇总了PHP中bbp_get_forum_permalink函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_get_forum_permalink函数的具体用法?PHP bbp_get_forum_permalink怎么用?PHP bbp_get_forum_permalink使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了bbp_get_forum_permalink函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: wp_slack_bbpress

/**
 * 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;
}
开发者ID:rolfkleef,项目名称:wp-slack-bbpress,代码行数:21,代码来源:wp-slack-bbpress.php

示例2: dtbaker_vote_bbp_template_before_topics_loop

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 
    }
}
开发者ID:paulmedwal,项目名称:edxforumspublic,代码行数:17,代码来源:bbps-vote-functions.php

示例3: test_bbp_get_forum_permalink

 /**
  * @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);
 }
开发者ID:joeyblake,项目名称:bbpress,代码行数:40,代码来源:forum.php

示例4: custom_list_forums

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;
    }
}
开发者ID:USSLomaPrieta,项目名称:usslomaprieta.org,代码行数:64,代码来源:forum-filters.php

示例5: bbp_toggle_topic_handler


//.........这里部分代码省略.........
    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);
    }
}
开发者ID:jenia-buianov,项目名称:all_my_sites,代码行数:101,代码来源:functions.php

示例6: bbp_get_breadcrumb


//.........这里部分代码省略.........
        $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);
}
开发者ID:rmccue,项目名称:bbPress,代码行数:101,代码来源:bbp-common-template.php

示例7: reply_create

 /**
  * 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);
     }
 }
开发者ID:hscale,项目名称:webento,代码行数:71,代码来源:activity.php

示例8: bbp_get_forum_replies_feed_link

/**
 * 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);
}
开发者ID:hscale,项目名称:webento,代码行数:40,代码来源:bbp-forum-template.php

示例9: bbp_get_user_subscribe_link

/**
 * 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>';
//.........这里部分代码省略.........
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:101,代码来源:template.php

示例10: bbp_get_topic_forum_link

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);
}
开发者ID:082net,项目名称:bbpresskr,代码行数:13,代码来源:functions.php

示例11: apoc_loop_subforums

/**
 * 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 
//.........这里部分代码省略.........
开发者ID:tamriel-foundry,项目名称:apoc2,代码行数:101,代码来源:bbpress.php

示例12: ajax_custom_load_posts

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;
}
开发者ID:bjornmann,项目名称:bbpress-mod-console,代码行数:72,代码来源:bbpress-mod-console.php

示例13: bbp_get_forum_permalink

			<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?>
开发者ID:niamherinoc,项目名称:rctractors,代码行数:30,代码来源:loop-single-forum.php

示例14: roost_bbp_forum_subscription

    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
    }
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:77,代码来源:class-roost-bbpress.php

示例15: get_views

 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;
 }
开发者ID:082net,项目名称:bbpresskr,代码行数:24,代码来源:list-table.php


注:本文中的bbp_get_forum_permalink函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。