本文整理汇总了PHP中bbp_get_topic_post_type函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_get_topic_post_type函数的具体用法?PHP bbp_get_topic_post_type怎么用?PHP bbp_get_topic_post_type使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bbp_get_topic_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: bbp_has_replies
/**
* The main reply loop. WordPress makes this easy for us
*
* @since bbPress (r2553)
*
* @param mixed $args All the arguments supported by {@link WP_Query}
* @uses bbp_is_user_bozo() To add the bozo post status
* @uses bbp_show_lead_topic() Are we showing the topic as a lead?
* @uses bbp_get_topic_id() To get the topic id
* @uses bbp_get_reply_post_type() To get the reply post type
* @uses bbp_get_topic_post_type() To get the topic post type
* @uses bbp_is_query_name() To check if we are getting replies for a widget
* @uses get_option() To get the replies per page option
* @uses bbp_get_paged() To get the current page value
* @uses current_user_can() To check if the current user is capable of editing
* others' replies
* @uses WP_Query To make query and get the replies
* @uses WP_Rewrite::using_permalinks() To check if the blog is using permalinks
* @uses get_permalink() To get the permalink
* @uses add_query_arg() To add custom args to the url
* @uses apply_filters() Calls 'bbp_replies_pagination' with the pagination args
* @uses paginate_links() To paginate the links
* @uses apply_filters() Calls 'bbp_has_replies' with
* bbPres::reply_query::have_posts()
* and bbPres::reply_query
* @return object Multidimensional array of reply information
*/
function bbp_has_replies($args = '')
{
global $wp_rewrite;
// What are the default allowed statuses (based on user caps)
if (bbp_get_view_all('edit_others_replies')) {
$post_statuses = array(bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id());
} else {
$post_statuses = array(bbp_get_public_status_id(), bbp_get_closed_status_id());
}
// Add the bozo status if user is a bozo
if (bbp_is_user_bozo()) {
$post_statuses[] = bbp_get_bozo_status_id();
}
$default_reply_search = !empty($_REQUEST['rs']) ? $_REQUEST['rs'] : false;
$default_post_parent = bbp_is_single_topic() ? bbp_get_topic_id() : 'any';
$default_post_type = bbp_is_single_topic() && bbp_show_lead_topic() ? bbp_get_reply_post_type() : array(bbp_get_topic_post_type(), bbp_get_reply_post_type());
$default_post_status = join(',', $post_statuses);
// Default query args
$default = array('post_type' => $default_post_type, 'post_parent' => $default_post_parent, 'post_status' => $default_post_status, 'posts_per_page' => bbp_get_replies_per_page(), 'paged' => bbp_get_paged(), 'orderby' => 'date', 'order' => 'ASC', 's' => $default_reply_search);
// Set up topic variables
$bbp_r = bbp_parse_args($args, $default, 'has_replies');
// Extract the query variables
extract($bbp_r);
// Get bbPress
$bbp = bbpress();
// Call the query
$bbp->reply_query = new WP_Query($bbp_r);
// Add pagination values to query object
$bbp->reply_query->posts_per_page = $posts_per_page;
$bbp->reply_query->paged = $paged;
// Only add pagination if query returned results
if ((int) $bbp->reply_query->found_posts && (int) $bbp->reply_query->posts_per_page) {
// If pretty permalinks are enabled, make our pagination pretty
if ($wp_rewrite->using_permalinks()) {
// Page or single
if (is_page() || is_single()) {
$base = get_permalink();
// Topic
} else {
$base = get_permalink(bbp_get_topic_id());
}
$base = trailingslashit($base) . user_trailingslashit($wp_rewrite->pagination_base . '/%#%/');
// Unpretty permalinks
} else {
$base = add_query_arg('paged', '%#%');
}
// Pagination settings with filter
$bbp_replies_pagination = apply_filters('bbp_replies_pagination', array('base' => $base, 'format' => '', 'total' => ceil((int) $bbp->reply_query->found_posts / (int) $posts_per_page), 'current' => (int) $bbp->reply_query->paged, 'prev_text' => '←', 'next_text' => '→', 'mid_size' => 1, 'add_args' => bbp_get_view_all() ? array('view' => 'all') : false));
// Add pagination to query object
$bbp->reply_query->pagination_links = paginate_links($bbp_replies_pagination);
// Remove first page from pagination
if ($wp_rewrite->using_permalinks()) {
$bbp->reply_query->pagination_links = str_replace($wp_rewrite->pagination_base . '/1/', '', $bbp->reply_query->pagination_links);
} else {
$bbp->reply_query->pagination_links = str_replace('&paged=1', '', $bbp->reply_query->pagination_links);
}
}
// Return object
return apply_filters('bbp_has_replies', $bbp->reply_query->have_posts(), $bbp->reply_query);
}
示例4: protected_title_format
static function protected_title_format($format, $post)
{
if (in_array(get_post_type($post), array(bbp_get_topic_post_type(), bbp_get_reply_post_type()))) {
return '%s';
}
// return __( '<span class="protected_title_format">Protected:</span> %s', 'bbpresskr' );
return $format;
}
示例5: hybrid_meta_box_post_remove_seo
/**
* Remove the meta box from some post types.
*
* @since 1.3.0
* @param string $post_type The post type of the current post being edited.
* @param object $post The current post being edited.
* @return void
*/
function hybrid_meta_box_post_remove_seo($post_type, $post)
{
/* Removes post stylesheets support of the bbPress 'topic' post type. */
if (function_exists('bbp_get_topic_post_type') && bbp_get_topic_post_type() == $post_type) {
remove_meta_box('hybrid-core-post-seo', bbp_get_topic_post_type(), 'normal');
} elseif (function_exists('bbp_get_reply_post_type') && bbp_get_reply_post_type() == $post_type) {
remove_meta_box('hybrid-core-post-seo', bbp_get_reply_post_type(), 'normal');
}
}
示例6: 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);
}
示例7: widget
function widget($args, $instance)
{
extract($args, EXTR_SKIP);
$title = !empty($instance['title']) ? $instance['title'] : __('Recent Topics');
$title = apply_filters('widget_title', $title, $instance, $this->id_base);
$number = !empty($instance['number']) ? absint($instance['number']) : 5;
$orderby = !empty($instance['number']) ? strip_tags($instance['order_by']) : 'newness';
if ($orderby == 'newness') {
$cb_meta_key = $cb_order_by = NULL;
} elseif ($orderby == 'popular') {
$cb_meta_key = '_bbp_reply_count';
$cb_order_by = 'meta_value';
} elseif ($orderby == 'freshness') {
$cb_meta_key = '_bbp_last_active_time';
$cb_order_by = 'meta_value';
}
if (!$number) {
$number = 5;
}
$cb_qry = new WP_Query(array('post_type' => bbp_get_topic_post_type(), 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'order' => 'DESC', 'posts_per_page' => $number, 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'meta_key' => $cb_meta_key, 'orderby' => $cb_order_by));
echo $before_widget;
echo $before_title . $title . $after_title;
?>
<ul class="cb-bbp-recent-topics">
<?php
while ($cb_qry->have_posts()) {
$cb_qry->the_post();
?>
<li>
<?php
$cb_reply_id = bbp_get_reply_id($cb_qry->post->ID);
$cb_reply_url = '<a class="bbp-reply-topic-title" href="' . esc_url(bbp_get_reply_url($cb_reply_id)) . '" title="' . esc_attr(bbp_get_reply_excerpt($cb_reply_id, 50)) . '">' . bbp_get_reply_topic_title($cb_reply_id) . '</a>';
$cb_number_replies = bbp_get_topic_reply_count($cb_reply_id);
$cb_author_avatar = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'avatar', 'size' => 60));
$cb_author_name = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'name'));
echo $cb_author_avatar . '<div class="cb-bbp-meta">' . $cb_reply_url . '<div class="cb-bbp-byline">' . __('Started by', 'cubell') . ' ' . $cb_author_name . ' <i class="icon-long-arrow-right"></i> ' . $cb_number_replies . ' replies</div></div>';
?>
</li>
<?php
}
?>
</ul>
<?php
echo $after_widget;
// Reset the $post global
wp_reset_postdata();
}
示例8: hybrid_meta_box_post_remove_template
/**
* Remove the meta box from some post types.
*
* @since 1.3.0
* @access public
* @param string $post_type The post type of the current post being edited.
* @param object $post The current post being edited.
* @return void
*/
function hybrid_meta_box_post_remove_template($post_type, $post)
{
/* Removes meta box from pages since this is a built-in WordPress feature. */
if ('page' == $post_type) {
remove_meta_box('hybrid-core-post-template', 'page', 'side');
} elseif (function_exists('bbp_get_topic_post_type') && bbp_get_topic_post_type() == $post_type) {
remove_meta_box('hybrid-core-post-template', bbp_get_topic_post_type(), 'side');
} elseif (function_exists('bbp_get_reply_post_type') && bbp_get_reply_post_type() == $post_type) {
remove_meta_box('hybrid-core-post-template', bbp_get_reply_post_type(), 'side');
}
}
示例9: post_stylesheets_remove_post_type_support
/**
* Removes post stylesheets support for certain post types created by plugins.
*
* @since 1.0
* @access public
* @return void
*/
function post_stylesheets_remove_post_type_support()
{
/* Removes post stylesheets support of the bbPress 'topic' post type. */
if (function_exists('bbp_get_topic_post_type')) {
remove_post_type_support(bbp_get_topic_post_type(), 'post-stylesheets');
}
/* Removes post stylesheets support of the bbPress 'reply' post type. */
if (function_exists('bbp_get_reply_post_type')) {
remove_post_type_support(bbp_get_reply_post_type(), 'post-stylesheets');
}
}
示例10: comments_template
public static function comments_template($file)
{
global $post;
if (get_post_type($post->ID) != bbp_get_topic_post_type()) {
return $file;
}
$open = comments_open($post->ID);
if (!$open) {
return BBPKR_PATH . '/templates/blank-comments.php';
}
return $file;
}
示例11: test_bbp_topic_post_type
/**
* @covers ::bbp_topic_post_type
* @covers ::bbp_get_topic_post_type
*/
public function test_bbp_topic_post_type()
{
$t = $this->factory->topic->create();
$tobj = get_post_type_object('topic');
$this->assertInstanceOf('stdClass', $tobj);
$this->assertEquals('topic', $tobj->name);
// Test some defaults
$this->assertFalse(is_post_type_hierarchical('topic'));
$topic_type = bbp_topic_post_type($t);
$this->expectOutputString('topic', $topic_type);
$topic_type = bbp_get_topic_post_type($t);
$this->assertSame('topic', $topic_type);
}
示例12: bbpvotes_buddypress_voted_activity
function bbpvotes_buddypress_voted_activity($post_id, $user_id, $vote)
{
//check vote value
if (is_bool($vote) === false) {
return new WP_Error('vote_is_not_bool', __('Vote is not a boolean', 'bbpvotes'));
}
$voteplus = $vote === true;
$voteminus = $vote === false;
$post = get_post($post_id);
$user_link = bbp_get_user_profile_link($user_id);
//build item link
if ($post->post_type == bbp_get_topic_post_type()) {
$topic_id = $post->ID;
$post_permalink = get_permalink($post->ID);
} elseif ($post->post_type == bbp_get_reply_post_type()) {
$topic_id = bbp_get_reply_topic_id($post->ID);
$post_permalink = bbp_get_reply_url($post->ID);
}
//topic infos
$topic = get_post($topic_id);
$topic_author_link = bbp_get_user_profile_link($topic->post_author);
$topic_title = $topic->post_title;
$post_link = '<a href="' . $post_permalink . '">' . $topic_title . '</a>';
if ($voteplus) {
$type = 'bbpvotes_voted_up';
if ($post->post_type == bbp_get_topic_post_type()) {
$action = sprintf(esc_html__('%1$s voted up to the topic %2$s by %3$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
} elseif ($post->post_type == bbp_get_reply_post_type()) {
$action = sprintf(esc_html__('%1$s voted up to a reply by %3$s in the topic %2$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
}
} else {
$type = 'bbpvotes_voted_down';
if ($post->post_type == bbp_get_topic_post_type()) {
$action = sprintf(esc_html__('%1$s voted down to the topic %2$s by %3$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
} elseif ($post->post_type == bbp_get_reply_post_type()) {
$action = sprintf(esc_html__('%1$s voted down to a reply by %3$s in the topic %2$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
}
}
$args = array('action' => $action, 'component' => 'bbpress', 'type' => $type, 'item_id' => $topic->ID);
if ($post->post_type == bbp_get_reply_post_type()) {
$args['secondary_item_id'] = $post->ID;
}
/*
if ($is_update){
$previous_activity_id =
$args['id'] = $previous_activity_id;
}
*/
bp_activity_add($args);
}
示例13: setup_actions
static function setup_actions()
{
if (!is_admin()) {
add_action('bbp_theme_after_topic_form_content', array(__CLASS__, 'print_meta_fields'));
add_action('bbpkr_' . bbp_get_topic_post_type() . '_list_custom_column', array(__CLASS__, 'meta_column'), 10, 2);
add_action('bbpkr_' . bbp_get_topic_post_type() . '_list_columns', array(__CLASS__, 'meta_columns'), 10, 2);
} elseif (!defined('DOING_AJAX') || !DOING_AJAX) {
// bbp_new_topic_post_extras, bbp_edit_topic_post_extras
// add_action( 'bbp_new_topic_post_extras', array(__CLASS__, 'update_bbpmeta') );
// add_action( 'bbp_edit_topic_post_extras', array(__CLASS__, 'update_bbpmeta') );
add_action('save_post_' . bbp_get_topic_post_type(), array(__CLASS__, 'update_bbpmeta'));
add_action('add_meta_boxes_' . bbp_get_topic_post_type(), array(__CLASS__, 'add_meta_box'));
}
}
示例14: gpbbp_new_post
function gpbbp_new_post($post_id, $post, $update)
{
$TOPIC_POST_TYPE = bbp_get_topic_post_type();
$REPLY_POST_TYPE = bbp_get_reply_post_type();
$post_type = get_post_type($post);
$forum_id = NULL;
if ($post_type == $TOPIC_POST_TYPE) {
$forum_id = wp_get_post_parent_id($post_id);
gpbbp_apply_capabilities_from_forum($post_id, $forum_id);
}
if ($post_type == $REPLY_POST_TYPE) {
$forum_id = bbp_get_forum_id();
gpbbp_apply_capabilities_from_forum($post_id, $forum_id);
}
gpbbp_new_post_notification($post_id, $post, $post_type);
}
示例15: 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;
}