本文整理汇总了PHP中bbp_get_forum_post_type函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_get_forum_post_type函数的具体用法?PHP bbp_get_forum_post_type怎么用?PHP bbp_get_forum_post_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bbp_get_forum_post_type函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: mycred_exclude_post_type_bbPress
function mycred_exclude_post_type_bbPress($excludes)
{
$excludes[] = bbp_get_forum_post_type();
$excludes[] = bbp_get_topic_post_type();
$excludes[] = bbp_get_reply_post_type();
return $excludes;
}
开发者ID:socialray,项目名称:surfied-2-0,代码行数:7,代码来源:mycred-hook-bbPress.php
示例2: bbp_admin_menu_order
/**
* Move our custom separator above our custom post types
*
* @since bbPress (r2957)
*
* @param array $menu_order Menu Order
* @uses bbp_get_forum_post_type() To get the forum post type
* @return array Modified menu order
*/
function bbp_admin_menu_order($menu_order)
{
// Bail if user cannot see any top level bbPress menus
if (empty($menu_order) || false === bbpress()->admin->show_separator) {
return $menu_order;
}
// Initialize our custom order array
$bbp_menu_order = array();
// Menu values
$second_sep = 'separator2';
$custom_menus = array('separator-bbpress', 'edit.php?post_type=' . bbp_get_forum_post_type(), 'edit.php?post_type=' . bbp_get_topic_post_type(), 'edit.php?post_type=' . bbp_get_reply_post_type());
// Loop through menu order and do some rearranging
foreach ($menu_order as $item) {
// Position bbPress menus above appearance
if ($second_sep == $item) {
// Add our custom menus
foreach ($custom_menus as $custom_menu) {
if (array_search($custom_menu, $menu_order)) {
$bbp_menu_order[] = $custom_menu;
}
}
// Add the appearance separator
$bbp_menu_order[] = $second_sep;
// Skip our menu items
} elseif (!in_array($item, $custom_menus)) {
$bbp_menu_order[] = $item;
}
}
// Return our custom order
return $bbp_menu_order;
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:40,代码来源:functions.php
示例3: om_add_bbpress_meta_box
function om_add_bbpress_meta_box()
{
global $om_bbpress_meta_box;
if (function_exists('bbp_get_forum_post_type')) {
ommb_add_meta_boxes($om_bbpress_meta_box, bbp_get_forum_post_type());
}
}
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:7,代码来源:bbpress-meta.php
示例4: 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;
}
开发者ID:brooklyntri,项目名称:btc-plugins,代码行数:31,代码来源:integration.other.bbpress.php
示例5: parse_query
public static function parse_query($posts_query)
{
// Bail if $posts_query is not the main loop
if (!$posts_query->is_main_query()) {
return;
}
// Bail if filters are suppressed on this query
if (true === $posts_query->get('suppress_filters')) {
return;
}
// Bail if in admin
if (is_admin()) {
return;
}
// Get query variables
$is_write = $posts_query->get(bbp_get_write_rewrite_id());
// Write?
if (!empty($is_write)) {
// Get the post type from the main query loop
$post_type = $posts_query->get('post_type');
// Check which post_type we are editing, if any
if (!empty($post_type)) {
switch ($post_type) {
// We are editing a forum
case bbp_get_forum_post_type():
$posts_query->bbp_is_topic_write = true;
$posts_query->bbp_is_write = true;
break;
}
}
}
}
开发者ID:082net,项目名称:bbpresskr,代码行数:32,代码来源:topic.php
示例6: bbpress_forumslist_settings_field
function bbpress_forumslist_settings_field($settings, $value)
{
$dependency = vc_generate_dependencies_attributes($settings);
$param_name = isset($settings['param_name']) ? $settings['param_name'] : '';
$type = isset($settings['type']) ? $settings['type'] : '';
$allforums = isset($settings['allforums']) ? $settings['allforums'] : 'false';
$value_arr = $value;
$args = array('post_type' => bbp_get_forum_post_type(), 'orderby' => 'title', 'order' => 'ASC');
$forums = new WP_Query($args);
$output = '';
$output .= '<select name="' . $settings['param_name'] . '" class="wpb_vc_param_value wpb-input wpb-select ' . $settings['param_name'] . ' ' . $settings['type'] . '">';
if ($allforums == "true") {
$output .= "<option value=''>" . __("All Forums", "ts_visual_composer_extend") . "</option>";
}
while ($forums->have_posts()) {
$forums->the_post();
if ($value != '' && get_the_ID() == $value) {
$selected = ' selected="selected"';
} else {
$selected = "";
}
$output .= '<option class="' . get_the_ID() . '" data-id="' . get_the_ID() . '" data-value="' . get_the_title() . '" value="' . get_the_ID() . '"' . $selected . '>' . get_the_title() . '</option>';
}
wp_reset_query();
$output .= '</select>';
return $output;
}
开发者ID:baochung26,项目名称:happy-c,代码行数:27,代码来源:ts_vcsc_parameter_woocommerce.php
示例7: widget
/**
* Displays the output, the forum list
*
* @since bbPress (r2653)
*
* @param mixed $args Arguments
* @param array $instance Instance
* @uses apply_filters() Calls 'bbp_forum_widget_title' with the title
* @uses get_option() To get the forums per page option
* @uses current_user_can() To check if the current user can read
* private() To resety name
* @uses bbp_has_forums() The main forum loop
* @uses bbp_forums() To check whether there are more forums available
* in the loop
* @uses bbp_the_forum() Loads up the current forum in the loop
* @uses bbp_forum_permalink() To display the forum permalink
* @uses bbp_forum_title() To display the forum title
*/
public function widget($args, $instance)
{
extract($args);
$title = apply_filters('bbp_forum_widget_title', $instance['title']);
$parent_forum = !empty($instance['parent_forum']) ? $instance['parent_forum'] : '0';
// Note: private and hidden forums will be excluded via the
// bbp_pre_get_posts_exclude_forums filter and function.
$widget_query = new WP_Query(array('post_parent' => $parent_forum, 'post_type' => bbp_get_forum_post_type(), 'posts_per_page' => get_option('_bbp_forums_per_page', 50), 'orderby' => 'menu_order', 'order' => 'ASC'));
if ($widget_query->have_posts()) {
echo $before_widget;
echo $before_title . $title . $after_title;
$current_forum_id = bbp_get_forum_id();
?>
<ul>
<?php
while ($widget_query->have_posts()) {
$widget_query->the_post();
?>
<?php
$current = $widget_query->post->ID == $current_forum_id ? 'current' : '';
?>
<li>
<a class="bbp-forum-title <?php
echo $current;
?>
" href="<?php
bbp_forum_permalink($widget_query->post->ID);
?>
" title="<?php
bbp_forum_title($widget_query->post->ID);
?>
">
<?php
bbp_forum_title($widget_query->post->ID);
?>
</a>
<span class="topic-count"><?php
bbp_forum_topic_count($widget_query->post->ID);
?>
</span>
</li>
<?php
}
?>
</ul>
<?php
echo $after_widget;
// Reset the $post global
wp_reset_postdata();
}
}
开发者ID:CloouCom,项目名称:Supportte,代码行数:76,代码来源:forum-categories.php
示例8: post_type
/**
* Register the post type
*
* @since 1.0
*
* @return void
*/
public function post_type()
{
if (!class_exists('bbPress')) {
return;
}
$labels = array('name' => _x('Canned Replies', 'post type general name', 'bbp-canned-replies'), 'singular_name' => _x('Canned Reply', 'post type singular name', 'bbp-canned-replies'), 'add_new' => __('Add New', 'bbp-canned-replies'), 'add_new_item' => __('Add New Canned Reply', 'bbp-canned-replies'), 'edit_item' => __('Edit Canned Reply', 'bbp-canned-replies'), 'new_item' => __('New Canned Reply', 'bbp-canned-replies'), 'all_items' => __('Canned Replies', 'bbp-canned-replies'), 'view_item' => __('View Canned Reply', 'bbp-canned-replies'), 'search_items' => __('Search Canned Replies', 'bbp-canned-replies'), 'not_found' => __('No Canned Replies found', 'bbp-canned-replies'), 'not_found_in_trash' => __('No Canned Replies found in Trash', 'bbp-canned-replies'), 'parent_item_colon' => '', 'menu_name' => __('Canned Replies', 'bbp-canned-replies'));
$args = array('labels' => $labels, 'public' => false, 'show_ui' => true, 'show_in_menu' => 'edit.php?post_type=' . bbp_get_forum_post_type(), 'query_var' => false, 'rewrite' => false, 'capabilities' => bbp_get_forum_caps(), 'capability_type' => array('forum', 'forums'), 'supports' => array('editor', 'title'), 'can_export' => true);
register_post_type('bbp_canned_reply', $args);
}
开发者ID:donwea,项目名称:nhap.org,代码行数:16,代码来源:bbpress-canned-replies.php
示例9: widget
/**
* Displays the output, the forum list
*
* @since bbPress (r2653)
*
* @param mixed $args Arguments
* @param array $instance Instance
* @uses apply_filters() Calls 'bbp_forum_widget_title' with the title
* @uses get_option() To get the forums per page option
* @uses current_user_can() To check if the current user can read
* private() To resety name
* @uses bbp_has_forums() The main forum loop
* @uses bbp_forums() To check whether there are more forums available
* in the loop
* @uses bbp_the_forum() Loads up the current forum in the loop
* @uses bbp_forum_permalink() To display the forum permalink
* @uses bbp_forum_title() To display the forum title
*/
public function widget($args, $instance)
{
// Get widget settings
$settings = $this->parse_settings($instance);
// Typical WordPress filter
$settings['title'] = apply_filters('widget_title', $settings['title'], $instance, $this->id_base);
// bbPress filter
$settings['title'] = apply_filters('pg_widget_title', $settings['title'], $instance, $this->id_base);
// Note: private and hidden forums will be excluded via the
// bbp_pre_get_posts_exclude_forums filter and function.
$query_data = array('post_type' => bbp_get_forum_post_type(), 'post_parent' => $settings['parent_forum'], 'post_status' => bbp_get_public_status_id(), 'posts_per_page' => get_option('_bbp_forums_per_page', 50), 'orderby' => 'menu_order', 'order' => 'ASC');
//PRIVATE GROUPS Get an array of IDs which the current user has permissions to view
$allowed_posts = private_groups_get_permitted_post_ids(new WP_Query($query_data));
// The default forum query with allowed forum ids array added
$query_data['post__in'] = $allowed_posts;
$widget_query = new WP_Query($query_data);
// Bail if no posts
if (!$widget_query->have_posts()) {
return;
}
echo $args['before_widget'];
if (!empty($settings['title'])) {
echo $args['before_title'] . $settings['title'] . $args['after_title'];
}
?>
<ul>
<?php
while ($widget_query->have_posts()) {
$widget_query->the_post();
?>
<li><a class="bbp-forum-title" href="<?php
bbp_forum_permalink($widget_query->post->ID);
?>
" title="<?php
bbp_forum_title($widget_query->post->ID);
?>
"><?php
bbp_forum_title($widget_query->post->ID);
?>
</a></li>
<?php
}
?>
</ul>
<?php
echo $args['after_widget'];
// Reset the $post global
wp_reset_postdata();
}
开发者ID:USSLomaPrieta,项目名称:usslomaprieta.org,代码行数:73,代码来源:pg_forum_widgets.php
示例10: register_bb_custom_sidebar_mb
function register_bb_custom_sidebar_mb()
{
if (!function_exists('bbp_get_topic_post_type') || !function_exists('bbp_get_forum_post_type') || !function_exists('bbp_get_reply_post_type')) {
return;
}
$options = array('id' => 'circleflip-custom-sidebar-page', 'title' => 'Custom Sidebar', 'callback' => 'render_page_custom_sidebar_mb', 'context' => 'normal', 'priority' => 'high', 'callback_args' => NULL);
extract($options);
add_meta_box($id, $title, $callback, bbp_get_topic_post_type(), $context, $priority, $callback_args);
add_meta_box($id, $title, $callback, bbp_get_forum_post_type(), $context, $priority, $callback_args);
add_meta_box($id, $title, $callback, bbp_get_reply_post_type(), $context, $priority, $callback_args);
}
开发者ID:purgesoftwares,项目名称:purges,代码行数:11,代码来源:sidebars.php
示例11: setup_actions
/**
* Setup the Genesis actions.
*/
public function setup_actions()
{
// Register forum sidebar if needed
$this->register_genesis_forum_sidebar();
// Remove Genesis profile fields from front end
$this->remove_profile_fields();
// We hook into 'genesis_before' because it is the most reliable hook
// available to bbPress in the Genesis page load process.
add_action('genesis_before', array($this, 'genesis_post_actions'));
add_action('genesis_before', array($this, 'check_genesis_forum_sidebar'));
// Configure which Genesis layout to apply
add_filter('genesis_pre_get_option_site_layout', array($this, 'genesis_layout'));
// Add Layout and SEO options to Forums
add_post_type_support(bbp_get_forum_post_type(), array('genesis-layouts', 'genesis-seo', 'genesis-scripts', 'genesis-ss'));
}
开发者ID:ThemeMix,项目名称:thememix-pro-genesis,代码行数:18,代码来源:class-bbpress-compat.php
示例12: bbPressPostTypes
/**
* bbPress post types.
*
* @since 150821 Improving bbPress support.
*
* @return array All bbPress post types.
*/
public function bbPressPostTypes()
{
if (!$this->isBbPressActive()) {
return [];
}
if (!is_null($types =& $this->cacheKey('bbPressPostTypes'))) {
return $types;
// Already did this.
}
$types = [];
// Initialize.
$types[] = bbp_get_forum_post_type();
$types[] = bbp_get_topic_post_type();
$types[] = bbp_get_reply_post_type();
return $types;
}
开发者ID:arobbins,项目名称:sblog,代码行数:23,代码来源:BbPressUtils.php
示例13: SavePost
public static function SavePost($post_id, $post, $update)
{
if (wp_is_post_revision($post_id) || $post->post_status != 'publish' || $post->post_type != 'namaste_course') {
return;
}
$meta = get_post_meta($post_id, 'buddypress_id', true);
if (empty($meta)) {
$group_id = groups_create_group(array('creator_id' => get_current_user_id(), 'name' => $post->post_title, 'description' => 'Обсуждение курса ' . $post->post_title, 'enable_forum' => 1));
update_post_meta($post_id, 'buddypress_id', $group_id);
groups_edit_group_settings($group_id, 1, 'private', 'mods');
$forum_id = bbp_insert_forum($forum_data = array('post_status' => bbp_get_private_status_id(), 'post_type' => bbp_get_forum_post_type(), 'post_author' => bbp_get_current_user_id(), 'post_content' => 'Обсуждение курса ' . $post->post_title, 'post_title' => $post->post_title), $forum_meta = array());
bbp_update_group_forum_ids($group_id, (array) $forum_id);
bbp_update_forum_group_ids($forum_id, (array) $group_id);
}
bbp_add_user_forum_subscription(bbp_get_current_user_id(), $forum_id);
update_post_meta($forum_id, '_forum_course_id', $post_id);
}
开发者ID:Bnei-Baruch,项目名称:mailchimpNamasteIntegration,代码行数:17,代码来源:CreateGroupAndForumForCourse.php
示例14: test_bbp_get_forum_post_type
/**
* @covers ::bbp_forum_post_type
* @covers ::bbp_get_forum_post_type
*/
public function test_bbp_get_forum_post_type()
{
$f = $this->factory->forum->create();
$fobj = get_post_type_object('forum');
// WordPress 4.6 introduced `WP_Post_Type` class
if (bbp_get_major_wp_version() < 4.6) {
$this->assertInstanceOf('stdClass', $fobj);
} else {
$this->assertInstanceOf('WP_Post_Type', $fobj);
}
$this->assertEquals('forum', $fobj->name);
// Test some defaults
$this->assertTrue(is_post_type_hierarchical('forum'));
$forum_type = bbp_forum_post_type($f);
$this->expectOutputString('forum', $forum_type);
$forum_type = bbp_get_forum_post_type($f);
$this->assertSame('forum', $forum_type);
}
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:22,代码来源:post_type.php
示例15: bbp_get_topic_write_url
function bbp_get_topic_write_url($forum_id = 0)
{
global $wp_rewrite;
$bbp = bbpress();
$forum = bbp_get_forum(bbp_get_forum_id($forum_id));
if (empty($forum)) {
return;
}
// Remove view=all link from edit
$forum_link = bbp_get_forum_permalink($forum_id);
// Pretty permalinks
if ($wp_rewrite->using_permalinks()) {
$url = trailingslashit($forum_link) . $bbp->write_id;
$url = trailingslashit($url);
// Unpretty permalinks
} else {
$url = add_query_arg(array(bbp_get_forum_post_type() => $forum->post_name, $bbp->write_id => '1'), $forum_link);
}
return apply_filters('bbp_get_topic_write_url', $url, $forum_id);
}
开发者ID:082net,项目名称:bbpresskr,代码行数:20,代码来源:functions.php
示例16: nav_menu_css_class
static function nav_menu_css_class($classes, $item, $args, $depth)
{
if ($item->object == bbp_get_forum_post_type() && is_bbpress()) {
if (bbp_is_topic_edit() || bbp_is_single_topic()) {
$forum_id = bbp_get_topic_forum_id();
if ($forum_id == $item->object_id) {
$classes[] = 'current-menu-parent';
$classes[] = 'current-' . bbp_get_topic_post_type() . '-parent';
} elseif ($ancestors = self::forum_ancestors($forum_id, array())) {
if (in_array($item->object_id, $ancestors)) {
$classes[] = 'current-menu-ancestor';
$classes[] = 'current-' . bbp_get_topic_post_type() . '-ancestor';
}
}
} elseif (bbp_is_reply_edit() || bbp_is_single_reply()) {
$forum_id = bbp_get_reply_forum_id();
}
}
return $classes;
}
开发者ID:082net,项目名称:bbpresskr,代码行数:20,代码来源:nav-menu.php
示例17: private_groups_get_forum_id_from_post_id
function private_groups_get_forum_id_from_post_id($post_id, $post_type)
{
$forum_id = 0;
// Check post type
switch ($post_type) {
// Forum
case bbp_get_forum_post_type():
$forum_id = bbp_get_forum_id($post_id);
break;
// Topic
// Topic
case bbp_get_topic_post_type():
$forum_id = bbp_get_topic_forum_id($post_id);
break;
// Reply
// Reply
case bbp_get_reply_post_type():
$forum_id = bbp_get_reply_forum_id($post_id);
break;
}
return $forum_id;
}
开发者ID:USSLomaPrieta,项目名称:usslomaprieta.org,代码行数:22,代码来源:functions.php
示例18: ajax_query_attachments_args
static function ajax_query_attachments_args($query)
{
$forum_id = 0;
$post_id = isset($_POST['post_id']) ? (int) $_POST['post_id'] : 0;
if ($post_id) {
$post_type = get_post_type($post_id);
if ($post_type == bbp_get_topic_post_type()) {
$forum_id = (int) bbp_get_topic_forum_id($post_id);
} elseif ($post_type == bbp_get_reply_post_type()) {
$forum_id = (int) bbp_get_reply_forum_id($post_id);
} elseif ($post_type == bbp_get_forum_post_type()) {
$forum_id = $post_id;
}
}
if ($forum_id) {
// TODO: post_id 값이 전달되지 않을 때, 포럼을 찾는 방법을 알아봐야함.
add_filter('bbp_get_forum_id', create_function('$a', 'return ' . $forum_id . ';'));
if (!current_user_can('edit_others_topics')) {
$query['author'] = get_current_user_id();
}
}
return $query;
}
开发者ID:082net,项目名称:bbpresskr,代码行数:23,代码来源:attachments.php
示例19: 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);
}
开发者ID:dnaleor,项目名称:Tehnik-bbPress-Permissions,代码行数:27,代码来源:tehnik_bpp_forum.php
示例20: stachestack_bbp_get_dropdown
/**
* Output a select box allowing to pick which forum/topic a new
* topic/reply belongs in.
*
* @since bbPress (r2746)
*
* @param mixed $args The function supports these args:
* - post_type: Post type, defaults to bbp_get_forum_post_type() (bbp_forum)
* - selected: Selected ID, to not have any value as selected, pass
* anything smaller than 0 (due to the nature of select
* box, the first value would of course be selected -
* though you can have that as none (pass 'show_none' arg))
* - orderby: Defaults to 'menu_order title'
* - post_parent: Post parent. Defaults to 0
* - post_status: Which all post_statuses to find in? Can be an array
* or CSV of publish, category, closed, private, spam,
* trash (based on post type) - if not set, these are
* automatically determined based on the post_type
* - posts_per_page: Retrieve all forums/topics. Defaults to -1 to get
* all posts
* - walker: Which walker to use? Defaults to
* {@link BBP_Walker_Dropdown}
* - select_id: ID of the select box. Defaults to 'bbp_forum_id'
* - tab: Tabindex value. False or integer
* - options_only: Show only <options>? No <select>?
* - show_none: False or something like __( '(No Forum)', 'bbpress' ),
* will have value=""
* - none_found: False or something like
* __( 'No forums to post to!', 'bbpress' )
* - disable_categories: Disable forum categories and closed forums?
* Defaults to true. Only for forums and when
* the category option is displayed.
* @uses BBP_Walker_Dropdown() As the default walker to generate the
* dropdown
* @uses current_user_can() To check if the current user can read
* private forums
* @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 walk_page_dropdown_tree() To generate the dropdown using the
* walker
* @uses apply_filters() Calls 'bbp_get_dropdown' with the dropdown
* and args
* @return string The dropdown
*/
function stachestack_bbp_get_dropdown($args = '')
{
/** Arguments *********************************************************/
// Parse arguments against default values
$r = bbp_parse_args($args, array('post_type' => bbp_get_forum_post_type(), 'post_parent' => null, 'post_status' => null, 'selected' => 0, 'exclude' => array(), 'numberposts' => -1, 'orderby' => 'menu_order title', 'order' => 'ASC', 'walker' => '', 'select_id' => 'bbp_forum_id', 'tab' => bbp_get_tab_index(), 'options_only' => false, 'show_none' => false, 'none_found' => false, 'disable_categories' => true, 'disabled' => ''), 'get_dropdown');
if (empty($r['walker'])) {
$r['walker'] = new BBP_Walker_Dropdown();
$r['walker']->tree_type = $r['post_type'];
}
// Force 0
if (is_numeric($r['selected']) && $r['selected'] < 0) {
$r['selected'] = 0;
}
// Force array
if (!empty($r['exclude']) && !is_array($r['exclude'])) {
$r['exclude'] = explode(',', $r['exclude']);
}
/** Setup variables ***************************************************/
$retval = '';
$posts = get_posts(array('post_type' => $r['post_type'], 'post_status' => $r['post_status'], 'exclude' => $r['exclude'], 'post_parent' => $r['post_parent'], 'numberposts' => $r['numberposts'], 'orderby' => $r['orderby'], 'order' => $r['order'], 'walker' => $r['walker'], 'disable_categories' => $r['disable_categories']));
/** Drop Down *********************************************************/
// Items found
if (!empty($posts)) {
// Build the opening tag for the select element
if (empty($r['options_only'])) {
// Should this select appear disabled?
$disabled = disabled(isset(bbpress()->options[$r['disabled']]), true, false);
// Setup the tab index attribute
$tab = !empty($r['tab']) ? ' tabindex="' . intval($r['tab']) . '"' : '';
// Build the opening tag
$retval .= '<select class="form-control" name="' . esc_attr($r['select_id']) . '" id="' . esc_attr($r['select_id']) . '"' . $disabled . $tab . '>' . "\n";
}
// Get the options
$retval .= !empty($r['show_none']) ? "\t<option value=\"\" class=\"level-0\">" . esc_html($r['show_none']) . '</option>' : '';
$retval .= walk_page_dropdown_tree($posts, 0, $r);
// Build the closing tag for the select element
if (empty($r['options_only'])) {
$retval .= '</select>';
}
// No items found - Display feedback if no custom message was passed
} elseif (empty($r['none_found'])) {
// Switch the response based on post type
switch ($r['post_type']) {
// Topics
case bbp_get_topic_post_type():
$retval = __('No topics available', 'bbpress');
break;
// Forums
// Forums
case bbp_get_forum_post_type():
$retval = __('No forums available', 'bbpress');
break;
// Any other
// Any other
default:
$retval = __('None available', 'bbpress');
//.........这里部分代码省略.........
开发者ID:BeardandFedora,项目名称:StacheStack,代码行数:101,代码来源:bbpress.php
注:本文中的bbp_get_forum_post_type函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论