本文整理汇总了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函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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());
}
}
示例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;
}
示例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;
}
}
}
}
示例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;
}
示例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();
}
}
示例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);
}
示例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();
}
示例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);
}
示例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'));
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}