本文整理汇总了PHP中bbp_get_closed_status_id函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_get_closed_status_id函数的具体用法?PHP bbp_get_closed_status_id怎么用?PHP bbp_get_closed_status_id使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bbp_get_closed_status_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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();
}
示例3: widget
function widget($args, $instance)
{
extract($args, EXTR_SKIP);
$title = !empty($instance['title']) ? $instance['title'] : __('Recent Comments');
$title = apply_filters('widget_title', $title, $instance, $this->id_base);
$number = !empty($instance['number']) ? absint($instance['number']) : 5;
if (!$number) {
$number = 5;
}
$cb_qry = new WP_Query(array('post_type' => bbp_get_reply_post_type(), 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'posts_per_page' => $number, 'ignore_sticky_posts' => true, 'no_found_rows' => true));
echo $before_widget;
echo $before_title . $title . $after_title;
?>
<ul class="cb-bbp-recent-replies">
<?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_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_author_name . ' <i class="icon-long-arrow-right"></i> ' . $cb_reply_url . '<div class="cb-bbp-recent-replies-time">' . bbp_get_time_since(get_the_time('U')) . '</div></div>';
?>
</li>
<?php
}
?>
</ul>
<?php
echo $after_widget;
// Reset the $post global
wp_reset_postdata();
}
示例4: row_actions
/**
* Topic Row actions
*
* Remove the quick-edit action link under the topic title and add the
* content and close/stick/spam links
*
* @since 2.0.0 bbPress (r2485)
*
* @param array $actions Actions
* @param array $topic Topic object
* @uses bbp_get_topic_post_type() To get the topic post type
* @uses bbp_topic_content() To output topic content
* @uses bbp_get_topic_permalink() To get the topic link
* @uses bbp_get_topic_title() To get the topic title
* @uses current_user_can() To check if the current user can edit or
* delete the topic
* @uses bbp_is_topic_open() To check if the topic is open
* @uses bbp_is_topic_spam() To check if the topic is marked as spam
* @uses bbp_is_topic_sticky() To check if the topic is a sticky or a
* super sticky
* @uses get_post_type_object() To get the topic post type object
* @uses add_query_arg() To add custom args to the url
* @uses remove_query_arg() To remove custom args from the url
* @uses wp_nonce_url() To nonce the url
* @uses get_delete_post_link() To get the delete post link of the topic
* @return array $actions Actions
*/
public function row_actions($actions, $topic)
{
if ($this->bail()) {
return $actions;
}
unset($actions['inline hide-if-no-js']);
// Show view link if it's not set, the topic is trashed and the user can view trashed topics
if (empty($actions['view']) && bbp_get_trash_status_id() === $topic->post_status && current_user_can('view_trash')) {
$actions['view'] = '<a href="' . esc_url(bbp_get_topic_permalink($topic->ID)) . '" title="' . esc_attr(sprintf(__('View “%s”', 'bbpress'), bbp_get_topic_title($topic->ID))) . '" rel="permalink">' . esc_html__('View', 'bbpress') . '</a>';
}
// Only show the actions if the user is capable of viewing them :)
if (current_user_can('moderate', $topic->ID)) {
// Pending
// Show the 'approve' and 'view' link on pending posts only and 'unapprove' on published posts only
$approve_uri = wp_nonce_url(add_query_arg(array('topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_approve'), remove_query_arg(array('bbp_topic_toggle_notice', 'topic_id', 'failed', 'super'))), 'approve-topic_' . $topic->ID);
if (bbp_is_topic_published($topic->ID)) {
$actions['unapproved'] = '<a href="' . esc_url($approve_uri) . '" title="' . esc_attr__('Unapprove this topic', 'bbpress') . '">' . _x('Unapprove', 'Unapprove Topic', 'bbpress') . '</a>';
} elseif (!bbp_is_topic_private($topic->ID)) {
$actions['approved'] = '<a href="' . esc_url($approve_uri) . '" title="' . esc_attr__('Approve this topic', 'bbpress') . '">' . _x('Approve', 'Approve Topic', 'bbpress') . '</a>';
$actions['view'] = '<a href="' . esc_url(bbp_get_topic_permalink($topic->ID)) . '" title="' . esc_attr(sprintf(__('View “%s”', 'bbpress'), bbp_get_topic_title($topic->ID))) . '" rel="permalink">' . esc_html__('View', 'bbpress') . '</a>';
}
// Close
// Show the 'close' and 'open' link on published and closed posts only
if (in_array($topic->post_status, array(bbp_get_public_status_id(), bbp_get_closed_status_id()))) {
$close_uri = wp_nonce_url(add_query_arg(array('topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_close'), remove_query_arg(array('bbp_topic_toggle_notice', 'topic_id', 'failed', 'super'))), 'close-topic_' . $topic->ID);
if (bbp_is_topic_open($topic->ID)) {
$actions['closed'] = '<a href="' . esc_url($close_uri) . '" title="' . esc_attr__('Close this topic', 'bbpress') . '">' . _x('Close', 'Close a Topic', 'bbpress') . '</a>';
} else {
$actions['closed'] = '<a href="' . esc_url($close_uri) . '" title="' . esc_attr__('Open this topic', 'bbpress') . '">' . _x('Open', 'Open a Topic', 'bbpress') . '</a>';
}
}
// Sticky
// Dont show sticky if topic links is spam, trash or pending
if (!bbp_is_topic_spam($topic->ID) && !bbp_is_topic_trash($topic->ID) && !bbp_is_topic_pending($topic->ID)) {
$stick_uri = wp_nonce_url(add_query_arg(array('topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick'), remove_query_arg(array('bbp_topic_toggle_notice', 'topic_id', 'failed', 'super'))), 'stick-topic_' . $topic->ID);
if (bbp_is_topic_sticky($topic->ID)) {
$actions['stick'] = '<a href="' . esc_url($stick_uri) . '" title="' . esc_attr__('Unstick this topic', 'bbpress') . '">' . esc_html__('Unstick', 'bbpress') . '</a>';
} else {
$super_uri = wp_nonce_url(add_query_arg(array('topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick', 'super' => '1'), remove_query_arg(array('bbp_topic_toggle_notice', 'topic_id', 'failed', 'super'))), 'stick-topic_' . $topic->ID);
$actions['stick'] = '<a href="' . esc_url($stick_uri) . '" title="' . esc_attr__('Stick this topic to its forum', 'bbpress') . '">' . esc_html__('Stick', 'bbpress') . '</a> <a href="' . esc_url($super_uri) . '" title="' . esc_attr__('Stick this topic to front', 'bbpress') . '">' . esc_html__('(to front)', 'bbpress') . '</a>';
}
}
// Spam
$spam_uri = wp_nonce_url(add_query_arg(array('topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_spam'), remove_query_arg(array('bbp_topic_toggle_notice', 'topic_id', 'failed', 'super'))), 'spam-topic_' . $topic->ID);
if (bbp_is_topic_spam($topic->ID)) {
$actions['spam'] = '<a href="' . esc_url($spam_uri) . '" title="' . esc_attr__('Mark the topic as not spam', 'bbpress') . '">' . esc_html__('Not spam', 'bbpress') . '</a>';
} else {
$actions['spam'] = '<a href="' . esc_url($spam_uri) . '" title="' . esc_attr__('Mark this topic as spam', 'bbpress') . '">' . esc_html__('Spam', 'bbpress') . '</a>';
}
}
// Do not show trash links for spam topics, or spam links for trashed topics
if (current_user_can('delete_topic', $topic->ID)) {
if (bbp_get_trash_status_id() === $topic->post_status) {
$post_type_object = get_post_type_object(bbp_get_topic_post_type());
$actions['untrash'] = "<a title='" . esc_attr__('Restore this item from the Trash', 'bbpress') . "' href='" . wp_nonce_url(add_query_arg(array('_wp_http_referer' => add_query_arg(array('post_type' => bbp_get_topic_post_type()), admin_url('edit.php'))), admin_url(sprintf($post_type_object->_edit_link . '&action=untrash', $topic->ID))), 'untrash-' . $topic->post_type . '_' . $topic->ID) . "'>" . esc_html__('Restore', 'bbpress') . "</a>";
} elseif (EMPTY_TRASH_DAYS) {
$actions['trash'] = "<a class='submitdelete' title='" . esc_attr__('Move this item to the Trash', 'bbpress') . "' href='" . esc_url(add_query_arg(array('_wp_http_referer' => add_query_arg(array('post_type' => bbp_get_topic_post_type()), admin_url('edit.php'))), get_delete_post_link($topic->ID))) . "'>" . esc_html__('Trash', 'bbpress') . "</a>";
}
if (bbp_get_trash_status_id() === $topic->post_status || !EMPTY_TRASH_DAYS) {
$actions['delete'] = "<a class='submitdelete' title='" . esc_attr__('Delete this item permanently', 'bbpress') . "' href='" . esc_url(add_query_arg(array('_wp_http_referer' => add_query_arg(array('post_type' => bbp_get_topic_post_type()), admin_url('edit.php'))), get_delete_post_link($topic->ID, '', true))) . "'>" . esc_html__('Delete Permanently', 'bbpress') . "</a>";
} elseif (bbp_get_spam_status_id() === $topic->post_status) {
unset($actions['trash']);
}
}
return $actions;
}
示例5: bbp_is_topic_closed
/**
* Is the topic closed to new replies?
*
* @since 2.0.0 bbPress (r2746)
*
* @param int $topic_id Optional. Topic id
* @uses bbp_get_topic_status() To get the topic status
* @uses apply_filters() Calls 'bbp_is_topic_closed' with the topic id
*
* @return bool True if closed, false if not.
*/
function bbp_is_topic_closed($topic_id = 0)
{
$topic_id = bbp_get_topic_id($topic_id);
$status = bbp_get_closed_status_id();
$topic_status = bbp_get_topic_status($topic_id) === $status;
return (bool) apply_filters('bbp_is_topic_closed', (bool) $topic_status, $topic_id);
}
示例6: bbp_trash_forum_topics
/**
* Trash all topics inside a forum
*
* @since bbPress (r3668)
*
* @param int $forum_id
* @uses bbp_get_forum_id() To validate the forum ID
* @uses bbp_is_forum() To make sure it's a forum
* @uses bbp_get_public_status_id() To return public post status
* @uses bbp_get_closed_status_id() To return closed post status
* @uses bbp_get_pending_status_id() To return pending post status
* @uses bbp_get_topic_post_type() To get the topic post type
* @uses wp_trash_post() To trash the post
* @uses update_post_meta() To update the forum meta of trashed topics
* @return If forum is not valid
*/
function bbp_trash_forum_topics($forum_id = 0)
{
// Validate forum ID
$forum_id = bbp_get_forum_id($forum_id);
if (empty($forum_id)) {
return;
}
// Allowed post statuses to pre-trash
$post_stati = implode(',', array(bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_pending_status_id()));
// Forum is being trashed, so its topics and replies are trashed too
$topics = new WP_Query(array('suppress_filters' => true, 'post_type' => bbp_get_topic_post_type(), 'post_parent' => $forum_id, 'post_status' => $post_stati, 'posts_per_page' => -1, 'nopaging' => true, 'fields' => 'id=>parent'));
// Loop through and trash child topics. Topic replies will get trashed by
// the bbp_trash_topic() action.
if (!empty($topics->posts)) {
// Prevent debug notices
$pre_trashed_topics = array();
// Loop through topics, trash them, and add them to array
foreach ($topics->posts as $topic) {
wp_trash_post($topic->ID, true);
$pre_trashed_topics[] = $topic->ID;
}
// Set a post_meta entry of the topics that were trashed by this action.
// This is so we can possibly untrash them, without untrashing topics
// that were purposefully trashed before.
update_post_meta($forum_id, '_bbp_pre_trashed_topics', $pre_trashed_topics);
// Reset the $post global
wp_reset_postdata();
}
// Cleanup
unset($topics);
}
示例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_request_feed_trap
/**
* This function is hooked into the WordPress 'request' action and is
* responsible for sniffing out the query vars and serving up RSS2 feeds if
* the stars align and the user has requested a feed of any bbPress type.
*
* @since 2.0.0 bbPress (r3171)
*
* @param array $query_vars
* @return array
*/
function bbp_request_feed_trap($query_vars = array())
{
// Looking at a feed
if (isset($query_vars['feed'])) {
// Forum/Topic/Reply Feed
if (isset($query_vars['post_type'])) {
// Matched post type
$post_type = false;
// Post types to check
$post_types = array(bbp_get_forum_post_type(), bbp_get_topic_post_type(), bbp_get_reply_post_type());
// Cast query vars as array outside of foreach loop
$qv_array = (array) $query_vars['post_type'];
// Check if this query is for a bbPress post type
foreach ($post_types as $bbp_pt) {
if (in_array($bbp_pt, $qv_array, true)) {
$post_type = $bbp_pt;
break;
}
}
// Looking at a bbPress post type
if (!empty($post_type)) {
// Supported select query vars
$select_query_vars = array('p' => false, 'name' => false, $post_type => false);
// Setup matched variables to select
foreach ($query_vars as $key => $value) {
if (isset($select_query_vars[$key])) {
$select_query_vars[$key] = $value;
}
}
// Remove any empties
$select_query_vars = array_filter($select_query_vars);
// What bbPress post type are we looking for feeds on?
switch ($post_type) {
// Forum
case bbp_get_forum_post_type():
// Define local variable(s)
$meta_query = array();
// Single forum
if (!empty($select_query_vars)) {
// Load up our own query
query_posts(array_merge(array('post_type' => bbp_get_forum_post_type(), 'feed' => true), $select_query_vars));
// Restrict to specific forum ID
$meta_query = array(array('key' => '_bbp_forum_id', 'value' => bbp_get_forum_id(), 'type' => 'NUMERIC', 'compare' => '='));
}
// Only forum replies
if (!empty($_GET['type']) && bbp_get_reply_post_type() === $_GET['type']) {
// The query
$the_query = array('author' => 0, 'feed' => true, 'post_type' => bbp_get_reply_post_type(), 'post_parent' => 'any', 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'posts_per_page' => bbp_get_replies_per_rss_page(), 'order' => 'DESC', 'meta_query' => $meta_query);
// Output the feed
bbp_display_replies_feed_rss2($the_query);
// Only forum topics
} elseif (!empty($_GET['type']) && bbp_get_topic_post_type() === $_GET['type']) {
// The query
$the_query = array('author' => 0, 'feed' => true, 'post_type' => bbp_get_topic_post_type(), 'post_parent' => bbp_get_forum_id(), 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'posts_per_page' => bbp_get_topics_per_rss_page(), 'order' => 'DESC');
// Output the feed
bbp_display_topics_feed_rss2($the_query);
// All forum topics and replies
} else {
// Exclude private/hidden forums if not looking at single
if (empty($select_query_vars)) {
$meta_query = array(bbp_exclude_forum_ids('meta_query'));
}
// The query
$the_query = array('author' => 0, 'feed' => true, 'post_type' => array(bbp_get_reply_post_type(), bbp_get_topic_post_type()), 'post_parent' => 'any', 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'posts_per_page' => bbp_get_replies_per_rss_page(), 'order' => 'DESC', 'meta_query' => $meta_query);
// Output the feed
bbp_display_replies_feed_rss2($the_query);
}
break;
// Topic feed - Show replies
// Topic feed - Show replies
case bbp_get_topic_post_type():
// Single topic
if (!empty($select_query_vars)) {
// Load up our own query
query_posts(array_merge(array('post_type' => bbp_get_topic_post_type(), 'feed' => true), $select_query_vars));
// Output the feed
bbp_display_replies_feed_rss2(array('feed' => true));
// All topics
} else {
// The query
$the_query = array('author' => 0, 'feed' => true, 'post_parent' => 'any', 'posts_per_page' => bbp_get_topics_per_rss_page(), 'show_stickies' => false);
// Output the feed
bbp_display_topics_feed_rss2($the_query);
}
break;
// Replies
// Replies
case bbp_get_reply_post_type():
// The query
$the_query = array('posts_per_page' => bbp_get_replies_per_rss_page(), 'meta_query' => array(array()), 'feed' => true);
//.........这里部分代码省略.........
示例9: widget
//.........这里部分代码省略.........
}
}
} else {
if ('forum_posts' === $type || 'forum_replies' === $type) {
$id = RatingWidgetPlugin::Urid2ForumPostId($urid);
if (function_exists('bp_forums_get_post')) {
$forum_post = @bp_forums_get_post($id);
if (!is_object($forum_post)) {
continue;
}
$title = trim(strip_tags($forum_post->post_text));
$page = bb_get_page_number($forum_post->post_position);
$permalink = get_topic_link($id, $page) . "#post-{$id}";
} else {
if (function_exists('bbp_get_reply_id')) {
$forum_item = bbp_get_topic();
if (is_object($forum_item)) {
$is_topic = true;
} else {
$is_topic = false;
$forum_item = bbp_get_reply($id);
if (!is_object($forum_item)) {
if (RWLogger::IsOn()) {
RWLogger::Log('BBP_FORUM_ITEM_NOT_EXIST', $id);
}
// Invalid id (no topic nor reply).
continue;
}
if (RWLogger::IsOn()) {
RWLogger::Log('BBP_IS_TOPIC_REPLY', $is_topic ? 'FALSE' : 'TRUE');
}
}
// Visible statueses: Public or Closed.
$visible_statuses = array(bbp_get_public_status_id(), bbp_get_closed_status_id());
if (!in_array($forum_item->post_status, $visible_statuses)) {
if (RWLogger::IsOn()) {
RWLogger::Log('BBP_FORUM_ITEM_HIDDEN', $forum_item->post_status);
}
// Item is not public nor closed.
continue;
}
$is_reply = !$is_topic;
if ($is_reply) {
// Get parent topic.
$forum_topic = bbp_get_topic($forum_post->post_parent);
if (!in_array($forum_topic->post_status, $visible_statuses)) {
if (RWLogger::IsOn()) {
RWLogger::Log('BBP_PARENT_FORUM_TOPIC_IS_HIDDEN', 'TRUE');
}
// Parent topic is not public nor closed.
continue;
}
}
$title = trim(strip_tags($forum_post->post_title));
$permalink = get_permalink($forum_post->ID);
} else {
continue;
}
}
$types[$type]['handler']->GetElementInfoByRating();
} else {
$found_handler = false;
$extensions = ratingwidget()->GetExtensions();
foreach ($extensions as $ext) {
$result = $ext->GetElementInfoByRating($type, $rating);
if (false !== $result) {
示例10: bbp_get_user_closed_topic_count
/**
* Return the raw database count of closed topics by a user
*
* @since 2.6.0 bbPress (r6113)
*
* @param int $user_id User ID to get count for
*
* @return int Raw DB count of user closed topics
*/
function bbp_get_user_closed_topic_count($user_id = 0)
{
$user_id = bbp_get_user_id($user_id);
if (empty($user_id)) {
return false;
}
$bbp_db = bbp_db();
$count = (int) $bbp_db->get_var("SELECT COUNT(*)\n\t\tFROM {$bbp_db->posts}\n\t\tWHERE post_type = '" . bbp_get_topic_post_type() . "'\n\t\tAND post_status = '" . bbp_get_closed_status_id() . "'\n\t\tAND post_author = {$user_id};");
return (int) apply_filters('bbp_get_user_closed_topic_count', $count, $user_id);
}
示例11: row_actions
/**
* Forum Row actions
*
* Remove the quick-edit action link and display the description under
* the forum title and add the open/close links
*
* @since 2.0.0 bbPress (r2577)
*
* @param array $actions Actions
* @param array $forum Forum object
* @uses bbp_get_public_status_id() To get the published forum id's
* @uses bbp_get_private_status_id() To get the private forum id's
* @uses bbp_get_hidden_status_id() To get the hidden forum id's
* @uses bbp_get_closed_status_id() To get the closed forum id's
* @uses wp_nonce_url() To nonce the url
* @uses bbp_is_forum_open() To check if a forum is open
* @uses bbp_forum_content() To output forum description
* @return array $actions Actions
*/
public function row_actions($actions, $forum)
{
if ($this->bail()) {
return $actions;
}
unset($actions['inline hide-if-no-js']);
// Only show the actions if the user is capable of viewing them :)
if (current_user_can('keep_gate', $forum->ID)) {
// Show the 'close' and 'open' link on published, private, hidden and closed posts only
if (in_array($forum->post_status, array(bbp_get_public_status_id(), bbp_get_private_status_id(), bbp_get_hidden_status_id(), bbp_get_closed_status_id()))) {
$close_uri = wp_nonce_url(add_query_arg(array('forum_id' => $forum->ID, 'action' => 'bbp_toggle_forum_close'), remove_query_arg(array('bbp_forum_toggle_notice', 'forum_id', 'failed', 'super'))), 'close-forum_' . $forum->ID);
if (bbp_is_forum_open($forum->ID)) {
$actions['closed'] = '<a href="' . esc_url($close_uri) . '" title="' . esc_attr__('Close this forum', 'bbpress') . '">' . _x('Close', 'Close a Forum', 'bbpress') . '</a>';
} else {
$actions['closed'] = '<a href="' . esc_url($close_uri) . '" title="' . esc_attr__('Open this forum', 'bbpress') . '">' . _x('Open', 'Open a Forum', 'bbpress') . '</a>';
}
}
}
// simple hack to show the forum description under the title
bbp_forum_content($forum->ID);
return $actions;
}
示例12: widget
//.........这里部分代码省略.........
?>
</ul><!--/.alx-tab-->
<?php
}
?>
<?php
if ($instance['tags_enable']) {
// Tags enabled?
?>
<ul id="tab-tags" class="alx-tab group">
<li>
<?php
wp_tag_cloud();
?>
</li>
</ul><!--/.alx-tab-->
<?php
}
?>
<?php
if ($instance['topics_enable']) {
// Recent posts enabled?
?>
<?php
switch ($instance["topics_order"]) {
// Order by most recent replies
case 'freshness':
$topics_query = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => $instance['topics_parent'], 'posts_per_page' => (int) $instance["topics_num"], 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'meta_key' => '_bbp_last_active_time', 'orderby' => 'meta_value', 'order' => 'DESC');
break;
// Order by total number of replies
// Order by total number of replies
case 'popular':
$topics_query = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => $instance['topics_parent'], 'posts_per_page' => (int) $instance["topics_num"], 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'meta_key' => '_bbp_reply_count', 'orderby' => 'meta_value', 'order' => 'DESC');
break;
// Order by which topic was created most recently
// Order by which topic was created most recently
case 'newness':
default:
$topics_query = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => $instance['topics_parent'], 'posts_per_page' => (int) $instance["topics_num"], 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'order' => 'DESC');
break;
}
?>
<?php
$topics = new WP_Query($topics_query);
?>
<ul id="tab-topics" class="alx-tab group">
<?php
while ($topics->have_posts()) {
$topics->the_post();
?>
<li>
<div class="tab-item-inner group">
<?php
if ($instance['tabs_category']) {
?>
<p class="tab-item-category"><?php
the_category(' / ');
?>
示例13: switch
// How do we want to order our results?
switch ($order_by) {
// Order by most recent replies
case 'freshness':
$topics_query = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => $parent_forum, 'posts_per_page' => (int) $max_shown, 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'meta_key' => '_bbp_last_active_time', 'orderby' => 'meta_value', 'order' => 'DESC');
break;
// Order by total number of replies
// Order by total number of replies
case 'popular':
$topics_query = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => $parent_forum, 'posts_per_page' => (int) $max_shown, 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'meta_key' => '_bbp_reply_count', 'orderby' => 'meta_value', 'order' => 'DESC');
break;
// Order by which topic was created most recently
// Order by which topic was created most recently
case 'newness':
default:
$topics_query = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => $parent_forum, 'posts_per_page' => (int) $max_shown, 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'order' => 'DESC');
break;
}
// Note: private and hidden forums will be excluded via the
// bbp_pre_get_posts_normalize_forum_visibility action and function.
$widget_query = new WP_Query($topics_query);
?>
<div class="topics-thread">
<?php
while ($widget_query->have_posts()) {
$widget_query->the_post();
$topic_id = bbp_get_topic_id($widget_query->post->ID);
$author_link = '';
// Maybe get the topic author
$author_link = bbp_get_topic_author_link(array('post_id' => $topic_id, 'type' => 'both', 'size' => 50));
示例14: display_forums
/**
* Output the forums for a group in the edit screens
*
* @since bbPress (r3653)
* @uses bp_get_current_group_id()
* @uses bbp_get_group_forum_ids()
* @uses bbp_has_forums()
* @uses bbp_get_template_part()
*/
public function display_forums($offset = 0)
{
// Allow actions immediately before group forum output
do_action('bbp_before_group_forum_display');
// Load up bbPress once
$bbp = bbpress();
// Forum data
$forum_slug = bp_action_variable($offset);
$forum_ids = bbp_get_group_forum_ids(bp_get_current_group_id());
$forum_args = array('post__in' => $forum_ids, 'post_parent' => null);
// Unset global queries
$bbp->forum_query = new stdClass();
$bbp->topic_query = new stdClass();
$bbp->reply_query = new stdClass();
// Unset global ID's
$bbp->current_forum_id = 0;
$bbp->current_topic_id = 0;
$bbp->current_reply_id = 0;
$bbp->current_topic_tag_id = 0;
// Reset the post data
wp_reset_postdata();
// Allow admins special views
$post_status = array(bbp_get_closed_status_id(), bbp_get_public_status_id());
if (is_super_admin() || current_user_can('moderate') || bp_is_item_admin() || bp_is_item_mod()) {
$post_status = array_merge($post_status, array(bbp_get_spam_status_id(), bbp_get_trash_status_id()));
}
?>
<div id="bbpress-forums">
<?php
// Looking at the group forum root
if (empty($forum_slug) || 'page' == $forum_slug) {
// Query forums and show them if they exist
if (!empty($forum_ids) && bbp_has_forums($forum_args)) {
// Only one forum found
if (1 == $bbp->forum_query->post_count) {
// Remove 'name' check for paginated requests
if ('page' == $forum_slug) {
$forum_args = array('post_type' => bbp_get_forum_post_type());
} else {
$forum_args = array('name' => $forum_slug, 'post_type' => bbp_get_forum_post_type());
}
// Get the forums
$forums = get_posts($forum_args);
bbp_the_forum();
// Forum exists
if (!empty($forums)) {
$forum = $forums[0];
// Suppress subforums for now
add_filter('bbp_get_forum_subforum_count', '__return_false');
// Set up forum data
bbpress()->current_forum_id = $forum->ID;
bbp_set_query_name('bbp_single_forum');
?>
<h3><?php
bbp_forum_title();
?>
</h3>
<?php
bbp_get_template_part('content', 'single-forum');
?>
<?php
// Remove the subforum suppression filter
remove_filter('bbp_get_forum_subforum_count', '__return_false');
?>
<?php
} else {
?>
<?php
bbp_get_template_part('feedback', 'no-topics');
?>
<?php
bbp_get_template_part('form', 'topic');
?>
<?php
}
// More than 1 forum found or group forum admin screen
} elseif (1 < $bbp->forum_query->post_count) {
?>
<h3><?php
_e('Forums', 'bbpress');
?>
//.........这里部分代码省略.........
示例15: widget
/**
* Displays the output, the replies list
*
* @since bbPress (r2653)
*
* @param mixed $args
* @param array $instance
* @uses apply_filters() Calls 'bbp_reply_widget_title' with the title
* @uses bbp_get_reply_author_link() To get the reply author link
* @uses bbp_get_reply_author() To get the reply author name
* @uses bbp_get_reply_id() To get the reply id
* @uses bbp_get_reply_url() To get the reply url
* @uses bbp_get_reply_excerpt() To get the reply excerpt
* @uses bbp_get_reply_topic_title() To get the reply topic title
* @uses get_the_date() To get the date of the reply
* @uses get_the_time() To get the time of the reply
*/
public function widget($args, $instance)
{
extract($args);
$title = apply_filters('bbp_replies_widget_title', $instance['title']);
$max_shown = !empty($instance['max_shown']) ? $instance['max_shown'] : '5';
$show_date = !empty($instance['show_date']) ? 'on' : false;
$show_user = !empty($instance['show_user']) ? 'on' : false;
$post_types = !empty($instance['post_type']) ? array(bbp_get_topic_post_type(), bbp_get_reply_post_type()) : bbp_get_reply_post_type();
// 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_type' => $post_types, 'post_status' => join(',', array(bbp_get_public_status_id(), bbp_get_closed_status_id())), 'posts_per_page' => $max_shown, 'meta_query' => array(bbp_exclude_forum_ids('meta_query'))));
// Get replies and display them
if ($widget_query->have_posts()) {
echo $before_widget;
echo $before_title . $title . $after_title;
?>
<ul>
<?php
while ($widget_query->have_posts()) {
$widget_query->the_post();
?>
<li>
<?php
$reply_id = bbp_get_reply_id($widget_query->post->ID);
$author_link = bbp_get_reply_author_link(array('post_id' => $reply_id, 'type' => 'both', 'size' => 14));
$reply_link = '<a class="bbp-reply-topic-title" href="' . esc_url(bbp_get_reply_url($reply_id)) . '" title="' . bbp_get_reply_excerpt($reply_id, 50) . '">' . bbp_get_reply_topic_title($reply_id) . '</a>';
// Reply author, link, and timestamp
if ('on' == $show_date && 'on' == $show_user) {
// translators: 1: reply author, 2: reply link, 3: reply timestamp
printf(_x('%1$s on %2$s %3$s', 'widgets', 'bbpress'), $author_link, $reply_link, '<div>' . bbp_get_time_since(get_the_time('U')) . '</div>');
// Reply link and timestamp
} elseif ($show_date == 'on') {
// translators: 1: reply link, 2: reply timestamp
printf(_x('%1$s %2$s', 'widgets', 'bbpress'), $reply_link, '<div>' . bbp_get_time_since(get_the_time('U')) . '</div>');
// Reply author and title
} elseif ($show_user == 'on') {
// translators: 1: reply author, 2: reply link
printf(_x('%1$s on %2$s', 'widgets', 'bbpress'), $author_link, $reply_link);
// Only the reply title
} else {
// translators: 1: reply link
printf(_x('%1$s', 'widgets', 'bbpress'), $reply_link);
}
?>
</li>
<?php
}
?>
</ul>
<?php
echo $after_widget;
// Reset the $post global
wp_reset_postdata();
}
}