本文整理汇总了PHP中bbp_parse_args函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_parse_args函数的具体用法?PHP bbp_parse_args怎么用?PHP bbp_parse_args使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bbp_parse_args函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_all_forums
public function get_all_forums()
{
$bbp_f = bbp_parse_args($args, array('post_type' => bbp_get_forum_post_type(), 'post_parent' => 'any', 'post_status' => bbp_get_public_status_id(), 'posts_per_page' => get_option('_bbp_forums_per_page', 50), 'ignore_sticky_posts' => true, 'orderby' => 'menu_order title', 'order' => 'ASC'), 'has_forums');
$bbp = bbpress();
$bbp->forum_query = new WP_Query($bbp_f);
$data = array();
foreach ($bbp->forum_query->posts as $post) {
$type = 'forum';
$is_parent = false;
$is_category = bbp_forum_get_subforums($post->ID);
if ($is_category) {
$type = 'category';
$parent = true;
}
$settings = $this->wlm->GetOption('bbpsettings');
if ($settings && count($settings) > 0) {
foreach ($settings as $setting) {
if ($setting["id"] == $post->ID) {
$data[$post->ID] = array("id" => $post->ID, "name" => $post->post_title, "level" => $setting["sku"], "protection" => $setting["protection"], "type" => $type, "parent" => $parent, "date" => "");
}
}
if (!isset($data[$post->ID])) {
$data[$post->ID] = array("id" => $post->ID, "name" => $post->post_title, "level" => "", "protection" => "", "type" => $type, "parent" => $parent, "date" => "");
}
} else {
$data[$post->ID] = array("id" => $post->ID, "name" => $post->post_title, "level" => "", "protection" => "", "type" => $type, "parent" => $parent, "date" => "");
}
}
echo json_encode($data);
die;
}
示例2: bbp_search_query
/**
* Run the search query
*
* @since bbPress (r4579)
*
* @param mixed $new_args New arguments
* @uses bbp_get_search_query_args() To get the search query args
* @uses bbp_parse_args() To parse the args
* @uses bbp_has_search_results() To make the search query
* @return bool False if no results, otherwise if search results are there
*/
function bbp_search_query($new_args = array())
{
// Existing arguments
$query_args = bbp_get_search_query_args();
// Merge arguments
if (!empty($new_args)) {
$new_args = bbp_parse_args($new_args, array(), 'search_query');
$query_args = array_merge($query_args, $new_args);
}
return bbp_has_search_results($query_args);
}
示例3: tehnik_bpp_filter_forums_by_permissions
/**
* This function filters the list of forums based on the users rank as set by the Mebmers plugin
*/
function tehnik_bpp_filter_forums_by_permissions($args = '')
{
$bbp = bbpress();
// Setup possible post__not_in array
$post_stati[] = bbp_get_public_status_id();
// Check if user can read private forums
if (current_user_can('read_private_forums')) {
$post_stati[] = bbp_get_private_status_id();
}
// Check if user can read hidden forums
if (current_user_can('read_hidden_forums')) {
$post_stati[] = bbp_get_hidden_status_id();
}
// The default forum query for most circumstances
$meta_query = array('post_type' => bbp_get_forum_post_type(), 'post_parent' => bbp_is_forum_archive() ? 0 : bbp_get_forum_id(), 'post_status' => implode(',', $post_stati), 'posts_per_page' => get_option('_bbp_forums_per_page', 50), 'orderby' => 'menu_order', 'order' => 'ASC');
//Get an array of IDs which the current user has permissions to view
$allowed_forums = tehnik_bpp_get_permitted_post_ids(new WP_Query($meta_query));
// The default forum query with allowed forum ids array added
$meta_query['post__in'] = $allowed_forums;
$bbp_f = bbp_parse_args($args, $meta_query, 'has_forums');
// Run the query
$bbp->forum_query = new WP_Query($bbp_f);
return apply_filters('bpp_filter_forums_by_permissions', $bbp->forum_query->have_posts(), $bbp->forum_query);
}
示例4: bbp_get_admin_repair_tool_overhead_filters
/**
* Get filter links for components for a specific admir repair tool
*
* @since 2.6.0 bbPress (r5885)
*
* @param array $args
* @return array
*/
function bbp_get_admin_repair_tool_overhead_filters($args = array())
{
// Parse args
$r = bbp_parse_args($args, array('before' => '<ul class="subsubsub">', 'after' => '</ul>', 'link_before' => '<li>', 'link_after' => '</li>', 'count_before' => ' <span class="count">(', 'count_after' => ')</span>', 'separator' => ' | '), 'get_admin_repair_tool_overhead_filters');
// Count the tools
$tools = bbp_get_admin_repair_tools();
// Get the tools URL
$tools_url = add_query_arg(array('page' => 'bbp-repair'), admin_url('tools.php'));
// Define arrays
$overheads = array();
// Loop through tools and count overheads
foreach ($tools as $id => $tool) {
// Get the overhead level
$overhead = $tool['overhead'];
// Set an empty count
if (empty($overheads[$overhead])) {
$overheads[$overhead] = 0;
}
// Bump the overhead count
$overheads[$overhead]++;
}
// Create the "All" link
$current = empty($_GET['overhead']) ? 'current' : '';
$output = $r['link_before'] . '<a href="' . esc_url($tools_url) . '" class="' . esc_attr($current) . '">' . sprintf(esc_html__('All %s', 'bbpress'), $r['count_before'] . count($tools) . $r['count_after']) . '</a>' . $r['separator'] . $r['link_after'];
// Default ticker
$i = 0;
// Loop through overheads and build filter
foreach ($overheads as $overhead => $count) {
// Separator count
$i++;
// Build the filter URL
$key = sanitize_key($overhead);
$args = array('overhead' => $key);
$filter_url = add_query_arg($args, $tools_url);
// Figure out separator and active class
$show_sep = count($overheads) > $i ? $r['separator'] : '';
$current = !empty($_GET['overhead']) && sanitize_key($_GET['overhead']) === $key ? 'current' : '';
// Counts to show
if (!empty($count)) {
$overhead_count = $r['count_before'] . $count . $r['count_after'];
}
// Build the link
$output .= $r['link_before'] . '<a href="' . esc_url($filter_url) . '" class="' . esc_attr($current) . '">' . $overhead . $overhead_count . '</a>' . $show_sep . $r['link_after'];
}
// Surround output with before & after strings
$output = $r['before'] . $output . $r['after'];
// Filter & return
return apply_filters('bbp_get_admin_repair_tool_components', $output, $r, $args);
}
示例5: bbp_update_topic_revision_log
/**
* Update the revision log of the topic
*
* @since bbPress (r2782)
*
* @param mixed $args Supports these args:
* - topic_id: Topic id
* - author_id: Author id
* - reason: Reason for editing
* - revision_id: Revision id
* @uses bbp_get_topic_id() To get the topic id
* @uses bbp_format_revision_reason() To format the reason
* @uses bbp_get_topic_raw_revision_log() To get the raw topic revision log
* @uses update_post_meta() To update the topic revision log meta
* @return mixed False on failure, true on success
*/
function bbp_update_topic_revision_log($args = '')
{
// Parse arguments against default values
$r = bbp_parse_args($args, array('reason' => '', 'topic_id' => 0, 'author_id' => 0, 'revision_id' => 0), 'update_topic_revision_log');
// Populate the variables
$r['reason'] = bbp_format_revision_reason($r['reason']);
$r['topic_id'] = bbp_get_topic_id($r['topic_id']);
$r['author_id'] = bbp_get_user_id($r['author_id'], false, true);
$r['revision_id'] = (int) $r['revision_id'];
// Get the logs and append the new one to those
$revision_log = bbp_get_topic_raw_revision_log($r['topic_id']);
$revision_log[$r['revision_id']] = array('author' => $r['author_id'], 'reason' => $r['reason']);
// Finally, update
return update_post_meta($r['topic_id'], '_bbp_revision_log', $revision_log);
}
示例6: bbp_get_breadcrumb
//.........这里部分代码省略.........
$pre_current_text = bbp_get_topic_archive_title();
// View
} elseif (bbp_is_single_view()) {
$pre_current_text = bbp_get_view_title();
// Single Forum
} elseif (bbp_is_single_forum()) {
$pre_current_text = bbp_get_forum_title();
// Single Topic
} elseif (bbp_is_single_topic()) {
$pre_current_text = bbp_get_topic_title();
// Single Topic
} elseif (bbp_is_single_reply()) {
$pre_current_text = bbp_get_reply_title();
// Topic Tag (or theme compat topic tag)
} elseif (bbp_is_topic_tag() || get_query_var('bbp_topic_tag') && !bbp_is_topic_tag_edit()) {
// Always include the tag name
$tag_data[] = bbp_get_topic_tag_name();
// If capable, include a link to edit the tag
if (current_user_can('manage_topic_tags')) {
$tag_data[] = '<a href="' . bbp_get_topic_tag_edit_link() . '" class="bbp-edit-topic-tag-link">' . __('(Edit)', 'bbpress') . '</a>';
}
// Implode the results of the tag data
$pre_current_text = sprintf(__('Topic Tag: %s', 'bbpress'), implode(' ', $tag_data));
// Edit Topic Tag
} elseif (bbp_is_topic_tag_edit()) {
$pre_current_text = __('Edit', 'bbpress');
// Single
} else {
$pre_current_text = get_the_title();
}
/** Parse Args ********************************************************/
// Parse args
$defaults = array('before' => '<div class="bbp-breadcrumb"><p>', 'after' => '</p></div>', 'sep' => __('›', 'bbpress'), 'pad_sep' => 1, 'include_home' => $pre_include_home, 'home_text' => $pre_front_text, 'include_root' => $pre_include_root, 'root_text' => $pre_root_text, 'include_current' => $pre_include_current, 'current_text' => $pre_current_text);
$r = bbp_parse_args($args, $defaults, 'get_breadcrumb');
extract($r);
/** Ancestors *********************************************************/
// Get post ancestors
if (is_page() || is_single() || bbp_is_forum_edit() || bbp_is_topic_edit() || bbp_is_reply_edit()) {
$ancestors = array_reverse(get_post_ancestors(get_the_ID()));
}
// Do we want to include a link to home?
if (!empty($include_home) || empty($home_text)) {
$crumbs[] = '<a href="' . trailingslashit(home_url()) . '" class="bbp-breadcrumb-home">' . $home_text . '</a>';
}
// Do we want to include a link to the forum root?
if (!empty($include_root) || empty($root_text)) {
// Page exists at root slug path, so use its permalink
$page = bbp_get_page_by_path(bbp_get_root_slug());
if (!empty($page)) {
$root_url = get_permalink($page->ID);
// Use the root slug
} else {
$root_url = get_post_type_archive_link(bbp_get_forum_post_type());
}
// Add the breadcrumb
$crumbs[] = '<a href="' . $root_url . '" class="bbp-breadcrumb-root">' . $root_text . '</a>';
}
// Ancestors exist
if (!empty($ancestors)) {
// Loop through parents
foreach ((array) $ancestors as $parent_id) {
// Parents
$parent = get_post($parent_id);
// Switch through post_type to ensure correct filters are applied
switch ($parent->post_type) {
// Forum
示例7: bbp_has_search_results
/**
* The main search loop. WordPress does the heavy lifting.
*
* @since bbPress (r4579)
*
* @param mixed $args All the arguments supported by {@link WP_Query}
* @uses bbp_get_view_all() Are we showing all results?
* @uses bbp_get_public_status_id() To get the public status id
* @uses bbp_get_closed_status_id() To get the closed status id
* @uses bbp_get_spam_status_id() To get the spam status id
* @uses bbp_get_trash_status_id() To get the trash status id
* @uses bbp_get_forum_post_type() To get the forum post type
* @uses bbp_get_topic_post_type() To get the topic post type
* @uses bbp_get_reply_post_type() To get the reply post type
* @uses bbp_get_replies_per_page() To get the replies per page option
* @uses bbp_get_paged() To get the current page value
* @uses bbp_get_search_terms() To get the search terms
* @uses WP_Query To make query and get the search results
* @uses WP_Rewrite::using_permalinks() To check if the blog is using permalinks
* @uses bbp_get_search_url() To get the forum search url
* @uses paginate_links() To paginate search results
* @uses apply_filters() Calls 'bbp_has_search_results' with
* bbPress::search_query::have_posts()
* and bbPress::reply_query
* @return object Multidimensional array of search information
*/
function bbp_has_search_results($args = '')
{
global $wp_rewrite;
/** Defaults **************************************************************/
$default_post_type = array(bbp_get_forum_post_type(), bbp_get_topic_post_type(), bbp_get_reply_post_type());
// Default query args
$default = array('post_type' => $default_post_type, 'posts_per_page' => bbp_get_replies_per_page(), 'paged' => bbp_get_paged(), 'orderby' => 'date', 'order' => 'DESC', 'ignore_sticky_posts' => true, 's' => bbp_get_search_terms());
// 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());
// 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';
}
/** Setup *****************************************************************/
// Parse arguments against default values
$r = bbp_parse_args($args, $default, 'has_search_results');
// Get bbPress
$bbp = bbpress();
// Call the query
if (!empty($r['s'])) {
$bbp->search_query = new WP_Query($r);
}
// Add pagination values to query object
$bbp->search_query->posts_per_page = $r['posts_per_page'];
$bbp->search_query->paged = $r['paged'];
// Never home, regardless of what parse_query says
$bbp->search_query->is_home = false;
// Only add pagination is query returned results
if (!empty($bbp->search_query->found_posts) && !empty($bbp->search_query->posts_per_page)) {
// Array of arguments to add after pagination links
$add_args = array();
// If pretty permalinks are enabled, make our pagination pretty
if ($wp_rewrite->using_permalinks()) {
// Shortcode territory
if (is_page() || is_single()) {
$base = trailingslashit(get_permalink());
// Default search location
} else {
$base = trailingslashit(bbp_get_search_results_url());
}
// Add pagination base
$base = $base . user_trailingslashit($wp_rewrite->pagination_base . '/%#%/');
// Unpretty permalinks
} else {
$base = add_query_arg('paged', '%#%');
}
// Add args
if (bbp_get_view_all()) {
$add_args['view'] = 'all';
}
// Add pagination to query object
$bbp->search_query->pagination_links = paginate_links(apply_filters('bbp_search_results_pagination', array('base' => $base, 'format' => '', 'total' => ceil((int) $bbp->search_query->found_posts / (int) $r['posts_per_page']), 'current' => (int) $bbp->search_query->paged, 'prev_text' => is_rtl() ? '→' : '←', 'next_text' => is_rtl() ? '←' : '→', 'mid_size' => 1, 'add_args' => $add_args)));
// Remove first page from pagination
if ($wp_rewrite->using_permalinks()) {
$bbp->search_query->pagination_links = str_replace($wp_rewrite->pagination_base . '/1/', '', $bbp->search_query->pagination_links);
} else {
$bbp->search_query->pagination_links = str_replace('&paged=1', '', $bbp->search_query->pagination_links);
}
}
// Return object
return apply_filters('bbp_has_search_results', $bbp->search_query->have_posts(), $bbp->search_query);
}
示例8: bbp_theme_compat_reset_post
/**
* This fun little function fills up some WordPress globals with dummy data to
* stop your average page template from complaining about it missing.
*
* @since bbPress (r3108)
* @global WP_Query $wp_query
* @global object $post
* @param array $args
*/
function bbp_theme_compat_reset_post($args = array())
{
global $wp_query, $post;
// Default arguments
$defaults = array('ID' => -9999, 'post_status' => bbp_get_public_status_id(), 'post_author' => 0, 'post_parent' => 0, 'post_type' => 'page', 'post_date' => 0, 'post_date_gmt' => 0, 'post_modified' => 0, 'post_modified_gmt' => 0, 'post_content' => '', 'post_title' => '', 'post_excerpt' => '', 'post_content_filtered' => '', 'post_mime_type' => '', 'post_password' => '', 'post_name' => '', 'guid' => '', 'menu_order' => 0, 'pinged' => '', 'to_ping' => '', 'ping_status' => '', 'comment_status' => 'closed', 'comment_count' => 0, 'is_404' => false, 'is_page' => false, 'is_single' => false, 'is_archive' => false, 'is_tax' => false);
// Switch defaults if post is set
if (isset($wp_query->post)) {
$defaults = array('ID' => $wp_query->post->ID, 'post_status' => $wp_query->post->post_status, 'post_author' => $wp_query->post->post_author, 'post_parent' => $wp_query->post->post_parent, 'post_type' => $wp_query->post->post_type, 'post_date' => $wp_query->post->post_date, 'post_date_gmt' => $wp_query->post->post_date_gmt, 'post_modified' => $wp_query->post->post_modified, 'post_modified_gmt' => $wp_query->post->post_modified_gmt, 'post_content' => $wp_query->post->post_content, 'post_title' => $wp_query->post->post_title, 'post_excerpt' => $wp_query->post->post_excerpt, 'post_content_filtered' => $wp_query->post->post_content_filtered, 'post_mime_type' => $wp_query->post->post_mime_type, 'post_password' => $wp_query->post->post_password, 'post_name' => $wp_query->post->post_name, 'guid' => $wp_query->post->guid, 'menu_order' => $wp_query->post->menu_order, 'pinged' => $wp_query->post->pinged, 'to_ping' => $wp_query->post->to_ping, 'ping_status' => $wp_query->post->ping_status, 'comment_status' => $wp_query->post->comment_status, 'comment_count' => $wp_query->post->comment_count, 'is_404' => false, 'is_page' => false, 'is_single' => false, 'is_archive' => false, 'is_tax' => false);
}
$dummy = bbp_parse_args($args, $defaults, 'theme_compat_reset_post');
// Clear out the post related globals
unset($wp_query->posts);
unset($wp_query->post);
unset($post);
// Setup the dummy post object
$wp_query->post = new stdClass();
$wp_query->post->ID = $dummy['ID'];
$wp_query->post->post_status = $dummy['post_status'];
$wp_query->post->post_author = $dummy['post_author'];
$wp_query->post->post_parent = $dummy['post_parent'];
$wp_query->post->post_type = $dummy['post_type'];
$wp_query->post->post_date = $dummy['post_date'];
$wp_query->post->post_date_gmt = $dummy['post_date_gmt'];
$wp_query->post->post_modified = $dummy['post_modified'];
$wp_query->post->post_modified_gmt = $dummy['post_modified_gmt'];
$wp_query->post->post_content = $dummy['post_content'];
$wp_query->post->post_title = $dummy['post_title'];
$wp_query->post->post_excerpt = $dummy['post_excerpt'];
$wp_query->post->post_content_filtered = $dummy['post_content_filtered'];
$wp_query->post->post_mime_type = $dummy['post_mime_type'];
$wp_query->post->post_password = $dummy['post_password'];
$wp_query->post->post_name = $dummy['post_name'];
$wp_query->post->guid = $dummy['guid'];
$wp_query->post->menu_order = $dummy['menu_order'];
$wp_query->post->pinged = $dummy['pinged'];
$wp_query->post->to_ping = $dummy['to_ping'];
$wp_query->post->ping_status = $dummy['ping_status'];
$wp_query->post->comment_status = $dummy['comment_status'];
$wp_query->post->comment_count = $dummy['comment_count'];
// Set the $post global
$post = $wp_query->post;
// Setup the dummy post loop
$wp_query->posts[0] = $wp_query->post;
// Prevent comments form from appearing
$wp_query->post_count = 1;
$wp_query->is_404 = $dummy['is_404'];
$wp_query->is_page = $dummy['is_page'];
$wp_query->is_single = $dummy['is_single'];
$wp_query->is_archive = $dummy['is_archive'];
$wp_query->is_tax = $dummy['is_tax'];
/**
* Force the header back to 200 status if not a deliberate 404
*
* @see http://bbpress.trac.wordpress.org/ticket/1973
*/
if (!$wp_query->is_404()) {
status_header(200);
}
// If we are resetting a post, we are in theme compat
bbp_set_theme_compat_active();
}
示例9: delete_activity
/**
* Wrapper for deleting bbPress actions from BuddyPress activity stream
*
* @since bbPress (r3395)
* @param type $args Array of arguments for bp_activity_add()
* @uses bbp_get_current_user_id()
* @uses bp_core_current_time()
* @uses bbp_parse_args()
* @uses aplly_filters()
* @uses bp_activity_add()
* @return type Activity ID if successful, false if not
*/
public function delete_activity($args = '')
{
// Default activity args
$defaults = array('item_id' => false, 'component' => $this->component, 'type' => false, 'user_id' => false, 'secondary_item_id' => false);
$activity = bbp_parse_args($args, $defaults, 'delete_activity');
// Delete the activity
bp_activity_delete_by_item_id($activity);
}
示例10: bbp_get_topic_forum_link
function bbp_get_topic_forum_link($args = '')
{
// Parse arguments against default values
$r = bbp_parse_args($args, array('id' => 0, 'link_before' => '', 'link_after' => '', 'edit_text' => esc_html__('List', 'bbpress')), 'get_topic_forum_link');
// Get uri
$uri = bbp_get_forum_permalink(bbp_get_topic_forum_id($r['id']));
// Bail if no uri
if (empty($uri)) {
return;
}
$retval = $r['link_before'] . '<a href="' . esc_url($uri) . '" class="bbp-topic-forum-link">' . $r['edit_text'] . '</a>' . $r['link_after'];
return apply_filters('bbp_get_topic_forum_link', $retval, $r);
}
示例11: get_reply_report_link
/**
* Render the reply report admin link
*
* @param array $args [description]
* @return string
*/
public function get_reply_report_link($args = '')
{
// Parse arguments against default values
$r = bbp_parse_args($args, array('id' => 0, 'link_before' => '', 'link_after' => '', 'report_text' => esc_html__('Report', 'bbpress-report-content'), 'unreport_text' => esc_html__('Unreport', 'bbpress-report-content')), 'get_reply_report_link');
$reply = bbp_get_reply(bbp_get_reply_id((int) $r['id']));
if (empty($reply)) {
return;
}
$reported = $this->is_reply_reported($reply->ID);
// Only display un-report link for
if ($reported && !current_user_can('moderate', $reply->ID)) {
return;
}
$display = $reported ? $r['unreport_text'] : $r['report_text'];
$uri = add_query_arg(array('action' => 'bbp_rc_toggle_reply_report', 'reply_id' => $reply->ID));
$uri = wp_nonce_url($uri, 'report-reply_' . $reply->ID);
$classes = array('bbp-reply-report-link');
$title = true === $reported ? __('Unreport inappropriate content', 'bbpress-report-content') : __('Report inappropriate content', 'bbpress-report-content');
if (true === $reported) {
$classes[] = 'reported';
} else {
$classes[] = 'unreported';
}
$retval = $r['link_before'] . '<a href="' . esc_url($uri) . '" class="' . join(' ', array_map('esc_attr', $classes)) . '" title="' . $title . '">' . $display . '</a>' . $r['link_after'];
return apply_filters('bbp_rc_get_reply_report_link', $retval, $r);
}
示例12: parse_settings
/**
* Merge the widget settings into defaults array.
*
* @since bbPress (r4802)
*
* @param $instance Instance
* @uses bbp_parse_args() To merge widget settings into defaults
*/
public function parse_settings($instance = array())
{
return bbp_parse_args($instance, array('title' => '', 'register' => '', 'lostpass' => ''), 'login_widget_settings');
}
示例13: st_bbp_list_forums
function st_bbp_list_forums($args = '')
{
// Define used variables
$output = $sub_forums = $topic_count = $reply_count = $counts = '';
$i = 0;
$count = array();
// Defaults and arguments
$defaults = array('before' => '<ul class="bbp-forums-list">', 'after' => '</ul>', 'link_before' => '<li class="bbp-forum">', 'link_after' => '</li>', 'count_before' => ' (', 'count_after' => ')', 'count_sep' => ', ', 'separator' => ', ', 'forum_id' => '', 'show_topic_count' => true, 'show_reply_count' => true, 'show_freshness_link' => true);
$r = bbp_parse_args($args, $defaults, 'list_forums');
extract($r, EXTR_SKIP);
// Bail if there are no subforums
if (!bbp_get_forum_subforum_count($forum_id)) {
return;
}
// Loop through forums and create a list
$sub_forums = bbp_forum_get_subforums($forum_id);
if (!empty($sub_forums)) {
// Total count (for separator)
$total_subs = count($sub_forums);
foreach ($sub_forums as $sub_forum) {
$i++;
// Separator count
// Get forum details
$count = array();
$show_sep = $total_subs > $i ? $separator : '';
$permalink = bbp_get_forum_permalink($sub_forum->ID);
$title = bbp_get_forum_title($sub_forum->ID);
$description = bbp_get_forum_content($sub_forum->ID);
// Show topic count
if (!empty($show_topic_count) && !bbp_is_forum_category($sub_forum->ID)) {
$count['topic'] = bbp_get_forum_topic_count($sub_forum->ID);
}
// Show reply count
if (!empty($show_reply_count) && !bbp_is_forum_category($sub_forum->ID)) {
$count['reply'] = bbp_get_forum_reply_count($sub_forum->ID);
}
// Counts to show
if (!empty($count)) {
$counts = $count_before . implode($count_sep, $count) . $count_after;
}
if (!empty($show_freshness_link)) {
$freshness_link = "<div class='freshness-forum-link'>" . st_get_last_poster_block($sub_forum->ID) . "</div>";
}
// Build this sub forums link
if ($i % 2) {
$class = "odd-forum-row";
} else {
$class = "even-forum-row";
}
$output .= "<li class='{$class}'><ul>" . $link_before . '<div class="bbp-forum-title-container"><a href="' . $permalink . '" class="bbp-forum-link">' . $title . '</a><p class="bbp-forum-description">' . $description . '</p></div>' . $counts . $freshness_link . $link_after . "</ul></li>";
}
// Output the list
echo apply_filters('bbp_list_forums', $before . $output . $after, $args);
}
}
示例14: parse_settings
/**
* Merge the widget settings into defaults array.
*
* @since bbPress (r4802)
*
* @param $instance Instance
* @uses bbp_parse_args() To merge widget settings into defaults
*/
public function parse_settings($instance = array())
{
return bbp_parse_args($instance, array('title' => __('Recent Replies', 'bbpress'), 'max_shown' => 5, 'show_date' => false, 'show_user' => false), 'replies_widget_settings');
}
示例15: bbp_create_initial_content
/**
* Create a default forum, topic, and reply
*
* @since bbPress (r3767)
* @param array $args Array of arguments to override default values
*/
function bbp_create_initial_content($args = array())
{
// Parse arguments against default values
$r = bbp_parse_args($args, array('forum_parent' => 0, 'forum_status' => 'publish', 'forum_title' => __('General', 'bbpress'), 'forum_content' => __('General chit-chat', 'bbpress'), 'topic_title' => __('Hello World!', 'bbpress'), 'topic_content' => __('I am the first topic in your new forums.', 'bbpress'), 'reply_title' => __('Re: Hello World!', 'bbpress'), 'reply_content' => __('Oh, and this is what a reply looks like.', 'bbpress')), 'create_initial_content');
// Create the initial forum
$forum_id = bbp_insert_forum(array('post_parent' => $r['forum_parent'], 'post_status' => $r['forum_status'], 'post_title' => $r['forum_title'], 'post_content' => $r['forum_content']));
// Create the initial topic
$topic_id = bbp_insert_topic(array('post_parent' => $forum_id, 'post_title' => $r['topic_title'], 'post_content' => $r['topic_content']), array('forum_id' => $forum_id));
// Create the initial reply
$reply_id = bbp_insert_reply(array('post_parent' => $topic_id, 'post_title' => $r['reply_title'], 'post_content' => $r['reply_content']), array('forum_id' => $forum_id, 'topic_id' => $topic_id));
return array('forum_id' => $forum_id, 'topic_id' => $topic_id, 'reply_id' => $reply_id);
}