本文整理汇总了PHP中bbp_get_topic_tag_link函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_get_topic_tag_link函数的具体用法?PHP bbp_get_topic_tag_link怎么用?PHP bbp_get_topic_tag_link使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bbp_get_topic_tag_link函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bbp_get_topic_tag_edit_link
/**
* Return the link of the current tag
*
* @since 2.0.0 bbPress (r3348)
*
* @uses get_term_by()
* @uses get_queried_object()
* @uses get_query_var()
* @uses apply_filters()
*
* @return string Term Name
*/
function bbp_get_topic_tag_edit_link($tag = '')
{
// Get the term
if (!empty($tag)) {
$term = get_term_by('slug', $tag, bbp_get_topic_tag_tax_id());
} else {
$tag = get_query_var('term');
$term = get_queried_object();
}
// Add before and after if description exists
if (!empty($term->term_id)) {
// Pretty
if (bbp_use_pretty_urls()) {
$retval = user_trailingslashit(trailingslashit(bbp_get_topic_tag_link()) . bbp_get_edit_rewrite_id());
// Ugly
} else {
$retval = add_query_arg(array(bbp_get_edit_rewrite_id() => '1'), bbp_get_topic_tag_link());
}
// No link
} else {
$retval = '';
}
return apply_filters('bbp_get_topic_tag_edit_link', $retval, $tag, $term);
}
示例2: 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);
}
示例3: bbp_check_topic_tag_edit
/**
* Redirect if unathorized user is attempting to edit a topic tag
*
* @since bbPress (r3605)
*
* @uses bbp_is_topic_tag_edit()
* @uses current_user_can()
* @uses bbp_get_topic_tag_id()
* @uses wp_safe_redirect()
* @uses bbp_get_topic_tag_link()
*/
function bbp_check_topic_tag_edit()
{
// Bail if not editing a topic tag
if (!bbp_is_topic_tag_edit()) {
return;
}
// Bail if current user cannot edit topic tags
if (!current_user_can('edit_topic_tags', bbp_get_topic_tag_id())) {
wp_safe_redirect(bbp_get_topic_tag_link());
exit;
}
}
示例4: bbp_get_topic_tag_edit_link
/**
* Return the link of the current tag
*
* @since bbPress (r3348)
*
* @uses get_term_by()
* @uses get_queried_object()
* @uses get_query_var()
* @uses apply_filters()
*
* @return string Term Name
*/
function bbp_get_topic_tag_edit_link($tag = '')
{
global $wp_rewrite;
// Get the term
if (!empty($tag)) {
$term = get_term_by('slug', $tag, bbp_get_topic_tag_tax_id());
} else {
$tag = get_query_var('term');
$term = get_queried_object();
}
// Add before and after if description exists
if (!empty($term->term_id)) {
$bbp = bbpress();
// Pretty
if ($wp_rewrite->using_permalinks()) {
$retval = user_trailingslashit(trailingslashit(bbp_get_topic_tag_link()) . $bbp->edit_id);
// Ugly
} else {
$retval = add_query_arg(array($bbp->edit_id => '1'), bbp_get_topic_tag_link());
}
// No link
} else {
$retval = '';
}
return apply_filters('bbp_get_topic_tag_edit_link', $retval, $tag);
}
示例5: tehnik_bbp_has_topics
//.........这里部分代码省略.........
unset($post_offsets);
}
// Cleanup
unset($sticky_offset);
// If any posts have been excluded specifically, Ignore those that are sticky.
if (!empty($stickies) && !empty($r['post__not_in'])) {
$stickies = array_diff($stickies, $r['post__not_in']);
}
// Fetch sticky posts that weren't in the query results
if (!empty($stickies)) {
// Query to use in get_posts to get sticky posts
$sticky_query = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => 'any', 'meta_key' => '_bbp_last_active_time', 'orderby' => 'meta_value', 'order' => 'DESC', 'include' => $stickies);
//Get an array of IDs which the current user has permissions to view
$allowed_forums = tehnik_bpp_get_permitted_post_ids(new WP_Query($sticky_query));
// The default forum query with allowed forum ids array added
$sticky_query['post__in'] = $allowed_forums;
// Cleanup
unset($stickies);
// What are the default allowed statuses (based on user caps)
if (bbp_get_view_all()) {
$sticky_query['post_status'] = $r['post_status'];
// Lean on the 'perm' query var value of 'readable' to provide statuses
} else {
$sticky_query['post_status'] = $r['perm'];
}
// Get all stickies
$sticky_posts = get_posts($sticky_query);
if (!empty($sticky_posts)) {
// Get a count of the visible stickies
$sticky_count = count($sticky_posts);
// Merge the stickies topics with the query topics .
$bbp->topic_query->posts = array_merge($sticky_posts, $bbp->topic_query->posts);
// Adjust loop and counts for new sticky positions
$bbp->topic_query->found_posts = (int) $bbp->topic_query->found_posts + (int) $sticky_count;
$bbp->topic_query->post_count = (int) $bbp->topic_query->post_count + (int) $sticky_count;
// Cleanup
unset($sticky_posts);
}
}
}
}
// If no limit to posts per page, set it to the current post_count
if (-1 == $r['posts_per_page']) {
$r['posts_per_page'] = $bbp->topic_query->post_count;
}
// Add pagination values to query object
$bbp->topic_query->posts_per_page = $r['posts_per_page'];
$bbp->topic_query->paged = $r['paged'];
// Only add pagination if query returned results
if (((int) $bbp->topic_query->post_count || (int) $bbp->topic_query->found_posts) && (int) $bbp->topic_query->posts_per_page) {
// Limit the number of topics shown based on maximum allowed pages
if (!empty($r['max_num_pages']) && $bbp->topic_query->found_posts > $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count) {
$bbp->topic_query->found_posts = $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count;
}
// If pretty permalinks are enabled, make our pagination pretty
if ($wp_rewrite->using_permalinks()) {
// User's topics
if (bbp_is_single_user_topics()) {
$base = bbp_get_user_topics_created_url(bbp_get_displayed_user_id());
// User's favorites
} elseif (bbp_is_favorites()) {
$base = bbp_get_favorites_permalink(bbp_get_displayed_user_id());
// User's subscriptions
} elseif (bbp_is_subscriptions()) {
$base = bbp_get_subscriptions_permalink(bbp_get_displayed_user_id());
// Root profile page
} elseif (bbp_is_single_user()) {
$base = bbp_get_user_profile_url(bbp_get_displayed_user_id());
// View
} elseif (bbp_is_single_view()) {
$base = bbp_get_view_url();
// Topic tag
} elseif (bbp_is_topic_tag()) {
$base = bbp_get_topic_tag_link();
// Page or single post
} elseif (is_page() || is_single()) {
$base = get_permalink();
// Topic archive
} elseif (bbp_is_topic_archive()) {
$base = bbp_get_topics_url();
// Default
} else {
$base = get_permalink((int) $r['post_parent']);
}
// Use pagination base
$base = trailingslashit($base) . user_trailingslashit($wp_rewrite->pagination_base . '/%#%/');
// Unpretty pagination
} else {
$base = add_query_arg('paged', '%#%');
}
// Pagination settings with filter
$bbp_topic_pagination = apply_filters('bbp_topic_pagination', array('base' => $base, 'format' => '', 'total' => $r['posts_per_page'] == $bbp->topic_query->found_posts ? 1 : ceil((int) $bbp->topic_query->found_posts / (int) $r['posts_per_page']), 'current' => (int) $bbp->topic_query->paged, 'prev_text' => is_rtl() ? '→' : '←', 'next_text' => is_rtl() ? '←' : '→', 'mid_size' => 1));
// Add pagination to query object
$bbp->topic_query->pagination_links = paginate_links($bbp_topic_pagination);
// Remove first page from pagination
$bbp->topic_query->pagination_links = str_replace($wp_rewrite->pagination_base . "/1/'", "'", $bbp->topic_query->pagination_links);
}
// Return object
return array($bbp->topic_query->have_posts(), $bbp->topic_query);
}
示例6: breadcrumb_trail_get_bbpress_items
/**
* Gets the items for the breadcrumb trail if bbPress is installed.
*
* @since 0.5.0
* @access public
* @param array $args Mixed arguments for the menu.
* @return array List of items to be shown in the trail.
*/
function breadcrumb_trail_get_bbpress_items($args = array())
{
/* Set up a new trail items array. */
$trail = array();
/* 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()) {
$trail[] = '<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()) {
$trail[] = "<span>" . bbp_get_forum_archive_title() . "</span>";
} elseif (bbp_is_topic_archive()) {
$trail[] = "<span>" . bbp_get_topic_archive_title() . "</span>";
} elseif (bbp_is_topic_tag()) {
$trail[] = "<span>" . bbp_get_topic_tag_name() . "</span>";
} elseif (bbp_is_topic_tag_edit()) {
$trail[] = '<a href="' . bbp_get_topic_tag_link() . '">' . bbp_get_topic_tag_name() . '</a>';
$trail[] = "<span>" . __('Edit', 'kleo_framework') . "</span>";
} elseif (bbp_is_single_view()) {
$trail[] = '<span>' . bbp_get_view_title() . '</span>';
} 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). */
$trail = array_merge($trail, breadcrumb_trail_get_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()) {
$trail[] = '<a href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
} else {
$trail[] = '<span>' . bbp_get_topic_title($topic_id) . '</span>';
}
/* If viewing a topic split page. */
if (bbp_is_topic_split()) {
$trail[] = "<span>" . __('Split', 'kleo_framework') . "</span>";
} elseif (bbp_is_topic_merge()) {
$trail[] = "<span>" . __('Merge', 'kleo_framework') . "</span>";
} elseif (bbp_is_topic_edit()) {
$trail[] = "<span>" . __('Edit', 'kleo_framework') . "</span>";
}
} 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. */
$trail = array_merge($trail, breadcrumb_trail_get_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()) {
$trail[] = '<a href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a>';
$trail[] = "<span>" . __('Edit', 'kleo_framework') . "</span>";
} else {
$trail[] = '<span>' . bbp_get_reply_title($reply_id) . '</span>';
}
} 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) {
$trail = array_merge($trail, breadcrumb_trail_get_parents($forum_parent_id));
}
/* Add the forum title to the end of the trail. */
$trail[] = '<span>' . bbp_get_forum_title($forum_id) . '</span>';
} elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
if (bbp_is_single_user_edit()) {
$trail[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a>';
$trail[] = "<span>" . __('Edit', 'kleo_framework') . "</span>";
} else {
$trail[] = '<span>' . bbp_get_displayed_user_field('display_name') . '</span>';
}
}
/* Return the bbPress breadcrumb trail items. */
return apply_filters('breadcrumb_trail_get_bbpress_items', $trail, $args);
}
示例7: pg_get_user_unread
//.........这里部分代码省略.........
// Fetch sticky posts that weren't in the query results
if (!empty($stickies)) {
// Query to use in get_posts to get sticky posts
$sticky_query = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => 'any', 'meta_key' => '_bbp_last_active_time', 'orderby' => 'meta_value', 'order' => 'DESC', 'include' => $stickies);
// Cleanup
unset($stickies);
// Conditionally exclude private/hidden forum ID's
$exclude_forum_ids = bbp_exclude_forum_ids('array');
if (!empty($exclude_forum_ids)) {
$sticky_query['post_parent__not_in'] = $exclude_forum_ids;
}
// What are the default allowed statuses (based on user caps)
if (bbp_get_view_all()) {
$sticky_query['post_status'] = $r['post_status'];
// Lean on the 'perm' query var value of 'readable' to provide statuses
} else {
$sticky_query['post_status'] = $r['perm'];
}
// Get all stickies
$sticky_posts = get_posts($sticky_query);
if (!empty($sticky_posts)) {
// Get a count of the visible stickies
$sticky_count = count($sticky_posts);
// Merge the stickies topics with the query topics .
$bbp->topic_query->posts = array_merge($sticky_posts, $bbp->topic_query->posts);
// Adjust loop and counts for new sticky positions
$bbp->topic_query->found_posts = (int) $bbp->topic_query->found_posts + (int) $sticky_count;
$bbp->topic_query->post_count = (int) $bbp->topic_query->post_count + (int) $sticky_count;
// Cleanup
unset($sticky_posts);
}
}
}
}
// If no limit to posts per page, set it to the current post_count
if (-1 === $r['posts_per_page']) {
$r['posts_per_page'] = $bbp->topic_query->post_count;
}
// Add pagination values to query object
$bbp->topic_query->posts_per_page = $r['posts_per_page'];
$bbp->topic_query->paged = $r['paged'];
// Only add pagination if query returned results
if (((int) $bbp->topic_query->post_count || (int) $bbp->topic_query->found_posts) && (int) $bbp->topic_query->posts_per_page) {
// Limit the number of topics shown based on maximum allowed pages
if (!empty($r['max_num_pages']) && $bbp->topic_query->found_posts > $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count) {
$bbp->topic_query->found_posts = $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count;
}
// If pretty permalinks are enabled, make our pagination pretty
if ($wp_rewrite->using_permalinks()) {
// User's topics
if (bbp_is_single_user_topics()) {
$base = bbp_get_user_topics_created_url(bbp_get_displayed_user_id());
// User's favorites
} elseif (bbp_is_favorites()) {
$base = bbp_get_favorites_permalink(bbp_get_displayed_user_id());
// User's subscriptions
} elseif (bbp_is_subscriptions()) {
$base = bbp_get_subscriptions_permalink(bbp_get_displayed_user_id());
// Root profile page
} elseif (bbp_is_single_user()) {
$base = bbp_get_user_profile_url(bbp_get_displayed_user_id());
// View
} elseif (bbp_is_single_view()) {
$base = bbp_get_view_url();
// Topic tag
} elseif (bbp_is_topic_tag()) {
$base = bbp_get_topic_tag_link();
// Page or single post
} elseif (is_page() || is_single()) {
$base = get_permalink();
// Forum archive
} elseif (bbp_is_forum_archive()) {
$base = bbp_get_forums_url();
// Topic archive
} elseif (bbp_is_topic_archive()) {
$base = bbp_get_topics_url();
// Default
} else {
$base = get_permalink((int) $r['post_parent']);
}
// Use pagination base
$base = trailingslashit($base) . user_trailingslashit($wp_rewrite->pagination_base . '/%#%/');
// Unpretty pagination
} else {
$base = add_query_arg('paged', '%#%');
}
// Pagination settings with filter
$bbp_topic_pagination = apply_filters('bbp_topic_pagination', array('base' => $base, 'format' => '', 'total' => $r['posts_per_page'] === $bbp->topic_query->found_posts ? 1 : ceil((int) $bbp->topic_query->found_posts / (int) $r['posts_per_page']), 'current' => (int) $bbp->topic_query->paged, 'prev_text' => is_rtl() ? '→' : '←', 'next_text' => is_rtl() ? '←' : '→', 'mid_size' => 1));
// Add pagination to query object
$bbp->topic_query->pagination_links = paginate_links($bbp_topic_pagination);
// Remove first page from pagination
$bbp->topic_query->pagination_links = str_replace($wp_rewrite->pagination_base . "/1/'", "'", $bbp->topic_query->pagination_links);
}
// Return object
return apply_filters('pg_get_user_unread', $bbp->topic_query->have_posts(), $bbp->topic_query);
}
//if no unread
return bbp_has_topics();
// default query
}