本文整理汇总了PHP中bbp_is_single_topic函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_is_single_topic函数的具体用法?PHP bbp_is_single_topic怎么用?PHP bbp_is_single_topic使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bbp_is_single_topic函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bbPress_head_scripts
function bbPress_head_scripts()
{
// Put some scripts in the header, like AJAX url for wp-lists
if (bbp_is_single_topic()) {
?>
<script type='text/javascript'>
/* <![CDATA[ */
var ajaxurl = '<?php
echo admin_url('admin-ajax.php');
?>
';
/* ]]> */
</script>
<?php
} elseif (bbp_is_single_user_edit()) {
?>
<script type="text/javascript" charset="utf-8">
if ( window.location.hash == '#password' ) {
document.getElementById('pass1').focus();
}
</script>
<?php
}
}
示例2: bbp_has_replies
/**
* The main reply loop. WordPress makes this easy for us
*
* @since bbPress (r2553)
*
* @param mixed $args All the arguments supported by {@link WP_Query}
* @uses bbp_is_user_bozo() To add the bozo post status
* @uses bbp_show_lead_topic() Are we showing the topic as a lead?
* @uses bbp_get_topic_id() To get the topic id
* @uses bbp_get_reply_post_type() To get the reply post type
* @uses bbp_get_topic_post_type() To get the topic post type
* @uses bbp_is_query_name() To check if we are getting replies for a widget
* @uses get_option() To get the replies per page option
* @uses bbp_get_paged() To get the current page value
* @uses current_user_can() To check if the current user is capable of editing
* others' replies
* @uses WP_Query To make query and get the replies
* @uses WP_Rewrite::using_permalinks() To check if the blog is using permalinks
* @uses get_permalink() To get the permalink
* @uses add_query_arg() To add custom args to the url
* @uses apply_filters() Calls 'bbp_replies_pagination' with the pagination args
* @uses paginate_links() To paginate the links
* @uses apply_filters() Calls 'bbp_has_replies' with
* bbPres::reply_query::have_posts()
* and bbPres::reply_query
* @return object Multidimensional array of reply information
*/
function bbp_has_replies($args = '')
{
global $wp_rewrite;
// What are the default allowed statuses (based on user caps)
if (bbp_get_view_all('edit_others_replies')) {
$post_statuses = array(bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id());
} else {
$post_statuses = array(bbp_get_public_status_id(), bbp_get_closed_status_id());
}
// Add the bozo status if user is a bozo
if (bbp_is_user_bozo()) {
$post_statuses[] = bbp_get_bozo_status_id();
}
$default_reply_search = !empty($_REQUEST['rs']) ? $_REQUEST['rs'] : false;
$default_post_parent = bbp_is_single_topic() ? bbp_get_topic_id() : 'any';
$default_post_type = bbp_is_single_topic() && bbp_show_lead_topic() ? bbp_get_reply_post_type() : array(bbp_get_topic_post_type(), bbp_get_reply_post_type());
$default_post_status = join(',', $post_statuses);
// Default query args
$default = array('post_type' => $default_post_type, 'post_parent' => $default_post_parent, 'post_status' => $default_post_status, 'posts_per_page' => bbp_get_replies_per_page(), 'paged' => bbp_get_paged(), 'orderby' => 'date', 'order' => 'ASC', 's' => $default_reply_search);
// Set up topic variables
$bbp_r = bbp_parse_args($args, $default, 'has_replies');
// Extract the query variables
extract($bbp_r);
// Get bbPress
$bbp = bbpress();
// Call the query
$bbp->reply_query = new WP_Query($bbp_r);
// Add pagination values to query object
$bbp->reply_query->posts_per_page = $posts_per_page;
$bbp->reply_query->paged = $paged;
// Only add pagination if query returned results
if ((int) $bbp->reply_query->found_posts && (int) $bbp->reply_query->posts_per_page) {
// If pretty permalinks are enabled, make our pagination pretty
if ($wp_rewrite->using_permalinks()) {
// Page or single
if (is_page() || is_single()) {
$base = get_permalink();
// Topic
} else {
$base = get_permalink(bbp_get_topic_id());
}
$base = trailingslashit($base) . user_trailingslashit($wp_rewrite->pagination_base . '/%#%/');
// Unpretty permalinks
} else {
$base = add_query_arg('paged', '%#%');
}
// Pagination settings with filter
$bbp_replies_pagination = apply_filters('bbp_replies_pagination', array('base' => $base, 'format' => '', 'total' => ceil((int) $bbp->reply_query->found_posts / (int) $posts_per_page), 'current' => (int) $bbp->reply_query->paged, 'prev_text' => '←', 'next_text' => '→', 'mid_size' => 1, 'add_args' => bbp_get_view_all() ? array('view' => 'all') : false));
// Add pagination to query object
$bbp->reply_query->pagination_links = paginate_links($bbp_replies_pagination);
// Remove first page from pagination
if ($wp_rewrite->using_permalinks()) {
$bbp->reply_query->pagination_links = str_replace($wp_rewrite->pagination_base . '/1/', '', $bbp->reply_query->pagination_links);
} else {
$bbp->reply_query->pagination_links = str_replace('&paged=1', '', $bbp->reply_query->pagination_links);
}
}
// Return object
return apply_filters('bbp_has_replies', $bbp->reply_query->have_posts(), $bbp->reply_query);
}
示例3: update_views
static function update_views()
{
if (bbp_is_single_topic() && ($topic_id = bbp_get_topic_id())) {
$count = self::get_views($topic_id);
$count++;
update_post_meta($topic_id, 'topic_view_count', $count);
}
}
示例4: bphelp_pbpp_redirect
function bphelp_pbpp_redirect()
{
global $bp;
//IMPORTANT: Do not alter the following line.
$bphelp_my_redirect_slug = get_option('bphelp-my-redirect-slug', 'register');
if (bp_is_activity_component() || bp_is_groups_component() || bp_is_group_forum() || bbp_is_single_forum() || bbp_is_single_topic() || bp_is_forums_component() || bp_is_blogs_component() || bp_is_members_component() || bp_is_profile_component()) {
if (!is_user_logged_in()) {
bp_core_redirect(get_option('home') . '/' . $bphelp_my_redirect_slug);
}
}
}
示例5: bbp_template_include_theme_supports
/**
* Possibly intercept the template being loaded
*
* Listens to the 'template_include' filter and waits for any bbPress specific
* template condition to be met. If one is met and the template file exists,
* it will be used; otherwise
*
* Note that the _edit() checks are ahead of their counterparts, to prevent them
* from being stomped on accident.
*
* @since bbPress (r3032)
*
* @param string $template
*
* @uses bbp_is_single_user() To check if page is single user
* @uses bbp_get_single_user_template() To get user template
* @uses bbp_is_single_user_edit() To check if page is single user edit
* @uses bbp_get_single_user_edit_template() To get user edit template
* @uses bbp_is_single_view() To check if page is single view
* @uses bbp_get_single_view_template() To get view template
* @uses bbp_is_search() To check if page is search
* @uses bbp_get_search_template() To get search template
* @uses bbp_is_forum_edit() To check if page is forum edit
* @uses bbp_get_forum_edit_template() To get forum edit template
* @uses bbp_is_topic_merge() To check if page is topic merge
* @uses bbp_get_topic_merge_template() To get topic merge template
* @uses bbp_is_topic_split() To check if page is topic split
* @uses bbp_get_topic_split_template() To get topic split template
* @uses bbp_is_topic_edit() To check if page is topic edit
* @uses bbp_get_topic_edit_template() To get topic edit template
* @uses bbp_is_reply_move() To check if page is reply move
* @uses bbp_get_reply_move_template() To get reply move template
* @uses bbp_is_reply_edit() To check if page is reply edit
* @uses bbp_get_reply_edit_template() To get reply edit template
* @uses bbp_set_theme_compat_template() To set the global theme compat template
*
* @return string The path to the template file that is being used
*/
function bbp_template_include_theme_supports($template = '')
{
// Editing a user
if (bbp_is_single_user_edit() && ($new_template = bbp_get_single_user_edit_template())) {
// User favorites
} elseif (bbp_is_favorites() && ($new_template = bbp_get_favorites_template())) {
// User favorites
} elseif (bbp_is_subscriptions() && ($new_template = bbp_get_subscriptions_template())) {
// Viewing a user
} elseif (bbp_is_single_user() && ($new_template = bbp_get_single_user_template())) {
// Single View
} elseif (bbp_is_single_view() && ($new_template = bbp_get_single_view_template())) {
// Search
} elseif (bbp_is_search() && ($new_template = bbp_get_search_template())) {
// Forum edit
} elseif (bbp_is_forum_edit() && ($new_template = bbp_get_forum_edit_template())) {
// Single Forum
} elseif (bbp_is_single_forum() && ($new_template = bbp_get_single_forum_template())) {
// Forum Archive
} elseif (bbp_is_forum_archive() && ($new_template = bbp_get_forum_archive_template())) {
// Topic merge
} elseif (bbp_is_topic_merge() && ($new_template = bbp_get_topic_merge_template())) {
// Topic split
} elseif (bbp_is_topic_split() && ($new_template = bbp_get_topic_split_template())) {
// Topic edit
} elseif (bbp_is_topic_edit() && ($new_template = bbp_get_topic_edit_template())) {
// Single Topic
} elseif (bbp_is_single_topic() && ($new_template = bbp_get_single_topic_template())) {
// Topic Archive
} elseif (bbp_is_topic_archive() && ($new_template = bbp_get_topic_archive_template())) {
// Reply move
} elseif (bbp_is_reply_move() && ($new_template = bbp_get_reply_move_template())) {
// Editing a reply
} elseif (bbp_is_reply_edit() && ($new_template = bbp_get_reply_edit_template())) {
// Single Reply
} elseif (bbp_is_single_reply() && ($new_template = bbp_get_single_reply_template())) {
// Editing a topic tag
} elseif (bbp_is_topic_tag_edit() && ($new_template = bbp_get_topic_tag_edit_template())) {
// Viewing a topic tag
} elseif (bbp_is_topic_tag() && ($new_template = bbp_get_topic_tag_template())) {
}
// A bbPress template file was located, so override the WordPress template
// and use it to switch off bbPress's theme compatibility.
if (!empty($new_template)) {
$template = bbp_set_template_included($new_template);
}
return apply_filters('bbp_template_include_theme_supports', $template);
}
示例6: comments_open
public static function comments_open($open, $post_id)
{
// if ( $open )
// return $open;
if (get_post_type($post_id) != bbp_get_topic_post_type()) {
return $open;
}
$use_comments = (bool) bbpresskr()->forum_option('use_comments', $post_id);
if (strpos($_SERVER['SCRIPT_FILENAME'], 'wp-comments-post.php') !== false && !empty($_POST['comment_post_ID']) && !empty($_POST['comment'])) {
return $use_comments;
}
if (bbp_is_single_topic()) {
return $use_comments;
}
return $open;
}
示例7: bbpress_hl_add_buttons
function bbpress_hl_add_buttons()
{
global $wp_sh_allowed_str, $wp_sh_setting_opt;
if (bbp_is_single_forum() || bbp_is_single_topic() || bbp_is_topic_edit() || bbp_is_reply_edit()) {
if (bbp_is_single_forum()) {
$textarea_id = "bbp_topic_content";
} elseif (bbp_is_topic_edit()) {
$textarea_id = "bbp_topic_content";
} elseif (bbp_is_reply_edit()) {
$textarea_id = "bbp_reply_content";
} elseif (bbp_is_single_topic()) {
$textarea_id = "bbp_reply_content";
}
echo "<div class=\"bbpress_highlight\">";
if ($wp_sh_setting_opt['bbpress_hl_description_before_enable'] == 1) {
$wp_sh_bbpress_hl_description_before = wp_sh_valid_text(get_option('wp_sh_bbpress_hl_description_before'), $wp_sh_allowed_str);
if ($wp_sh_bbpress_hl_description_before == "invalid") {
$wp_sh_bbpress_hl_description_before = wp_sh_default_setting_value('bbp_desc');
}
echo "<p>" . str_replace("<pre>", "<pre>", $wp_sh_bbpress_hl_description_before) . "</p>";
}
if ($wp_sh_setting_opt['bbpress_hl_bt_tag'] == "shortcode") {
$tag = "shorcode";
} else {
$tag = "pre";
}
echo "<div class=\"bbpress_highlight_button\">";
if ($wp_sh_setting_opt['lib_version'] == '3.0') {
$languages = get_option('wp_sh_language3');
} elseif ($wp_sh_setting_opt['lib_version'] == '2.1') {
$languages = get_option('wp_sh_language2');
}
$gutter = $wp_sh_setting_opt['gutter'];
if (is_array($languages)) {
asort($languages);
foreach ($languages as $key => $val) {
if ($val[1] == 'true' || $val[1] == 'added') {
echo "<a href=\"javascript:void(0);\" onclick=\"surroundHTML('" . $key . "','" . $textarea_id . "','" . $gutter . "','" . $wp_sh_setting_opt['first_line'] . "','" . $tag . "','0');\">" . $val[0] . "</a> | ";
}
}
unset($val);
}
echo "</div>";
echo "</div>";
}
}
示例8: bbp_template_include_theme_supports
/**
* Possibly intercept the template being loaded
*
* Listens to the 'template_include' filter and waits for any bbPress specific
* template condition to be met. If one is met and the template file exists,
* it will be used; otherwise
*
* Note that the _edit() checks are ahead of their counterparts, to prevent them
* from being stomped on accident.
*
* @since bbPress (r3032)
*
* @param string $template
*
* @uses bbp_is_single_user() To check if page is single user
* @uses bbp_get_single_user_template() To get user template
* @uses bbp_is_single_user_edit() To check if page is single user edit
* @uses bbp_get_single_user_edit_template() To get user edit template
* @uses bbp_is_single_view() To check if page is single view
* @uses bbp_get_single_view_template() To get view template
* @uses bbp_is_forum_edit() To check if page is forum edit
* @uses bbp_get_forum_edit_template() To get forum edit template
* @uses bbp_is_topic_merge() To check if page is topic merge
* @uses bbp_get_topic_merge_template() To get topic merge template
* @uses bbp_is_topic_split() To check if page is topic split
* @uses bbp_get_topic_split_template() To get topic split template
* @uses bbp_is_topic_edit() To check if page is topic edit
* @uses bbp_get_topic_edit_template() To get topic edit template
* @uses bbp_is_reply_edit() To check if page is reply edit
* @uses bbp_get_reply_edit_template() To get reply edit template
* @uses bbp_set_theme_compat_template() To set the global theme compat template
*
* @return string The path to the template file that is being used
*/
function bbp_template_include_theme_supports($template = '')
{
// Editing a user
if (bbp_is_single_user_edit() && ($new_template = bbp_get_single_user_edit_template())) {
// User favorites
} elseif (bbp_is_favorites() && ($new_template = bbp_get_favorites_template())) {
// User favorites
} elseif (bbp_is_subscriptions() && ($new_template = bbp_get_subscriptions_template())) {
// Viewing a user
} elseif (bbp_is_single_user() && ($new_template = bbp_get_single_user_template())) {
// Single View
} elseif (bbp_is_single_view() && ($new_template = bbp_get_single_view_template())) {
// Forum edit
} elseif (bbp_is_forum_edit() && ($new_template = bbp_get_forum_edit_template())) {
// Single Forum
} elseif (bbp_is_single_forum() && ($new_template = bbp_get_single_forum_template())) {
// Forum Archive
} elseif (bbp_is_forum_archive() && ($new_template = bbp_get_forum_archive_template())) {
// Topic merge
} elseif (bbp_is_topic_merge() && ($new_template = bbp_get_topic_merge_template())) {
// Topic split
} elseif (bbp_is_topic_split() && ($new_template = bbp_get_topic_split_template())) {
// Topic edit
} elseif (bbp_is_topic_edit() && ($new_template = bbp_get_topic_edit_template())) {
// Single Topic
} elseif (bbp_is_single_topic() && ($new_template = bbp_get_single_topic_template())) {
// Topic Archive
} elseif (bbp_is_topic_archive() && ($new_template = bbp_get_topic_archive_template())) {
// Editing a reply
} elseif (bbp_is_reply_edit() && ($new_template = bbp_get_reply_edit_template())) {
// Single Reply
} elseif (bbp_is_single_reply() && ($new_template = bbp_get_single_reply_template())) {
// Editing a topic tag
} elseif (bbp_is_topic_tag_edit() && ($new_template = bbp_get_topic_tag_edit_template())) {
// Viewing a topic tag
} elseif (bbp_is_topic_tag() && ($new_template = bbp_get_topic_tag_template())) {
}
// bbPress template file exists
if (!empty($new_template)) {
// Override the WordPress template with a bbPress one
$template = $new_template;
// @see: bbp_template_include_theme_compat()
bbpress()->theme_compat->bbpress_template = true;
}
return apply_filters('bbp_template_include_theme_supports', $template);
}
示例9: nav_menu_css_class
static function nav_menu_css_class($classes, $item, $args, $depth)
{
if ($item->object == bbp_get_forum_post_type() && is_bbpress()) {
if (bbp_is_topic_edit() || bbp_is_single_topic()) {
$forum_id = bbp_get_topic_forum_id();
if ($forum_id == $item->object_id) {
$classes[] = 'current-menu-parent';
$classes[] = 'current-' . bbp_get_topic_post_type() . '-parent';
} elseif ($ancestors = self::forum_ancestors($forum_id, array())) {
if (in_array($item->object_id, $ancestors)) {
$classes[] = 'current-menu-ancestor';
$classes[] = 'current-' . bbp_get_topic_post_type() . '-ancestor';
}
}
} elseif (bbp_is_reply_edit() || bbp_is_single_reply()) {
$forum_id = bbp_get_reply_forum_id();
}
}
return $classes;
}
示例10: stachestack_bbp_get_user_favorites_link
/**
* User favorites link
*
* Return the link to make a topic favorite/remove a topic from
* favorites
*
* @since bbPress (r2652)
*
* @param mixed $args This function supports these arguments:
* - subscribe: Favorite text
* - unsubscribe: Unfavorite text
* - user_id: User id
* - topic_id: Topic id
* - before: Before the link
* - after: After the link
* @param int $user_id Optional. User id
* @param int $topic_id Optional. Topic id
* @param bool $wrap Optional. If you want to wrap the link in <span id="favorite-toggle">. See ajax_favorite()
* @uses bbp_get_user_id() To get the user id
* @uses current_user_can() If the current user can edit the user
* @uses bbp_get_topic_id() To get the topic id
* @uses bbp_is_user_favorite() To check if the topic is user's favorite
* @uses bbp_get_favorites_permalink() To get the favorites permalink
* @uses bbp_get_topic_permalink() To get the topic permalink
* @uses bbp_is_favorites() Is it the favorites page?
* @uses apply_filters() Calls 'bbp_get_user_favorites_link' with the
* html, add args, remove args, user & topic id
* @return string User favorites link
*/
function stachestack_bbp_get_user_favorites_link($args = '', $user_id = 0, $wrap = true)
{
if (!bbp_is_favorites_active()) {
return false;
}
// Parse arguments against default values
$r = bbp_parse_args($args, array('favorite' => __('Favorite', 'bbpress'), 'favorited' => __('Favorited', 'bbpress'), 'user_id' => 0, 'topic_id' => 0, 'before' => '', 'after' => ''), 'get_user_favorites_link');
// Validate user and topic ID's
$user_id = bbp_get_user_id($r['user_id'], true, true);
$topic_id = bbp_get_topic_id($r['topic_id']);
if (empty($user_id) || empty($topic_id)) {
return false;
}
// No link if you can't edit yourself
if (!current_user_can('edit_user', (int) $user_id)) {
return false;
}
// Decide which link to show
$is_fav = bbp_is_user_favorite($user_id, $topic_id);
if (!empty($is_fav)) {
$text = $r['favorited'];
$query_args = array('action' => 'bbp_favorite_remove', 'topic_id' => $topic_id);
} else {
$text = $r['favorite'];
$query_args = array('action' => 'bbp_favorite_add', 'topic_id' => $topic_id);
}
// Create the link based where the user is and if the topic is
// already the user's favorite
if (bbp_is_favorites()) {
$permalink = bbp_get_favorites_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-favorite_' . $topic_id));
$sub = $is_fav ? ' class="is-favorite"' : '';
$html = sprintf('%s<span id="favorite-%d" %s><a href="%s" class="btn btn-success btn-xs favorite-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="favorite-toggle">' . $html . '</span>';
}
// Return the link
return apply_filters('bbp_get_user_favorites_link', $html, $r, $user_id, $topic_id);
}
示例11: do_trail_items
/**
* Runs through the various bbPress conditional tags to check the current page being viewed. Once
* a condition is met, add items to the $items array.
*
* @since 0.6.0
* @access public
* @return void
*/
public function do_trail_items()
{
/* Add the network and site home links. */
$this->do_network_home_link();
$this->do_site_home_link();
/* Get the forum post type object. */
$post_type_object = get_post_type_object(bbp_get_forum_post_type());
/* If not viewing the forum root/archive page and a forum archive exists, add it. */
if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
$this->items[] = '<a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a>';
}
/* If viewing the forum root/archive. */
if (bbp_is_forum_archive()) {
if (true === $this->args['show_title']) {
$this->items[] = bbp_get_forum_archive_title();
}
} elseif (bbp_is_topic_archive()) {
if (true === $this->args['show_title']) {
$this->items[] = bbp_get_topic_archive_title();
}
} elseif (bbp_is_topic_tag()) {
if (true === $this->args['show_title']) {
$this->items[] = bbp_get_topic_tag_name();
}
} elseif (bbp_is_topic_tag_edit()) {
$this->items[] = '<a href="' . bbp_get_topic_tag_link() . '">' . bbp_get_topic_tag_name() . '</a>';
if (true === $this->args['show_title']) {
$this->items[] = __('Edit', 'breadcrumb-trail');
}
} elseif (bbp_is_single_view()) {
if (true === $this->args['show_title']) {
$this->items[] = bbp_get_view_title();
}
} elseif (bbp_is_single_topic()) {
/* Get the queried topic. */
$topic_id = get_queried_object_id();
/* Get the parent items for the topic, which would be its forum (and possibly forum grandparents). */
$this->do_post_parents(bbp_get_topic_forum_id($topic_id));
/* If viewing a split, merge, or edit topic page, show the link back to the topic. Else, display topic title. */
if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
$this->items[] = '<a href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
} elseif (true === $this->args['show_title']) {
$this->items[] = bbp_get_topic_title($topic_id);
}
/* If viewing a topic split page. */
if (bbp_is_topic_split() && true === $this->args['show_title']) {
$this->items[] = __('Split', 'breadcrumb-trail');
} elseif (bbp_is_topic_merge() && true === $this->args['show_title']) {
$this->items[] = __('Merge', 'breadcrumb-trail');
} elseif (bbp_is_topic_edit() && true === $this->args['show_title']) {
$this->items[] = __('Edit', 'breadcrumb-trail');
}
} elseif (bbp_is_single_reply()) {
/* Get the queried reply object ID. */
$reply_id = get_queried_object_id();
/* Get the parent items for the reply, which should be its topic. */
$this->do_post_parents(bbp_get_reply_topic_id($reply_id));
/* If viewing a reply edit page, link back to the reply. Else, display the reply title. */
if (bbp_is_reply_edit()) {
$this->items[] = '<a href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a>';
if (true === $this->args['show_title']) {
$this->items[] = __('Edit', 'breadcrumb-trail');
}
} elseif (true === $this->args['show_title']) {
$this->items[] = bbp_get_reply_title($reply_id);
}
} elseif (bbp_is_single_forum()) {
/* Get the queried forum ID and its parent forum ID. */
$forum_id = get_queried_object_id();
$forum_parent_id = bbp_get_forum_parent_id($forum_id);
/* If the forum has a parent forum, get its parent(s). */
if (0 !== $forum_parent_id) {
$this->do_post_parents($forum_parent_id);
}
/* Add the forum title to the end of the trail. */
if (true === $this->args['show_title']) {
$this->items[] = bbp_get_forum_title($forum_id);
}
} elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
if (bbp_is_single_user_edit()) {
$this->items[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a>';
if (true === $this->args['show_title']) {
$this->items[] = __('Edit', 'breadcrumb-trail');
}
} elseif (true === $this->args['show_title']) {
$this->items[] = bbp_get_displayed_user_field('display_name');
}
}
/* Return the bbPress breadcrumb trail items. */
$this->items = apply_filters('breadcrumb_trail_get_bbpress_items', $this->items, $this->args);
}
示例12: bbp_get_topic_pagination_count
/**
* Return the topic pagination count
*
* @since bbPress (r2519)
*
* @uses bbp_number_format() To format the number value
* @uses bbp_show_lead_topic() Are we showing the topic as a lead?
* @uses apply_filters() Calls 'bbp_get_topic_pagination_count' with the
* pagination count
* @return string Topic pagination count
*/
function bbp_get_topic_pagination_count()
{
$bbp = bbpress();
// Define local variable(s)
$retstr = '';
// Set pagination values
$start_num = intval(($bbp->reply_query->paged - 1) * $bbp->reply_query->posts_per_page) + 1;
$from_num = bbp_number_format($start_num);
$to_num = bbp_number_format($start_num + ($bbp->reply_query->posts_per_page - 1) > $bbp->reply_query->found_posts ? $bbp->reply_query->found_posts : $start_num + ($bbp->reply_query->posts_per_page - 1));
$total_int = (int) $bbp->reply_query->found_posts;
$total = bbp_number_format($total_int);
// We are threading replies
if (bbp_thread_replies() && bbp_is_single_topic()) {
return;
$walker = new BBP_Walker_Reply();
$threads = (int) $walker->get_number_of_root_elements($bbp->reply_query->posts);
// Adjust for topic
$threads--;
$retstr = sprintf(_n('Viewing %1$s reply thread', 'Viewing %1$s reply threads', $threads, 'bbbpress'), bbp_number_format($threads));
// We are not including the lead topic
} elseif (bbp_show_lead_topic()) {
// Several replies in a topic with a single page
if (empty($to_num)) {
$retstr = sprintf(_n('Viewing %1$s reply', 'Viewing %1$s replies', $total_int, 'bbpress'), $total);
// Several replies in a topic with several pages
} else {
$retstr = sprintf(_n('Viewing %2$s replies (of %4$s total)', 'Viewing %1$s replies - %2$s through %3$s (of %4$s total)', $bbp->reply_query->post_count, 'bbpress'), $bbp->reply_query->post_count, $from_num, $to_num, $total);
}
// We are including the lead topic
} else {
// Several posts in a topic with a single page
if (empty($to_num)) {
$retstr = sprintf(_n('Viewing %1$s post', 'Viewing %1$s posts', $total_int, 'bbpress'), $total);
// Several posts in a topic with several pages
} else {
$retstr = sprintf(_n('Viewing %2$s post (of %4$s total)', 'Viewing %1$s posts - %2$s through %3$s (of %4$s total)', $bbp->reply_query->post_count, 'bbpress'), $bbp->reply_query->post_count, $from_num, $to_num, $total);
}
}
// Filter and return
return apply_filters('bbp_get_topic_pagination_count', esc_html($retstr));
}
示例13: _bbpress_items
protected function _bbpress_items()
{
$item = array();
$post_type_object = get_post_type_object(bbp_get_forum_post_type());
if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
$item[] = '<span typeof="v:Breadcrumb"><a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '" property="v:title" rel="v:url"><span>' . bbp_get_forum_archive_title() . '</span></a></span>';
}
if (bbp_is_forum_archive()) {
$item[] = bbp_get_forum_archive_title();
} elseif (bbp_is_topic_archive()) {
$item[] = bbp_get_topic_archive_title();
} elseif (bbp_is_single_view()) {
$item[] = bbp_get_view_title();
} elseif (bbp_is_single_topic()) {
$topic_id = get_queried_object_id();
$item = array_merge($item, $this->_get_parents(bbp_get_topic_forum_id($topic_id)));
if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
$item[] = '<span typeof="v:Breadcrumb"><a href="' . bbp_get_topic_permalink($topic_id) . '" property="v:title" rel="v:url"><span>' . bbp_get_topic_title($topic_id) . '</span></a></span>';
} else {
$item[] = bbp_get_topic_title($topic_id);
}
if (bbp_is_topic_split()) {
$item[] = __('Split', DH_DOMAIN);
} elseif (bbp_is_topic_merge()) {
$item[] = __('Merge', DH_DOMAIN);
} elseif (bbp_is_topic_edit()) {
$item[] = __('Edit', DH_DOMAIN);
}
} elseif (bbp_is_single_reply()) {
$reply_id = get_queried_object_id();
$item = array_merge($item, $this->_get_parents(bbp_get_reply_topic_id($reply_id)));
if (!bbp_is_reply_edit()) {
$item[] = bbp_get_reply_title($reply_id);
} else {
$item[] = '<span typeof="v:Breadcrumb"><a href="' . bbp_get_reply_url($reply_id) . '" property="v:title" rel="v:url"><span>' . bbp_get_reply_title($reply_id) . '</span></a></span>';
$item[] = __('Edit', DH_DOMAIN);
}
} elseif (bbp_is_single_forum()) {
$forum_id = get_queried_object_id();
$forum_parent_id = bbp_get_forum_parent_id($forum_id);
if (0 !== $forum_parent_id) {
$item = array_merge($item, $this->_get_parents($forum_parent_id));
}
$item[] = bbp_get_forum_title($forum_id);
} elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
if (bbp_is_single_user_edit()) {
$item[] = '<span typeof="v:Breadcrumb"><a href="' . bbp_get_user_profile_url() . '" property="v:title" rel="v:url" ><span>' . bbp_get_displayed_user_field('display_name') . '</span></a></span>';
$item[] = __('Edit', DH_DOMAIN);
} else {
$item[] = bbp_get_displayed_user_field('display_name');
}
}
return $item;
}
示例14: bbp_get_forum_id
/**
* Return the forum id
*
* @since bbPress (r2464)
*
* @param $forum_id Optional. Used to check emptiness
* @uses bbPress::forum_query::in_the_loop To check if we're in the loop
* @uses bbPress::forum_query::post::ID To get the forum id
* @uses WP_Query::post::ID To get the forum id
* @uses bbp_is_forum() To check if the search result is a forum
* @uses bbp_is_single_forum() To check if it's a forum page
* @uses bbp_is_single_topic() To check if it's a topic page
* @uses bbp_get_topic_forum_id() To get the topic forum id
* @uses get_post_field() To get the post's post type
* @uses apply_filters() Calls 'bbp_get_forum_id' with the forum id and
* supplied forum id
* @return int The forum id
*/
function bbp_get_forum_id($forum_id = 0)
{
global $wp_query;
$bbp = bbpress();
// Easy empty checking
if (!empty($forum_id) && is_numeric($forum_id)) {
$bbp_forum_id = $forum_id;
// Currently inside a forum loop
} elseif (!empty($bbp->forum_query->in_the_loop) && isset($bbp->forum_query->post->ID)) {
$bbp_forum_id = $bbp->forum_query->post->ID;
// Currently inside a search loop
} elseif (!empty($bbp->search_query->in_the_loop) && isset($bbp->search_query->post->ID) && bbp_is_forum($bbp->search_query->post->ID)) {
$bbp_forum_id = $bbp->search_query->post->ID;
// Currently viewing a forum
} elseif ((bbp_is_single_forum() || bbp_is_forum_edit()) && !empty($bbp->current_forum_id)) {
$bbp_forum_id = $bbp->current_forum_id;
// Currently viewing a forum
} elseif ((bbp_is_single_forum() || bbp_is_forum_edit()) && isset($wp_query->post->ID)) {
$bbp_forum_id = $wp_query->post->ID;
// Currently viewing a topic
} elseif (bbp_is_single_topic()) {
$bbp_forum_id = bbp_get_topic_forum_id();
// Fallback
} else {
$bbp_forum_id = 0;
}
return (int) apply_filters('bbp_get_forum_id', (int) $bbp_forum_id, $forum_id);
}
示例15:
<div class="cb-cat-header<?php
if ($cb_theme_style == 'cb_boxed') {
echo ' wrap';
}
?>
" style="border-bottom-color:<?php
echo $cb_bbpress_global_color;
?>
;">
<h1 id="cb-cat-title"><?php
echo $cb_title;
?>
</h1>
<p><?php
if ($cb_forum_id != 0 && bbp_is_single_topic() == false && bbp_is_single_reply() == false) {
bbp_forum_content();
}
?>
</p>
</div>
<?php
if ($cb_user_page != NULL) {
echo cb_bbp_author_details($cb_current_user);
}
?>
<?php
if ($cb_forum_id != 0 && $cb_breadcrumbs == 'on') {