本文整理汇总了PHP中bbp_get_topic_archive_slug函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_get_topic_archive_slug函数的具体用法?PHP bbp_get_topic_archive_slug怎么用?PHP bbp_get_topic_archive_slug使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bbp_get_topic_archive_slug函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bbp_get_topic_archive_title
/**
* Return the topic archive title
*
* @since 2.0.0 bbPress (r3249)
*
* @param string $title Default text to use as title
*
* @uses bbp_get_page_by_path() Check if page exists at root path
* @uses get_the_title() Use the page title at the root path
* @uses get_post_type_object() Load the post type object
* @uses bbp_get_topic_post_type() Get the topic post type ID
* @uses get_post_type_labels() Get labels for topic post type
* @uses apply_filters() Allow output to be manipulated
*
* @return string The topic archive title
*/
function bbp_get_topic_archive_title($title = '')
{
// If no title was passed
if (empty($title)) {
// Set root text to page title
$page = bbp_get_page_by_path(bbp_get_topic_archive_slug());
if (!empty($page)) {
$title = get_the_title($page->ID);
// Default to topic post type name label
} else {
$tto = get_post_type_object(bbp_get_topic_post_type());
$title = $tto->labels->name;
}
}
return apply_filters('bbp_get_topic_archive_title', $title);
}
示例2: bbp_replace_the_content
/**
* Replaces the_content() if the post_type being displayed is one that would
* normally be handled by bbPress, but proper single page templates do not
* exist in the currently active theme.
*
* Note that we do *not* currently use is_main_query() here. This is because so
* many existing themes either use query_posts() or fail to use wp_reset_query()
* when running queries before the main loop, causing theme compat to fail.
*
* @since bbPress (r3034)
* @param string $content
* @return type
*/
function bbp_replace_the_content($content = '')
{
// Bail if not inside the query loop
if (!in_the_loop()) {
return $content;
}
$bbp = bbpress();
// Define local variable(s)
$new_content = '';
// Bail if shortcodes are unset somehow
if (!is_a($bbp->shortcodes, 'BBP_Shortcodes')) {
return $content;
}
// Use shortcode API to display forums/topics/replies because they are
// already output buffered and ready to fit inside the_content
/** Users *************************************************************/
// Profile View
if (bbp_is_single_user_edit() || bbp_is_single_user()) {
ob_start();
bbp_get_template_part('content', 'single-user');
$new_content = ob_get_contents();
ob_end_clean();
/** Forums ************************************************************/
// Forum archive
} elseif (bbp_is_forum_archive()) {
// Page exists where this archive should be
$page = bbp_get_page_by_path(bbp_get_root_slug());
if (!empty($page)) {
// Restore previously unset filters
bbp_restore_all_filters('the_content');
// Remove 'bbp_replace_the_content' filter to prevent infinite loops
remove_filter('the_content', 'bbp_replace_the_content');
// Start output buffer
ob_start();
// Grab the content of this page
$new_content = apply_filters('the_content', $page->post_content);
// Clean up the buffer
ob_end_clean();
// Add 'bbp_replace_the_content' filter back (@see $this::start())
add_filter('the_content', 'bbp_replace_the_content');
// No page so show the archive
} else {
$new_content = $bbp->shortcodes->display_forum_index();
}
// Forum Edit
} elseif (bbp_is_forum_edit()) {
$new_content = $bbp->shortcodes->display_forum_form();
// Single Forum
} elseif (bbp_is_single_forum()) {
$new_content = $bbp->shortcodes->display_forum(array('id' => get_the_ID()));
/** Topics ************************************************************/
// Topic archive
} elseif (bbp_is_topic_archive()) {
// Page exists where this archive should be
$page = bbp_get_page_by_path(bbp_get_topic_archive_slug());
if (!empty($page)) {
// Restore previously unset filters
bbp_restore_all_filters('the_content');
// Remove 'bbp_replace_the_content' filter to prevent infinite loops
remove_filter('the_content', 'bbp_replace_the_content');
// Start output buffer
ob_start();
// Grab the content of this page
$new_content = apply_filters('the_content', $page->post_content);
// Clean up the buffer
ob_end_clean();
// Add 'bbp_replace_the_content' filter back (@see $this::start())
add_filter('the_content', 'bbp_replace_the_content');
// No page so show the archive
} else {
$new_content = $bbp->shortcodes->display_topic_index();
}
// Topic Edit
} elseif (bbp_is_topic_edit()) {
// Split
if (bbp_is_topic_split()) {
ob_start();
bbp_get_template_part('form', 'topic-split');
$new_content = ob_get_contents();
ob_end_clean();
// Merge
} elseif (bbp_is_topic_merge()) {
ob_start();
bbp_get_template_part('form', 'topic-merge');
$new_content = ob_get_contents();
ob_end_clean();
// Edit
//.........这里部分代码省略.........
示例3: bbp_get_topics_url
/**
* Return the forum URL
*
* @since bbPress (r3979)
*
* @uses home_url() To get the home URL
* @uses bbp_get_topic_archive_slug() To get the topics archive location
* @param string $path Additional path with leading slash
* @return The URL to the topics archive
*/
function bbp_get_topics_url($path = '/')
{
return home_url(bbp_get_topic_archive_slug() . $path);
}
示例4: add_rewrite_rules
/**
* Add bbPress-specific rewrite rules for uri's that are not
* setup for us by way of custom post types or taxonomies. This includes:
* - Front-end editing
* - Topic views
* - User profiles
*
* @since bbPress (r2688)
* @todo Extract into an API
*/
public static function add_rewrite_rules()
{
/** Setup *************************************************************/
// Add rules to top or bottom?
$priority = 'top';
// Single Slugs
$forum_slug = bbp_get_forum_slug();
$topic_slug = bbp_get_topic_slug();
$reply_slug = bbp_get_reply_slug();
$ttag_slug = bbp_get_topic_tag_tax_slug();
// Archive Slugs
$user_slug = bbp_get_user_slug();
$view_slug = bbp_get_view_slug();
$search_slug = bbp_get_search_slug();
$topic_archive_slug = bbp_get_topic_archive_slug();
$reply_archive_slug = bbp_get_reply_archive_slug();
// Tertiary Slugs
$feed_slug = 'feed';
$edit_slug = 'edit';
$paged_slug = bbp_get_paged_slug();
$user_favs_slug = bbp_get_user_favorites_slug();
$user_subs_slug = bbp_get_user_subscriptions_slug();
// Unique rewrite ID's
$feed_id = 'feed';
$edit_id = bbp_get_edit_rewrite_id();
$view_id = bbp_get_view_rewrite_id();
$paged_id = bbp_get_paged_rewrite_id();
$search_id = bbp_get_search_rewrite_id();
$user_id = bbp_get_user_rewrite_id();
$user_favs_id = bbp_get_user_favorites_rewrite_id();
$user_subs_id = bbp_get_user_subscriptions_rewrite_id();
$user_tops_id = bbp_get_user_topics_rewrite_id();
$user_reps_id = bbp_get_user_replies_rewrite_id();
// Rewrite rule matches used repeatedly below
$root_rule = '/([^/]+)/?$';
$feed_rule = '/([^/]+)/' . $feed_slug . '/?$';
$edit_rule = '/([^/]+)/' . $edit_slug . '/?$';
$paged_rule = '/([^/]+)/' . $paged_slug . '/?([0-9]{1,})/?$';
// Search rules (without slug check)
$search_root_rule = '/?$';
$search_paged_rule = '/' . $paged_slug . '/?([0-9]{1,})/?$';
/** Add ***************************************************************/
// User profile rules
$tops_rule = '/([^/]+)/' . $topic_archive_slug . '/?$';
$reps_rule = '/([^/]+)/' . $reply_archive_slug . '/?$';
$favs_rule = '/([^/]+)/' . $user_favs_slug . '/?$';
$subs_rule = '/([^/]+)/' . $user_subs_slug . '/?$';
$tops_paged_rule = '/([^/]+)/' . $topic_archive_slug . '/' . $paged_slug . '/?([0-9]{1,})/?$';
$reps_paged_rule = '/([^/]+)/' . $reply_archive_slug . '/' . $paged_slug . '/?([0-9]{1,})/?$';
$favs_paged_rule = '/([^/]+)/' . $user_favs_slug . '/' . $paged_slug . '/?([0-9]{1,})/?$';
$subs_paged_rule = '/([^/]+)/' . $user_subs_slug . '/' . $paged_slug . '/?([0-9]{1,})/?$';
// Edit Forum|Topic|Reply|Topic-tag
add_rewrite_rule($forum_slug . $edit_rule, 'index.php?' . bbp_get_forum_post_type() . '=$matches[1]&' . $edit_id . '=1', $priority);
add_rewrite_rule($topic_slug . $edit_rule, 'index.php?' . bbp_get_topic_post_type() . '=$matches[1]&' . $edit_id . '=1', $priority);
add_rewrite_rule($reply_slug . $edit_rule, 'index.php?' . bbp_get_reply_post_type() . '=$matches[1]&' . $edit_id . '=1', $priority);
add_rewrite_rule($ttag_slug . $edit_rule, 'index.php?' . bbp_get_topic_tag_tax_id() . '=$matches[1]&' . $edit_id . '=1', $priority);
// User Pagination|Edit|View
add_rewrite_rule($user_slug . $tops_paged_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_tops_id . '=1&' . $paged_id . '=$matches[2]', $priority);
add_rewrite_rule($user_slug . $reps_paged_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_reps_id . '=1&' . $paged_id . '=$matches[2]', $priority);
add_rewrite_rule($user_slug . $favs_paged_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_favs_id . '=1&' . $paged_id . '=$matches[2]', $priority);
add_rewrite_rule($user_slug . $subs_paged_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_subs_id . '=1&' . $paged_id . '=$matches[2]', $priority);
add_rewrite_rule($user_slug . $tops_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_tops_id . '=1', $priority);
add_rewrite_rule($user_slug . $reps_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_reps_id . '=1', $priority);
add_rewrite_rule($user_slug . $favs_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_favs_id . '=1', $priority);
add_rewrite_rule($user_slug . $subs_rule, 'index.php?' . $user_id . '=$matches[1]&' . $user_subs_id . '=1', $priority);
add_rewrite_rule($user_slug . $edit_rule, 'index.php?' . $user_id . '=$matches[1]&' . $edit_id . '=1', $priority);
add_rewrite_rule($user_slug . $root_rule, 'index.php?' . $user_id . '=$matches[1]', $priority);
// Topic-View Pagination|Feed|View
add_rewrite_rule($view_slug . $paged_rule, 'index.php?' . $view_id . '=$matches[1]&' . $paged_id . '=$matches[2]', $priority);
add_rewrite_rule($view_slug . $feed_rule, 'index.php?' . $view_id . '=$matches[1]&' . $feed_id . '=$matches[2]', $priority);
add_rewrite_rule($view_slug . $root_rule, 'index.php?' . $view_id . '=$matches[1]', $priority);
// Search All
add_rewrite_rule($search_slug . $search_paged_rule, 'index.php?' . $paged_id . '=$matches[1]', $priority);
add_rewrite_rule($search_slug . $search_root_rule, 'index.php?' . $search_id, $priority);
}
示例5: bbp_get_user_topics_created_url
/**
* Return the link to the user's topics
*
* @since 2.2.0 bbPress (r4225)
*
* @param int $user_id Optional. User id
* @uses bbp_get_user_profile_url() To get the user profile url
* @uses apply_filters() Calls 'bbp_get_favorites_permalink' with the
* user profile url and user id
* @return string Permanent link to user profile page
*/
function bbp_get_user_topics_created_url($user_id = 0)
{
// Use displayed user ID if there is one, and one isn't requested
$user_id = bbp_get_user_id($user_id);
if (empty($user_id)) {
return false;
}
// Allow early overriding of the profile URL to cut down on processing
$early_url = apply_filters('bbp_pre_get_user_topics_created_url', $user_id);
if (is_string($early_url)) {
return $early_url;
}
// Get user profile URL
$profile_url = bbp_get_user_profile_url($user_id);
// Pretty permalinks
if (bbp_use_pretty_urls()) {
$url = trailingslashit($profile_url) . bbp_get_topic_archive_slug();
$url = user_trailingslashit($url);
// Unpretty permalinks
} else {
$url = add_query_arg(array(bbp_get_user_topics_rewrite_id() => '1'), $profile_url);
}
return apply_filters('bbp_get_user_topics_created_url', $url, $user_id);
}
示例6: bbp_template_include_theme_compat
//.........这里部分代码省略.........
} else {
$new_content = $bbp_shortcodes->display_forum_index();
}
// ...or use the existing page content?
} else {
$new_content = apply_filters('the_content', $page->post_content);
}
// Should we replace the title...
if (empty($page->post_title)) {
// Use the topics archive
if ('topics' === bbp_show_on_root()) {
$new_title = bbp_get_topic_archive_title();
// No page so show the archive
} else {
$new_title = bbp_get_forum_archive_title();
}
// ...or use the existing page title?
} else {
$new_title = apply_filters('the_title', $page->post_title);
}
// Reset post
bbp_theme_compat_reset_post(array('ID' => !empty($page->ID) ? $page->ID : 0, 'post_title' => $new_title, 'post_author' => 0, 'post_date' => 0, 'post_content' => $new_content, 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_public_status_id(), 'is_archive' => true, 'comment_status' => 'closed'));
// Single Forum
} elseif (bbp_is_forum_edit()) {
// Reset post
bbp_theme_compat_reset_post(array('ID' => bbp_get_forum_id(), 'post_title' => bbp_get_forum_title(), 'post_author' => bbp_get_forum_author_id(), 'post_date' => 0, 'post_content' => $bbp_shortcodes->display_forum_form(), 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_forum_visibility(), 'is_single' => true, 'comment_status' => 'closed'));
} elseif (bbp_is_single_forum()) {
// Reset post
bbp_theme_compat_reset_post(array('ID' => bbp_get_forum_id(), 'post_title' => bbp_get_forum_title(), 'post_author' => bbp_get_forum_author_id(), 'post_date' => 0, 'post_content' => $bbp_shortcodes->display_forum(array('id' => bbp_get_forum_id())), 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_forum_visibility(), 'is_single' => true, 'comment_status' => 'closed'));
/** Topics ************************************************************/
// Topic archive
} elseif (bbp_is_topic_archive()) {
// Page exists where this archive should be
$page = bbp_get_page_by_path(bbp_get_topic_archive_slug());
// Should we replace the content...
if (empty($page->post_content)) {
$new_content = $bbp_shortcodes->display_topic_index();
// ...or use the existing page content?
} else {
$new_content = apply_filters('the_content', $page->post_content);
}
// Should we replace the title...
if (empty($page->post_title)) {
$new_title = bbp_get_topic_archive_title();
// ...or use the existing page title?
} else {
$new_title = apply_filters('the_title', $page->post_title);
}
// Reset post
bbp_theme_compat_reset_post(array('ID' => !empty($page->ID) ? $page->ID : 0, 'post_title' => bbp_get_topic_archive_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => $new_content, 'post_type' => bbp_get_topic_post_type(), 'post_status' => bbp_get_public_status_id(), 'is_archive' => true, 'comment_status' => 'closed'));
// Single Topic
} elseif (bbp_is_topic_edit() || bbp_is_single_topic()) {
// Split
if (bbp_is_topic_split()) {
$new_content = bbp_buffer_template_part('form', 'topic-split', false);
// Merge
} elseif (bbp_is_topic_merge()) {
$new_content = bbp_buffer_template_part('form', 'topic-merge', false);
// Edit
} elseif (bbp_is_topic_edit()) {
$new_content = $bbp_shortcodes->display_topic_form();
// Single
} else {
$new_content = $bbp_shortcodes->display_topic(array('id' => bbp_get_topic_id()));
}
// Reset post
示例7: setup_admin_bar
/**
* Set up the admin bar
*
* @since bbPress (r3552)
*/
public function setup_admin_bar($wp_admin_nav = array())
{
// Menus for logged in user
if (is_user_logged_in()) {
// Setup the logged in user variables
$user_domain = bp_loggedin_user_domain();
$forums_link = trailingslashit($user_domain . $this->slug);
// Add the "My Account" sub menus
$wp_admin_nav[] = array('parent' => buddypress()->my_account_menu_id, 'id' => 'my-account-' . $this->id, 'title' => __('Forums', 'bbpress'), 'href' => trailingslashit($forums_link));
// Topics
$wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-topics', 'title' => __('Topics Started', 'bbpress'), 'href' => trailingslashit($forums_link . bbp_get_topic_archive_slug()));
// Replies
$wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-replies', 'title' => __('Replies Created', 'bbpress'), 'href' => trailingslashit($forums_link . bbp_get_reply_archive_slug()));
// Favorites
$wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-favorites', 'title' => __('Favorite Topics', 'bbpress'), 'href' => trailingslashit($forums_link . bbp_get_user_favorites_slug()));
// Subscriptions
$wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-subscriptions', 'title' => __('Subscribed Topics', 'bbpress'), 'href' => trailingslashit($forums_link . bbp_get_user_subscriptions_slug()));
}
parent::setup_admin_bar($wp_admin_nav);
}
示例8: register_post_types
/**
* Setup the post types for forums, topics and replies
*
* @since bbPress (r2597)
* @uses register_post_type() To register the post types
* @uses apply_filters() Calls various filters to modify the arguments
* sent to register_post_type()
*/
public static function register_post_types()
{
// Define local variable(s)
$post_type = array();
/** Forums ************************************************************/
// Forum labels
$post_type['labels'] = array('name' => __('Forums', 'bbpress'), 'menu_name' => __('Forums', 'bbpress'), 'singular_name' => __('Forum', 'bbpress'), 'all_items' => __('All Forums', 'bbpress'), 'add_new' => __('New Forum', 'bbpress'), 'add_new_item' => __('Create New Forum', 'bbpress'), 'edit' => __('Edit', 'bbpress'), 'edit_item' => __('Edit Forum', 'bbpress'), 'new_item' => __('New Forum', 'bbpress'), 'view' => __('View Forum', 'bbpress'), 'view_item' => __('View Forum', 'bbpress'), 'search_items' => __('Search Forums', 'bbpress'), 'not_found' => __('No forums found', 'bbpress'), 'not_found_in_trash' => __('No forums found in Trash', 'bbpress'), 'parent_item_colon' => __('Parent Forum:', 'bbpress'));
// Forum rewrite
$post_type['rewrite'] = array('slug' => bbp_get_forum_slug(), 'with_front' => false);
// Forum supports
$post_type['supports'] = array('title', 'editor', 'revisions');
// Register Forum content type
register_post_type(bbp_get_forum_post_type(), apply_filters('bbp_register_forum_post_type', array('labels' => $post_type['labels'], 'rewrite' => $post_type['rewrite'], 'supports' => $post_type['supports'], 'description' => __('bbPress Forums', 'bbpress'), 'capabilities' => bbp_get_forum_caps(), 'capability_type' => array('forum', 'forums'), 'menu_position' => 555555, 'has_archive' => bbp_get_root_slug(), 'exclude_from_search' => true, 'show_in_nav_menus' => true, 'public' => true, 'show_ui' => current_user_can('bbp_forums_admin'), 'can_export' => true, 'hierarchical' => true, 'query_var' => true, 'menu_icon' => '')));
/** Topics ************************************************************/
// Topic labels
$post_type['labels'] = array('name' => __('Topics', 'bbpress'), 'menu_name' => __('Topics', 'bbpress'), 'singular_name' => __('Topic', 'bbpress'), 'all_items' => __('All Topics', 'bbpress'), 'add_new' => __('New Topic', 'bbpress'), 'add_new_item' => __('Create New Topic', 'bbpress'), 'edit' => __('Edit', 'bbpress'), 'edit_item' => __('Edit Topic', 'bbpress'), 'new_item' => __('New Topic', 'bbpress'), 'view' => __('View Topic', 'bbpress'), 'view_item' => __('View Topic', 'bbpress'), 'search_items' => __('Search Topics', 'bbpress'), 'not_found' => __('No topics found', 'bbpress'), 'not_found_in_trash' => __('No topics found in Trash', 'bbpress'), 'parent_item_colon' => __('Forum:', 'bbpress'));
// Topic rewrite
$post_type['rewrite'] = array('slug' => bbp_get_topic_slug(), 'with_front' => false);
// Topic supports
$post_type['supports'] = array('title', 'editor', 'revisions');
// Register Topic content type
register_post_type(bbp_get_topic_post_type(), apply_filters('bbp_register_topic_post_type', array('labels' => $post_type['labels'], 'rewrite' => $post_type['rewrite'], 'supports' => $post_type['supports'], 'description' => __('bbPress Topics', 'bbpress'), 'capabilities' => bbp_get_topic_caps(), 'capability_type' => array('topic', 'topics'), 'menu_position' => 555555, 'has_archive' => bbp_get_topic_archive_slug(), 'exclude_from_search' => true, 'show_in_nav_menus' => false, 'public' => true, 'show_ui' => current_user_can('bbp_topics_admin'), 'can_export' => true, 'hierarchical' => false, 'query_var' => true, 'menu_icon' => '')));
/** Replies ***********************************************************/
// Reply labels
$post_type['labels'] = array('name' => __('Replies', 'bbpress'), 'menu_name' => __('Replies', 'bbpress'), 'singular_name' => __('Reply', 'bbpress'), 'all_items' => __('All Replies', 'bbpress'), 'add_new' => __('New Reply', 'bbpress'), 'add_new_item' => __('Create New Reply', 'bbpress'), 'edit' => __('Edit', 'bbpress'), 'edit_item' => __('Edit Reply', 'bbpress'), 'new_item' => __('New Reply', 'bbpress'), 'view' => __('View Reply', 'bbpress'), 'view_item' => __('View Reply', 'bbpress'), 'search_items' => __('Search Replies', 'bbpress'), 'not_found' => __('No replies found', 'bbpress'), 'not_found_in_trash' => __('No replies found in Trash', 'bbpress'), 'parent_item_colon' => __('Topic:', 'bbpress'));
// Reply rewrite
$post_type['rewrite'] = array('slug' => bbp_get_reply_slug(), 'with_front' => false);
// Reply supports
$post_type['supports'] = array('title', 'editor', 'revisions');
// Register reply content type
register_post_type(bbp_get_reply_post_type(), apply_filters('bbp_register_reply_post_type', array('labels' => $post_type['labels'], 'rewrite' => $post_type['rewrite'], 'supports' => $post_type['supports'], 'description' => __('bbPress Replies', 'bbpress'), 'capabilities' => bbp_get_reply_caps(), 'capability_type' => array('reply', 'replies'), 'menu_position' => 555555, 'exclude_from_search' => true, 'has_archive' => false, 'show_in_nav_menus' => false, 'public' => true, 'show_ui' => current_user_can('bbp_replies_admin'), 'can_export' => true, 'hierarchical' => false, 'query_var' => true, 'menu_icon' => '')));
}
示例9: setup_admin_bar
/**
* Set up the admin bar
*
* @since 2.1.0 bbPress (r3552)
*/
public function setup_admin_bar($wp_admin_nav = array())
{
// Menus for logged in user
if (is_user_logged_in()) {
// If BuddyPress is network activated and bbPress is
// not activated on a the root blog but on any child one
if (!bp_is_root_blog()) {
$user_id = bbp_get_current_user_id();
$my_account_link = bbp_get_user_profile_url($user_id);
$my_topics_link = bbp_get_user_topics_created_url($user_id);
$my_replies_link = bbp_get_user_replies_created_url($user_id);
$my_favorites_link = bbp_get_favorites_permalink($user_id);
$my_subscriptions_link = bbp_get_subscriptions_permalink($user_id);
} else {
// Setup the logged in user variables
$user_domain = bp_loggedin_user_domain();
$forums_link = trailingslashit($user_domain . $this->slug);
$my_account_link = trailingslashit($forums_link);
$my_topics_link = trailingslashit($forums_link . bbp_get_topic_archive_slug());
$my_replies_link = trailingslashit($forums_link . bbp_get_reply_archive_slug());
$my_favorites_link = trailingslashit($forums_link . bbp_get_user_favorites_slug());
$my_subscriptions_link = trailingslashit($forums_link . bbp_get_user_subscriptions_slug());
}
// Add the "My Account" sub menus
$wp_admin_nav[] = array('parent' => buddypress()->my_account_menu_id, 'id' => 'my-account-' . $this->id, 'title' => __('Forums', 'bbpress'), 'href' => $my_account_link);
// Topics
$wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-topics', 'title' => __('Topics Started', 'bbpress'), 'href' => $my_topics_link);
// Replies
$wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-replies', 'title' => __('Replies Created', 'bbpress'), 'href' => $my_replies_link);
// Favorites
$wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-favorites', 'title' => __('Favorite Topics', 'bbpress'), 'href' => $my_favorites_link);
// Subscriptions
$wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-subscriptions', 'title' => __('Subscribed Topics', 'bbpress'), 'href' => $my_subscriptions_link);
}
parent::setup_admin_bar($wp_admin_nav);
}
示例10: user_profile_url
/**
* Override bbPress profile URL with BuddyPress profile URL
*
* @since bbPress (r3401)
* @param string $url
* @param int $user_id
* @param string $user_nicename
* @return string
*/
public function user_profile_url($user_id)
{
// Define local variable(s)
$profile_url = '';
$component_slug = bbpress()->extend->buddypress->slug;
// Special handling for forum component
if (bp_is_current_component($component_slug)) {
// Empty action or 'topics' action
if (!bp_current_action() || bp_is_current_action(bbp_get_topic_archive_slug())) {
$profile_url = bp_core_get_user_domain($user_id) . $component_slug . '/' . bbp_get_topic_archive_slug();
// Empty action or 'topics' action
} elseif (bp_is_current_action(bbp_get_reply_archive_slug())) {
$profile_url = bp_core_get_user_domain($user_id) . $component_slug . '/' . bbp_get_reply_archive_slug();
// 'favorites' action
} elseif (bbp_is_favorites_active() && bp_is_current_action(bbp_get_user_favorites_slug())) {
$profile_url = $this->get_favorites_permalink('', $user_id);
// 'subscriptions' action
} elseif (bbp_is_subscriptions_active() && bp_is_current_action(bbp_get_user_subscriptions_slug())) {
$profile_url = $this->get_subscriptions_permalink('', $user_id);
}
// Not in users' forums area
} else {
$profile_url = bp_core_get_user_domain($user_id);
}
return trailingslashit($profile_url);
}
示例11: bbp_replace_the_content
/**
* Replaces the_content() if the post_type being displayed is one that would
* normally be handled by bbPress, but proper single page templates do not
* exist in the currently active theme.
*
* @since bbPress (r3034)
* @param string $content
* @return type
*/
function bbp_replace_the_content($content = '')
{
$bbp = bbpress();
// Define local variable(s)
$new_content = '';
// Bail if shortcodes are unset somehow
if (!is_a($bbp->shortcodes, 'BBP_Shortcodes')) {
return $content;
}
// Use shortcode API to display forums/topics/replies because they are
// already output buffered and ready to fit inside the_content
/** Users *************************************************************/
// Profile View
if (bbp_is_single_user()) {
ob_start();
bbp_get_template_part('content', 'single-user');
$new_content = ob_get_contents();
ob_end_clean();
// Profile Edit
} elseif (bbp_is_single_user_edit()) {
ob_start();
bbp_get_template_part('content', 'single-user-edit');
$new_content = ob_get_contents();
ob_end_clean();
/** Forums ************************************************************/
// Reply Edit
} elseif (bbp_is_forum_edit()) {
$new_content = $bbp->shortcodes->display_forum_form();
// Forum archive
} elseif (bbp_is_forum_archive()) {
// Page exists where this archive should be
$page = bbp_get_page_by_path(bbp_get_root_slug());
if (!empty($page)) {
// Restore previously unset filters
bbp_restore_all_filters('the_content');
// Remove 'bbp_replace_the_content' filter to prevent infinite loops
remove_filter('the_content', 'bbp_replace_the_content');
// Start output buffer
ob_start();
// Grab the content of this page
$new_content = apply_filters('the_content', $page->post_content);
// Clean up the buffer
ob_end_clean();
// Add 'bbp_replace_the_content' filter back (@see $this::start())
add_filter('the_content', 'bbp_replace_the_content');
// No page so show the archive
} else {
$new_content = $bbp->shortcodes->display_forum_index();
}
/** Topics ************************************************************/
// Topic archive
} elseif (bbp_is_topic_archive()) {
// Page exists where this archive should be
$page = bbp_get_page_by_path(bbp_get_topic_archive_slug());
if (!empty($page)) {
// Restore previously unset filters
bbp_restore_all_filters('the_content');
// Remove 'bbp_replace_the_content' filter to prevent infinite loops
remove_filter('the_content', 'bbp_replace_the_content');
// Start output buffer
ob_start();
// Grab the content of this page
$new_content = apply_filters('the_content', $page->post_content);
// Clean up the buffer
ob_end_clean();
// Add 'bbp_replace_the_content' filter back (@see $this::start())
add_filter('the_content', 'bbp_replace_the_content');
// No page so show the archive
} else {
$new_content = $bbp->shortcodes->display_topic_index();
}
// Single topic
} elseif (bbp_is_topic_edit()) {
// Split
if (bbp_is_topic_split()) {
ob_start();
bbp_get_template_part('form', 'topic-split');
$new_content = ob_get_contents();
ob_end_clean();
// Merge
} elseif (bbp_is_topic_merge()) {
ob_start();
bbp_get_template_part('form', 'topic-merge');
$new_content = ob_get_contents();
ob_end_clean();
// Edit
} else {
$new_content = $bbp->shortcodes->display_topic_form();
}
/** Replies ***********************************************************/
// Reply archive
//.........这里部分代码省略.........
示例12: bbp_get_user_topics_created_url
/**
* Return the link to the user's topics
*
* @since bbPress (r4225)
*
* @param int $user_id Optional. User id
* @uses bbp_get_user_profile_url() To get the user profile url
* @uses apply_filters() Calls 'bbp_get_favorites_permalink' with the
* user profile url and user id
* @return string Permanent link to user profile page
*/
function bbp_get_user_topics_created_url($user_id = 0)
{
global $wp_rewrite;
// Use displayed user ID if there is one, and one isn't requested
$user_id = bbp_get_user_id($user_id);
if (empty($user_id)) {
return false;
}
// Allow early overriding of the profile URL to cut down on processing
$early_url = apply_filters('bbp_pre_get_user_topics_created_url', (int) $user_id);
if (is_string($early_url)) {
return $early_url;
}
// Pretty permalinks
if ($wp_rewrite->using_permalinks()) {
$url = $wp_rewrite->root . bbp_get_user_slug() . '/%' . bbp_get_user_rewrite_id() . '%/' . bbp_get_topic_archive_slug();
$user = get_userdata($user_id);
if (!empty($user->user_nicename)) {
$user_nicename = $user->user_nicename;
} else {
$user_nicename = $user->user_login;
}
$url = str_replace('%' . bbp_get_user_rewrite_id() . '%', $user_nicename, $url);
$url = home_url(user_trailingslashit($url));
// Unpretty permalinks
} else {
$url = add_query_arg(array(bbp_get_user_rewrite_id() => $user_id, bbp_get_user_topics_rewrite_id() => '1'), home_url('/'));
}
return apply_filters('bbp_get_user_topics_created_url', $url, $user_id);
}