本文整理汇总了PHP中bbp_is_single_forum函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_is_single_forum函数的具体用法?PHP bbp_is_single_forum怎么用?PHP bbp_is_single_forum使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bbp_is_single_forum函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pg_has_topics
function pg_has_topics($args = '')
{
//check if being called by subscriptions and if so skip filtering (as you can only subscribe to forums you can already see)
if ($args['post__in']) {
return $args;
}
$default_post_parent = bbp_is_single_forum() ? bbp_get_forum_id() : 'any';
if ($default_post_parent == 'any') {
if (bbp_is_user_keymaster()) {
return $args;
}
$user_id = wp_get_current_user()->ID;
if (user_can($user_id, 'moderate')) {
$check = get_user_meta($user_id, 'private_group', true);
if ($check == '') {
return $args;
}
}
global $wpdb;
$topic = bbp_get_topic_post_type();
$post_ids = $wpdb->get_col("select ID from {$wpdb->posts} where post_type = '{$topic}'");
//check this list against those the user is allowed to see, and create a list of valid ones for the wp_query in bbp_has_topics
$allowed_posts = check_private_groups_topic_ids($post_ids);
$args['post__in'] = $allowed_posts;
}
return $args;
}
示例2: gpbbp_breadcrumb_options
function gpbbp_breadcrumb_options()
{
$args['include_home'] = false;
$args['include_root'] = false;
if (bbp_is_single_forum()) {
$args['include_current'] = false;
} else {
$args['include_current'] = true;
}
return $args;
}
示例3: 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);
}
}
}
示例4: 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);
}
示例5: 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>";
}
}
示例6: 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);
}
示例7: do_action
<?php
do_action('bbp_theme_before_topic_started_by');
?>
<span class="bbp-topic-started-by"><?php
printf(__('Started by: %1$s', 'bbpress'), bbp_get_topic_author_link(array('type' => 'name')));
?>
</span>
<?php
do_action('bbp_theme_after_topic_started_by');
?>
<?php
if (!bbp_is_single_forum() || bbp_get_topic_forum_id() !== bbp_get_forum_id()) {
?>
<?php
do_action('bbp_theme_before_topic_started_in');
?>
<span class="bbp-topic-started-in"><?php
printf(__('in: <a href="%1$s">%2$s</a>', 'bbpress'), bbp_get_forum_permalink(bbp_get_topic_forum_id()), bbp_get_forum_title(bbp_get_topic_forum_id()));
?>
</span>
<?php
do_action('bbp_theme_after_topic_started_in');
?>
示例8: bbp_has_topics
/**
* The main topic loop. WordPress makes this easy for us
*
* @since 2.0.0 bbPress (r2485)
*
* @param array $args All the arguments supported by {@link WP_Query}
* @uses current_user_can() To check if the current user can edit other's topics
* @uses bbp_get_topic_post_type() To get the topic post type
* @uses WP_Query To make query and get the topics
* @uses is_page() To check if it's a page
* @uses bbp_is_single_forum() To check if it's a forum
* @uses bbp_get_forum_id() To get the forum id
* @uses bbp_get_paged() To get the current page value
* @uses bbp_get_super_stickies() To get the super stickies
* @uses bbp_get_stickies() To get the forum stickies
* @uses bbp_use_pretty_urls() To check if the site is using pretty URLs
* @uses get_permalink() To get the permalink
* @uses add_query_arg() To add custom args to the url
* @uses apply_filters() Calls 'bbp_topics_pagination' with the pagination args
* @uses paginate_links() To paginate the links
* @uses apply_filters() Calls 'bbp_has_topics' with
* bbPres::topic_query::have_posts()
* and bbPres::topic_query
* @return object Multidimensional array of topic information
*/
function bbp_has_topics($args = array())
{
/** Defaults **************************************************************/
// Other defaults
$default_topic_search = !empty($_REQUEST['ts']) ? $_REQUEST['ts'] : false;
$default_show_stickies = (bool) (bbp_is_single_forum() || bbp_is_topic_archive()) && false === $default_topic_search;
$default_post_parent = bbp_is_single_forum() ? bbp_get_forum_id() : 'any';
// Default argument array
$default = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => $default_post_parent, 'meta_key' => '_bbp_last_active_time', 'meta_type' => 'DATETIME', 'orderby' => 'meta_value', 'order' => 'DESC', 'posts_per_page' => bbp_get_topics_per_page(), 'paged' => bbp_get_paged(), 'show_stickies' => $default_show_stickies, 'max_num_pages' => false);
// Only add 's' arg if searching for topics
// See https://bbpress.trac.wordpress.org/ticket/2607
if (!empty($default_topic_search)) {
$default['s'] = $default_topic_search;
}
// What are the default allowed statuses (based on user caps)
if (bbp_get_view_all()) {
// Default view=all statuses
$post_statuses = array(bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id(), bbp_get_pending_status_id());
// Add support for private status
if (current_user_can('read_private_topics')) {
$post_statuses[] = bbp_get_private_status_id();
}
// Join post statuses together
$default['post_status'] = implode(',', $post_statuses);
// Lean on the 'perm' query var value of 'readable' to provide statuses
} else {
$default['perm'] = 'readable';
}
// Maybe query for topic tags
if (bbp_is_topic_tag()) {
$default['term'] = bbp_get_topic_tag_slug();
$default['taxonomy'] = bbp_get_topic_tag_tax_id();
}
/** Setup *****************************************************************/
// Parse arguments against default values
$r = bbp_parse_args($args, $default, 'has_topics');
// Get bbPress
$bbp = bbpress();
// Call the query
$bbp->topic_query = new WP_Query($r);
// Set post_parent back to 0 if originally set to 'any'
if ('any' === $r['post_parent']) {
$r['post_parent'] = 0;
}
// Limited the number of pages shown
if (!empty($r['max_num_pages'])) {
$bbp->topic_query->max_num_pages = $r['max_num_pages'];
}
/** Stickies **************************************************************/
// Put sticky posts at the top of the posts array
if (!empty($r['show_stickies']) && $r['paged'] <= 1) {
// Get super stickies and stickies in this forum
$stickies = bbp_get_super_stickies();
// Get stickies for current forum
if (!empty($r['post_parent'])) {
$stickies = array_merge($stickies, bbp_get_stickies($r['post_parent']));
}
// Remove any duplicate stickies
$stickies = array_unique($stickies);
// We have stickies
if (is_array($stickies) && !empty($stickies)) {
// Start the offset at -1 so first sticky is at correct 0 offset
$sticky_offset = -1;
// Loop over topics and relocate stickies to the front.
foreach ($stickies as $sticky_index => $sticky_ID) {
// Get the post offset from the posts array
$post_offsets = wp_filter_object_list($bbp->topic_query->posts, array('ID' => $sticky_ID), 'OR', 'ID');
// Continue if no post offsets
if (empty($post_offsets)) {
continue;
}
// Loop over posts in current query and splice them into position
foreach (array_keys($post_offsets) as $post_offset) {
$sticky_offset++;
$sticky = $bbp->topic_query->posts[$post_offset];
//.........这里部分代码省略.........
示例9: bbp_redirect_canonical
/**
* Remove the canonical redirect to allow pretty pagination
*
* @since bbPress (r2628)
* @param string $redirect_url Redirect url
* @uses WP_Rewrite::using_permalinks() To check if the blog is using permalinks
* @uses bbp_get_paged() To get the current page number
* @uses bbp_is_single_topic() To check if it's a topic page
* @uses bbp_is_single_forum() To check if it's a forum page
* @return bool|string False if it's a topic/forum and their first page,
* otherwise the redirect url
*/
function bbp_redirect_canonical($redirect_url)
{
global $wp_rewrite;
// Canonical is for the beautiful
if ($wp_rewrite->using_permalinks()) {
// If viewing beyond page 1 of several
if (1 < bbp_get_paged()) {
// Only on single topics...
if (bbp_is_single_topic()) {
$redirect_url = false;
// ...and single forums...
} elseif (bbp_is_single_forum()) {
$redirect_url = false;
// ...and single replies...
} elseif (bbp_is_single_reply()) {
$redirect_url = false;
// ...and any single anything else...
//
// @todo - Find a more accurate way to disable paged canonicals for
// paged shortcode usage within other posts.
} elseif (is_page() || is_singular()) {
$redirect_url = false;
}
// If editing a topic
} elseif (bbp_is_topic_edit()) {
$redirect_url = false;
// If editing a reply
} elseif (bbp_is_reply_edit()) {
$redirect_url = false;
}
}
return $redirect_url;
}
示例10: the_permalink
the_permalink();
?>
">
<?php
do_action('bbp_theme_before_forum_form');
?>
<fieldset class="bbp-form">
<legend>
<?php
if (bbp_is_forum_edit()) {
printf(__('Now Editing “%s”', 'bbpress'), bbp_get_forum_title());
} else {
bbp_is_single_forum() ? printf(__('Create New Forum in “%s”', 'bbpress'), bbp_get_forum_title()) : _e('Create New Forum', 'bbpress');
}
?>
</legend>
<?php
do_action('bbp_theme_before_forum_form_notices');
?>
<?php
if (!bbp_is_forum_edit() && bbp_is_forum_closed()) {
?>
<div class="bbp-template-notice">
<p><?php
示例11: bbp_title
/**
* Custom page title for bbPress pages
*
* @since bbPress (r2788)
*
* @param string $title Optional. The title (not used).
* @param string $sep Optional, default is '»'. How to separate the
* various items within the page title.
* @param string $seplocation Optional. Direction to display title, 'right'.
* @uses bbp_is_single_user() To check if it's a user profile page
* @uses bbp_is_single_user_edit() To check if it's a user profile edit page
* @uses bbp_is_user_home() To check if the profile page is of the current user
* @uses get_query_var() To get the user id
* @uses get_userdata() To get the user data
* @uses bbp_is_single_forum() To check if it's a forum
* @uses bbp_get_forum_title() To get the forum title
* @uses bbp_is_single_topic() To check if it's a topic
* @uses bbp_get_topic_title() To get the topic title
* @uses bbp_is_single_reply() To check if it's a reply
* @uses bbp_get_reply_title() To get the reply title
* @uses is_tax() To check if it's the tag page
* @uses get_queried_object() To get the queried object
* @uses bbp_is_single_view() To check if it's a view
* @uses bbp_get_view_title() To get the view title
* @uses apply_filters() Calls 'bbp_raw_title' with the title
* @uses apply_filters() Calls 'bbp_profile_page_wp_title' with the title,
* separator and separator location
* @return string The tite
*/
function bbp_title($title = '', $sep = '»', $seplocation = '')
{
// Title array
$new_title = array();
/** Archives **************************************************************/
// Forum Archive
if (bbp_is_forum_archive()) {
$new_title['text'] = bbp_get_forum_archive_title();
// Topic Archive
} elseif (bbp_is_topic_archive()) {
$new_title['text'] = bbp_get_topic_archive_title();
/** Edit ******************************************************************/
// Forum edit page
} elseif (bbp_is_forum_edit()) {
$new_title['text'] = bbp_get_forum_title();
$new_title['format'] = esc_attr__('Forum Edit: %s', 'bbpress');
// Topic edit page
} elseif (bbp_is_topic_edit()) {
$new_title['text'] = bbp_get_topic_title();
$new_title['format'] = esc_attr__('Topic Edit: %s', 'bbpress');
// Reply edit page
} elseif (bbp_is_reply_edit()) {
$new_title['text'] = bbp_get_reply_title();
$new_title['format'] = esc_attr__('Reply Edit: %s', 'bbpress');
// Topic tag edit page
} elseif (bbp_is_topic_tag_edit()) {
$new_title['text'] = bbp_get_topic_tag_name();
$new_title['format'] = esc_attr__('Topic Tag Edit: %s', 'bbpress');
/** Singles ***************************************************************/
// Forum page
} elseif (bbp_is_single_forum()) {
$new_title['text'] = bbp_get_forum_title();
$new_title['format'] = esc_attr__('Forum: %s', 'bbpress');
// Topic page
} elseif (bbp_is_single_topic()) {
$new_title['text'] = bbp_get_topic_title();
$new_title['format'] = esc_attr__('Topic: %s', 'bbpress');
// Replies
} elseif (bbp_is_single_reply()) {
$new_title['text'] = bbp_get_reply_title();
// Topic tag page
} elseif (bbp_is_topic_tag() || get_query_var('bbp_topic_tag')) {
$new_title['text'] = bbp_get_topic_tag_name();
$new_title['format'] = esc_attr__('Topic Tag: %s', 'bbpress');
/** Users *****************************************************************/
// Profile page
} elseif (bbp_is_single_user()) {
// User is viewing their own profile
if (bbp_is_user_home()) {
$new_title['text'] = esc_attr_x('Your', 'User viewing his/her own profile', 'bbpress');
// User is viewing someone else's profile (so use their display name)
} else {
$new_title['text'] = sprintf(esc_attr_x("%s's", 'User viewing another users profile', 'bbpress'), get_userdata(bbp_get_user_id())->display_name);
}
// User topics created
if (bbp_is_single_user_topics()) {
$new_title['format'] = esc_attr__("%s Topics", 'bbpress');
// User rueplies created
} elseif (bbp_is_single_user_replies()) {
$new_title['format'] = esc_attr__("%s Replies", 'bbpress');
// User favorites
} elseif (bbp_is_favorites()) {
$new_title['format'] = esc_attr__("%s Favorites", 'bbpress');
// User subscriptions
} elseif (bbp_is_subscriptions()) {
$new_title['format'] = esc_attr__("%s Subscriptions", 'bbpress');
// User "home"
} else {
$new_title['format'] = esc_attr__("%s Profile", 'bbpress');
}
// Profile edit page
//.........这里部分代码省略.........
示例12: bbp_current_user_can_access_create_topic_form
/**
* Performs a series of checks to ensure the current user can create topics.
*
* @since 2.0.0 bbPress (r3127)
*
* @uses bbp_is_user_keymaster()
* @uses bbp_is_topic_edit()
* @uses current_user_can()
* @uses bbp_get_topic_id()
* @uses bbp_allow_anonymous()
* @uses is_user_logged_in()
*
* @return bool
*/
function bbp_current_user_can_access_create_topic_form()
{
// Users need to earn access
$retval = false;
// Always allow keymasters
if (bbp_is_user_keymaster()) {
$retval = true;
// Looking at a single forum & forum is open
} elseif ((bbp_is_single_forum() || is_page() || is_single()) && bbp_is_forum_open()) {
$retval = bbp_current_user_can_publish_topics();
// User can edit this topic
} elseif (bbp_is_topic_edit()) {
$retval = current_user_can('edit_topic', bbp_get_topic_id());
}
// Allow access to be filtered
return (bool) apply_filters('bbp_current_user_can_access_create_topic_form', (bool) $retval);
}
示例13: get_bbpress_breadcrumbs
static function get_bbpress_breadcrumbs($page_title)
{
if (td_util::get_option('tds_breadcrumbs_show') == 'hide') {
return;
}
$breadcrumbs_array[] = array('title_attribute' => '', 'url' => get_permalink(get_page_by_path('forums')), 'display_name' => __td('Forums'));
if (bbp_is_single_forum() or bbp_is_single_topic()) {
$breadcrumbs_array[] = array('title_attribute' => '', 'url' => sanitize_title(bbp_get_forum_title()), 'display_name' => bbp_get_forum_title());
}
return self::get_breadcrumbs($breadcrumbs_array);
}
示例14: breadcrumbs_plus_get_bbpress_items
/**
* Gets the items for the breadcrumb item if bbPress is installed.
*
* @since 0.4
*
* @param array $args Mixed arguments for the menu.
* @return array List of items to be shown in the item.
*/
function breadcrumbs_plus_get_bbpress_items($args = array())
{
$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[] = '<a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a>';
}
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, breadcrumbs_plus_get_parents(bbp_get_topic_forum_id($topic_id)));
if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
$item[] = '<a href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
} else {
$item[] = bbp_get_topic_title($topic_id);
}
if (bbp_is_topic_split()) {
$item[] = __('Split', 'theme_front');
} elseif (bbp_is_topic_merge()) {
$item[] = __('Merge', 'theme_front');
} elseif (bbp_is_topic_edit()) {
$item[] = __('Edit', 'theme_front');
}
} elseif (bbp_is_single_reply()) {
$reply_id = get_queried_object_id();
$item = array_merge($item, breadcrumbs_plus_get_parents(bbp_get_reply_topic_id($reply_id)));
if (!bbp_is_reply_edit()) {
$item[] = bbp_get_reply_title($reply_id);
} else {
$item[] = '<a href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a>';
$item[] = __('Edit', 'theme_front');
}
} elseif (bbp_is_single_forum()) {
$forum_id = get_queried_object_id();
$forum_parent_id = bbp_get_forum_parent($forum_id);
if (0 !== $forum_parent_id) {
$item = array_merge($item, breadcrumbs_plus_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[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a>';
$item[] = __('Edit');
} else {
$item[] = bbp_get_displayed_user_field('display_name');
}
}
return apply_filters('breadcrumbs_plus_get_bbpress_items', $item, $args);
}
示例15: x_bbpress_filter_breadcrumbs
function x_bbpress_filter_breadcrumbs($r)
{
if (bbp_is_search()) {
$current_text = bbp_get_search_title();
} elseif (bbp_is_forum_archive()) {
$current_text = bbp_get_forum_archive_title();
} elseif (bbp_is_topic_archive()) {
$current_text = bbp_get_topic_archive_title();
} elseif (bbp_is_single_view()) {
$current_text = bbp_get_view_title();
} elseif (bbp_is_single_forum()) {
$current_text = bbp_get_forum_title();
} elseif (bbp_is_single_topic()) {
$current_text = bbp_get_topic_title();
} elseif (bbp_is_single_reply()) {
$current_text = bbp_get_reply_title();
} 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="' . esc_url(bbp_get_topic_tag_edit_link()) . '" class="bbp-edit-topic-tag-link">' . esc_html__('(Edit)', 'bbpress') . '</a>';
}
// Implode the results of the tag data
$current_text = sprintf(__('Topic Tag: %s', 'bbpress'), implode(' ', $tag_data));
} elseif (bbp_is_topic_tag_edit()) {
$current_text = __('Edit', 'bbpress');
} else {
$current_text = get_the_title();
}
$r = array('before' => '', 'after' => '', 'sep' => x_get_breadcrumb_delimiter(), 'pad_sep' => 0, 'sep_before' => '', 'sep_after' => '', 'crumb_before' => '', 'crumb_after' => '', 'include_home' => false, 'home_text' => x_get_breadcrumb_home_text(), 'include_root' => true, 'root_text' => bbp_get_forum_archive_title(), 'include_current' => true, 'current_text' => $current_text, 'current_before' => x_get_breadcrumb_current_before(), 'current_after' => x_get_breadcrumb_current_after());
return $r;
}