本文整理汇总了PHP中bbp_get_spam_status_id函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_get_spam_status_id函数的具体用法?PHP bbp_get_spam_status_id怎么用?PHP bbp_get_spam_status_id使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bbp_get_spam_status_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_bbp_get_topic_reply_count_hidden
/**
* @covers ::bbp_topic_reply_count_hidden
* @covers ::bbp_get_topic_reply_count_hidden
*/
public function test_bbp_get_topic_reply_count_hidden()
{
$f = $this->factory->forum->create();
$int_value = 3;
$formatted_value = bbp_number_format($int_value);
$t = $this->factory->topic->create(array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f)));
$r = $this->factory->reply->create_many($int_value, array('post_parent' => $t, 'post_status' => bbp_get_spam_status_id(), 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
bbp_update_topic_reply_count_hidden($t);
bbp_spam_reply($r[1]);
// Output
$this->expectOutputString($formatted_value);
bbp_topic_reply_count_hidden($t);
// Formatted string
$count = bbp_get_topic_reply_count_hidden($t, false);
$this->assertSame($formatted_value, $count);
// Integer
$count = bbp_get_topic_reply_count_hidden($t, true);
$this->assertSame($int_value, $count);
}
示例2: test_bbp_decrease_forum_topic_count_hidden
/**
* @covers ::bbp_decrease_forum_topic_count_hidden
*/
public function test_bbp_decrease_forum_topic_count_hidden()
{
$f = $this->factory->forum->create();
$count = bbp_get_forum_topic_count_hidden($f);
$this->assertSame('0', $count);
$t = $this->factory->topic->create_many(2, array('post_parent' => $f, 'post_status' => bbp_get_spam_status_id(), 'topic_meta' => array('forum_id' => $f, 'spam_meta_status' => 'publish')));
bbp_update_forum_topic_count_hidden($f);
$count = bbp_get_forum_topic_count_hidden($f);
$this->assertSame('2', $count);
bbp_decrease_forum_topic_count_hidden($f);
$count = bbp_get_forum_topic_count_hidden($f);
$this->assertSame('1', $count);
}
示例3: filter_dropdown
/**
* Add forum dropdown to topic and reply list table filters
*
* @since 2.0.0 bbPress (r2991)
*
* @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_dropdown() To generate a forum dropdown
* @return bool False. If post type is not topic or reply
*/
public function filter_dropdown()
{
if ($this->bail()) {
return;
}
// Add Empty Spam button
if (!empty($_GET['post_status']) && bbp_get_spam_status_id() === $_GET['post_status'] && current_user_can('moderate')) {
wp_nonce_field('bulk-destroy', '_destroy_nonce');
$title = esc_attr__('Empty Spam', 'bbpress');
submit_button($title, 'button-secondary apply', 'delete_all', false);
}
// Get which forum is selected
$selected = !empty($_GET['bbp_forum_id']) ? $_GET['bbp_forum_id'] : '';
// Show the forums dropdown
bbp_dropdown(array('selected' => $selected, 'show_none' => __('In all forums', 'bbpress')));
}
示例4: bbp_unspam_topic
/**
* Unspams a topic
*
* @since bbPress (r2740)
*
* @param int $topic_id Topic id
* @uses bbp_get_topic() To get the topic
* @uses do_action() Calls 'bbp_unspam_topic' with the topic id
* @uses get_post_meta() To get the previous status
* @uses delete_post_meta() To delete the previous status meta
* @uses wp_update_post() To update the topic with the new status
* @uses do_action() Calls 'bbp_unspammed_topic' with the topic id
* @return mixed False or {@link WP_Error} on failure, topic id on success
*/
function bbp_unspam_topic($topic_id = 0)
{
// Get the topic
$topic = bbp_get_topic($topic_id);
if (empty($topic)) {
return $topic;
}
// Bail if already not spam
if (bbp_get_spam_status_id() !== $topic->post_status) {
return false;
}
// Execute pre unspam code
do_action('bbp_unspam_topic', $topic_id);
/** Untrash Replies *******************************************************/
// Get the replies that were not previously trashed
$pre_spammed_replies = get_post_meta($topic_id, '_bbp_pre_spammed_replies', true);
// There are replies to untrash
if (!empty($pre_spammed_replies)) {
// Maybe reverse the trashed replies array
if (is_array($pre_spammed_replies)) {
$pre_spammed_replies = array_reverse($pre_spammed_replies);
}
// Loop through replies
foreach ((array) $pre_spammed_replies as $reply) {
wp_untrash_post($reply);
}
}
/** Topic Tags ************************************************************/
// Get pre-spam topic tags
$terms = get_post_meta($topic_id, '_bbp_spam_topic_tags', true);
// Topic had tags before it was spammed
if (!empty($terms)) {
// Set the tax_input of the topic
$topic->tax_input = array(bbp_get_topic_tag_tax_id() => $terms);
// Delete pre-spam topic tag meta
delete_post_meta($topic_id, '_bbp_spam_topic_tags');
}
/** Topic Status **********************************************************/
// Get pre spam status
$topic_status = get_post_meta($topic_id, '_bbp_spam_meta_status', true);
// If no previous status, default to publish
if (empty($topic_status)) {
$topic_status = bbp_get_public_status_id();
}
// Set post status to pre spam
$topic->post_status = $topic_status;
// Delete pre spam meta
delete_post_meta($topic_id, '_bbp_spam_meta_status');
// No revisions
remove_action('pre_post_update', 'wp_save_post_revision');
// Update the topic
$topic_id = wp_update_post($topic);
// Execute post unspam code
do_action('bbp_unspammed_topic', $topic_id);
// Return topic_id
return $topic_id;
}
示例5: bbp_get_reply_admin_links
/**
* Return admin links for reply
*
* @since bbPress (r2667)
*
* @param array $args This function supports these arguments:
* - id: Optional. Reply id
* - before: HTML before the links. Defaults to
* '<span class="bbp-admin-links">'
* - after: HTML after the links. Defaults to '</span>'
* - sep: Separator. Defaults to ' | '
* - links: Array of the links to display. By default, edit, trash,
* spam, reply move, and topic split links are displayed
* @uses bbp_is_topic() To check if it's the topic page
* @uses bbp_is_reply() To check if it's the reply page
* @uses bbp_get_reply_id() To get the reply id
* @uses bbp_get_reply_edit_link() To get the reply edit link
* @uses bbp_get_reply_trash_link() To get the reply trash link
* @uses bbp_get_reply_spam_link() To get the reply spam link
* @uses bbp_get_reply_move_link() To get the reply move link
* @uses bbp_get_topic_split_link() To get the topic split link
* @uses current_user_can() To check if the current user can edit or
* delete the reply
* @uses apply_filters() Calls 'bbp_get_reply_admin_links' with the
* reply admin links and args
* @return string Reply admin links
*/
function bbp_get_reply_admin_links($args = array())
{
// Parse arguments against default values
$r = bbp_parse_args($args, array('id' => 0, 'before' => '<span class="bbp-admin-links">', 'after' => '</span>', 'sep' => ' | ', 'links' => array()), 'get_reply_admin_links');
$r['id'] = bbp_get_reply_id((int) $r['id']);
// If post is a topic, return the topic admin links instead
if (bbp_is_topic($r['id'])) {
return bbp_get_topic_admin_links($args);
}
// If post is not a reply, return
if (!bbp_is_reply($r['id'])) {
return;
}
// If topic is trashed, do not show admin links
if (bbp_is_topic_trash(bbp_get_reply_topic_id($r['id']))) {
return;
}
// If no links were passed, default to the standard
if (empty($r['links'])) {
$r['links'] = apply_filters('bbp_reply_admin_links', array('edit' => bbp_get_reply_edit_link($r), 'move' => bbp_get_reply_move_link($r), 'split' => bbp_get_topic_split_link($r), 'trash' => bbp_get_reply_trash_link($r), 'spam' => bbp_get_reply_spam_link($r), 'reply' => bbp_get_reply_to_link($r)), $r['id']);
}
// See if links need to be unset
$reply_status = bbp_get_reply_status($r['id']);
if (in_array($reply_status, array(bbp_get_spam_status_id(), bbp_get_trash_status_id()))) {
// Spam link shouldn't be visible on trashed topics
if (bbp_get_trash_status_id() === $reply_status) {
unset($r['links']['spam']);
// Trash link shouldn't be visible on spam topics
} elseif (bbp_get_spam_status_id() === $reply_status) {
unset($r['links']['trash']);
}
}
// Process the admin links
$links = implode($r['sep'], array_filter($r['links']));
$retval = $r['before'] . $links . $r['after'];
return apply_filters('bbp_get_reply_admin_links', $retval, $r, $args);
}
示例6: bbp_admin_repair_topic_hidden_reply_count
/**
* Recount topic hidden replies (spammed/trashed)
*
* @since bbPress (r2747)
*
* @uses wpdb::query() To run our recount sql queries
* @uses is_wp_error() To check if the executed query returned {@link WP_Error}
* @return array An array of the status code and the message
*/
function bbp_admin_repair_topic_hidden_reply_count()
{
global $wpdb;
$statement = __('Counting the number of spammed and trashed replies in each topic… %s', 'bbpress');
$result = __('Failed!', 'bbpress');
$sql_delete = "DELETE FROM `{$wpdb->postmeta}` WHERE `meta_key` = '_bbp_reply_count_hidden';";
if (is_wp_error($wpdb->query($sql_delete))) {
return array(1, sprintf($statement, $result));
}
$sql = "INSERT INTO `{$wpdb->postmeta}` (`post_id`, `meta_key`, `meta_value`) (SELECT `post_parent`, '_bbp_reply_count_hidden', COUNT(`post_status`) as `meta_value` FROM `{$wpdb->posts}` WHERE `post_type` = '" . bbp_get_reply_post_type() . "' AND `post_status` IN ( '" . implode("','", array(bbp_get_trash_status_id(), bbp_get_spam_status_id())) . "') GROUP BY `post_parent`);";
if (is_wp_error($wpdb->query($sql))) {
return array(2, sprintf($statement, $result));
}
return array(0, sprintf($statement, __('Complete!', 'bbpress')));
}
示例7: bbp_unspam_reply
/**
* Unspams a reply
*
* @since bbPress (r2740)
*
* @param int $reply_id Reply id
* @uses bbp_get_reply() To get the reply
* @uses do_action() Calls 'bbp_unspam_reply' with the reply ID
* @uses get_post_meta() To get the previous status meta
* @uses delete_post_meta() To delete the previous status meta
* @uses wp_update_post() To insert the updated post
* @uses do_action() Calls 'bbp_unspammed_reply' with the reply ID
* @return mixed False or {@link WP_Error} on failure, reply id on success
*/
function bbp_unspam_reply($reply_id = 0)
{
// Get reply
$reply = bbp_get_reply($reply_id);
if (empty($reply)) {
return $reply;
}
// Bail if already not spam
if (bbp_get_spam_status_id() !== $reply->post_status) {
return false;
}
// Execute pre unspam code
do_action('bbp_unspam_reply', $reply_id);
// Get pre spam status
$reply->post_status = get_post_meta($reply_id, '_bbp_spam_meta_status', true);
// If no previous status, default to publish
if (empty($reply->post_status)) {
$reply->post_status = bbp_get_public_status_id();
}
// Delete pre spam meta
delete_post_meta($reply_id, '_bbp_spam_meta_status');
// No revisions
remove_action('pre_post_update', 'wp_save_post_revision');
// Update the reply
$reply_id = wp_update_post($reply);
// Execute post unspam code
do_action('bbp_unspammed_reply', $reply_id);
// Return reply_id
return $reply_id;
}
示例8: bbp_unspam_topic
/**
* Unspams a topic
*
* @since bbPress (r2740)
*
* @param int $topic_id Topic id
* @uses wp_get_single_post() To get the topic
* @uses do_action() Calls 'bbp_unspam_topic' with the topic id
* @uses get_post_meta() To get the previous status
* @uses delete_post_meta() To delete the previous status meta
* @uses wp_insert_post() To update the topic with the new status
* @uses do_action() Calls 'bbp_unspammed_topic' with the topic id
* @return mixed False or {@link WP_Error} on failure, topic id on success
*/
function bbp_unspam_topic($topic_id = 0)
{
// Get the topic
if (!($topic = wp_get_single_post($topic_id, ARRAY_A))) {
return $topic;
}
// Bail if already not spam
if (bbp_get_spam_status_id() != $topic['post_status']) {
return false;
}
// Execute pre unspam code
do_action('bbp_unspam_topic', $topic_id);
// Get pre spam status
$topic_status = get_post_meta($topic_id, '_bbp_spam_meta_status', true);
// Set post status to pre spam
$topic['post_status'] = $topic_status;
// Delete pre spam meta
delete_post_meta($topic_id, '_bbp_spam_meta_status');
// No revisions
remove_action('pre_post_update', 'wp_save_post_revision');
// Get pre-spam topic tags
$terms = get_post_meta($topic_id, '_bbp_spam_topic_tags', true);
// Topic had tags before it was spammed
if (!empty($terms)) {
// Set the tax_input of the topic
$topic['tax_input'] = array(bbp_get_topic_tag_tax_id() => $terms);
// Delete pre-spam topic tag meta
delete_post_meta($topic_id, '_bbp_spam_topic_tags');
}
// Update the topic
$topic_id = wp_insert_post($topic);
// Execute post unspam code
do_action('bbp_unspammed_topic', $topic_id);
// Return topic_id
return $topic_id;
}
示例9: bbp_update_forum_topic_count_hidden
/**
* Adjust the total hidden topic count of a forum (hidden includes trashed,
* spammed and pending topics)
*
* @since 2.0.0 bbPress (r2888)
* @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects
*
* @param int $forum_id Optional. Topic id to update.
* @param int $topic_count Optional. Set the topic count manually.
* @uses bbp_is_topic() To check if the supplied id is a topic
* @uses bbp_get_topic_id() To get the topic id
* @uses bbp_get_topic_forum_id() To get the topic forum id
* @uses bbp_get_forum_id() To get the forum id
* @uses bbp_get_trash_status_id() To get the trash status id
* @uses bbp_get_spam_status_id() To get the spam status id
* @uses bbp_get_pending_status_id() To get the pending status id
* @uses bbp_get_topic_post_type() To get the topic post type
* @uses update_post_meta() To update the forum hidden topic count meta
* @uses apply_filters() Calls 'bbp_update_forum_topic_count_hidden' with the
* hidden topic count and forum id
* @return int Topic hidden topic count
*/
function bbp_update_forum_topic_count_hidden($forum_id = 0, $topic_count = 0)
{
// If topic_id was passed as $forum_id, then get its forum
if (bbp_is_topic($forum_id)) {
$topic_id = bbp_get_topic_id($forum_id);
$forum_id = bbp_get_topic_forum_id($topic_id);
// $forum_id is not a topic_id, so validate and proceed
} else {
$forum_id = bbp_get_forum_id($forum_id);
}
// Can't update what isn't there
if (!empty($forum_id)) {
// Get topics of forum
if (empty($topic_count)) {
$query = new WP_Query(array('fields' => 'ids', 'post_parent' => $forum_id, 'post_status' => array(bbp_get_trash_status_id(), bbp_get_spam_status_id(), bbp_get_pending_status_id()), 'post_type' => bbp_get_topic_post_type(), 'posts_per_page' => -1, 'update_post_term_cache' => false, 'update_post_meta_cache' => false, 'ignore_sticky_posts' => true));
$topic_count = $query->post_count;
unset($query);
}
$topic_count = (int) $topic_count;
// Update the count
update_post_meta($forum_id, '_bbp_topic_count_hidden', $topic_count);
}
return (int) apply_filters('bbp_update_forum_topic_count_hidden', $topic_count, $forum_id);
}
示例10: bbp_get_reply_admin_links
/**
* Return admin links for reply
*
* @since bbPress (r2667)
*
* @param mixed $args This function supports these arguments:
* - id: Optional. Reply id
* - before: HTML before the links. Defaults to
* '<span class="bbp-admin-links">'
* - after: HTML after the links. Defaults to '</span>'
* - sep: Separator. Defaults to ' | '
* - links: Array of the links to display. By default, edit, trash,
* spam and topic split links are displayed
* @uses bbp_is_topic() To check if it's the topic page
* @uses bbp_is_reply() To check if it's the reply page
* @uses bbp_get_reply_id() To get the reply id
* @uses bbp_get_reply_edit_link() To get the reply edit link
* @uses bbp_get_reply_trash_link() To get the reply trash link
* @uses bbp_get_reply_spam_link() To get the reply spam link
* @uses bbp_get_topic_split_link() To get the topic split link
* @uses current_user_can() To check if the current user can edit or
* delete the reply
* @uses apply_filters() Calls 'bbp_get_reply_admin_links' with the
* reply admin links and args
* @return string Reply admin links
*/
function bbp_get_reply_admin_links($args = '')
{
$defaults = array('id' => 0, 'before' => '<span class="bbp-admin-links">', 'after' => '</span>', 'sep' => ' | ', 'links' => array());
$r = bbp_parse_args($args, $defaults, 'get_reply_admin_links');
$r['id'] = bbp_get_reply_id((int) $r['id']);
// If post is a topic, return the topic admin links instead
if (bbp_is_topic($r['id'])) {
return bbp_get_topic_admin_links($args);
}
// If post is not a reply, return
if (!bbp_is_reply($r['id'])) {
return;
}
// Make sure user can edit this reply
if (!current_user_can('edit_reply', $r['id'])) {
return;
}
// If topic is trashed, do not show admin links
if (bbp_is_topic_trash(bbp_get_reply_topic_id($r['id']))) {
return;
}
// If no links were passed, default to the standard
if (empty($r['links'])) {
$r['links'] = array('edit' => bbp_get_reply_edit_link($r), 'split' => bbp_get_topic_split_link($r), 'trash' => bbp_get_reply_trash_link($r), 'spam' => bbp_get_reply_spam_link($r));
}
// Check caps for trashing the topic
if (!current_user_can('delete_reply', $r['id']) && !empty($r['links']['trash'])) {
unset($r['links']['trash']);
}
// See if links need to be unset
$reply_status = bbp_get_reply_status($r['id']);
if (in_array($reply_status, array(bbp_get_spam_status_id(), bbp_get_trash_status_id()))) {
// Spam link shouldn't be visible on trashed topics
if ($reply_status == bbp_get_trash_status_id()) {
unset($r['links']['spam']);
// Trash link shouldn't be visible on spam topics
} elseif (isset($r['links']['trash']) && bbp_get_spam_status_id() == $reply_status) {
unset($r['links']['trash']);
}
}
// Process the admin links
$links = implode($r['sep'], array_filter($r['links']));
$retval = $r['before'] . $links . $r['after'];
return apply_filters('bbp_get_reply_admin_links', $retval, $args);
}
示例11: post_new_topic
//.........这里部分代码省略.........
/** TOPIC DATA ***************************************************/
$topic_content = $data['content'];
$topic_title = $data['subject'];
bp_rbe_log('Message #' . $i . ': body contents - ' . $topic_content);
bp_rbe_log('Subject - ' . $topic_title);
if (empty($topic_content) || empty($topic_title)) {
//do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bbp_new_forum_topic_empty' );
return new WP_Error('bbp_new_forum_topic_empty', '', $data);
}
// Filter and sanitize
$topic_title = apply_filters('bbp_new_topic_pre_title', $topic_title);
$topic_content = apply_filters('bbp_new_topic_pre_content', $topic_content);
/** Topic Tags ****************************************************/
/* TODO
if ( bbp_allow_topic_tags() ) {
// Escape tag input
$terms = esc_attr( strip_tags( $_POST['bbp_topic_tags'] ) );
// Explode by comma
if ( strstr( $terms, ',' ) ) {
$terms = explode( ',', $terms );
}
// Add topic tag ID as main key
$terms = array( bbp_get_topic_tag_tax_id() => $terms );
}
*/
/** TOPIC MODERATION *********************************************/
// Post Flooding
if (!bbp_check_for_flood($anonymous_data, $topic_author)) {
//do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bbp_topic_flood' );
//bbp_add_error( 'bbp_reply_flood', __( '<strong>ERROR</strong>: Slow down; you move too fast.', 'bbpress' ) );
return new WP_Error('bbp_topic_flood', '', $data);
}
// Topic Duplicate
if (!bbp_check_for_duplicate(array('post_type' => bbp_get_topic_post_type(), 'post_author' => $topic_author, 'post_content' => $topic_content, 'anonymous_data' => $anonymous_data))) {
//do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bbp_topic_duplicate' );
return new WP_Error('bbp_topic_duplicate', '', $data);
}
// Topic Blacklist
if (!bbp_check_for_blacklist($anonymous_data, $topic_author, $topic_title, $topic_content)) {
//do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bbp_topic_blacklist' );
return new WP_Error('bbp_topic_blacklist', '', $data);
}
// Topic Status
// Maybe put into moderation
if (!bbp_check_for_moderation($anonymous_data, $topic_author, $topic_title, $topic_content)) {
$topic_status = bbp_get_pending_status_id();
// Default
} else {
$topic_status = bbp_get_public_status_id();
}
/** POSTING TIME! ************************************************/
// bbP hook before save
do_action('bbp_new_topic_pre_extras', $forum_id);
// Setup reply data
$topic_data = apply_filters('bbp_new_topic_pre_insert', array('post_author' => $topic_author, 'post_title' => $topic_title, 'post_content' => $topic_content, 'post_status' => $topic_status, 'post_parent' => $forum_id, 'post_type' => bbp_get_topic_post_type(), 'comment_status' => 'closed'));
// Insert topic
$topic_id = wp_insert_post($topic_data);
// Topic posted!
if (!is_wp_error($topic_id)) {
// more internal logging
bp_rbe_log('Message #' . $i . ': bbPress topic successfully posted!');
// Problem posting
} else {
//do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bbp_topic_error' );
return new WP_Error('bbp_topic_error', '', $data);
}
/** AFTER POSTING ************************************************/
// stuff that needs to happen after a bbP topic is posted occurs here... bbP
// should preferably do the following at the 'bbp_new_reply' hook, until then
// do what bbP does inline.
// Trash Check ////////////////////////////////////////////////////
// If the forum is trash, or the topic_status is switched to
// trash, trash it properly
if (get_post_field('post_status', $forum_id) == bbp_get_trash_status_id() || $topic_data['post_status'] == bbp_get_trash_status_id()) {
// Trash the reply
wp_trash_post($topic_id);
}
// Spam Check /////////////////////////////////////////////////////
// If reply or topic are spam, officially spam this reply
if ($topic_data['post_status'] == bbp_get_spam_status_id()) {
add_post_meta($topic_id, '_bbp_spam_meta_status', bbp_get_public_status_id());
}
// Reply By Email /////////////////////////////////////////////////
// Add a RBE marker to the post's meta
// Could potentially show that post was made via email on the frontend
add_post_meta($topic_id, 'bp_rbe', 1);
/** POST HOOKS ***************************************************/
// RBE Custom Hooks ///////////////////////////////////////////////
// change activity action
add_filter('bbp_before_record_activity_parse_args', array($this, 'change_activity_action'));
// add RBE's special activity hook
add_action('bp_activity_after_save', array($this, 'activity_rbe_hook'));
// bbPress Topic Hooks ////////////////////////////////////////////
do_action('bbp_new_topic', $topic_id, $forum_id, $anonymous_data, $topic_author);
do_action('bbp_new_topic_post_extras', $topic_id);
return array('bbp_topic_id' => $topic_id);
}
示例12: 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');
?>
//.........这里部分代码省略.........
示例13: test_bbp_get_forum_topic_count_hidden
/**
* @covers ::bbp_forum_topic_count_hidden
* @covers ::bbp_get_forum_topic_count_hidden
*/
public function test_bbp_get_forum_topic_count_hidden()
{
$f = $this->factory->forum->create();
$int_value = 3;
$formatted_value = bbp_number_format($int_value);
$this->factory->topic->create_many($int_value, array('post_parent' => $f, 'post_status' => bbp_get_spam_status_id()));
bbp_update_forum_topic_count_hidden($f);
// Output
$count = bbp_get_forum_topic_count_hidden($f, false);
$this->expectOutputString($formatted_value);
bbp_forum_topic_count_hidden($f);
// Formatted string
$count = bbp_get_forum_topic_count_hidden($f, false);
$this->assertSame($formatted_value, $count);
// Integer
$count = bbp_get_forum_topic_count_hidden($f, true, true);
$this->assertSame($int_value, $count);
}
示例14: bbp_dashboard_widget_right_now
//.........这里部分代码省略.........
<?php
$num = $r['user_count'];
$text = _n('User', 'Users', $r['user_count'], 'bbpress');
if (current_user_can('edit_users')) {
$link = get_admin_url(null, 'users.php');
$num = '<a href="' . $link . '">' . $num . '</a>';
$text = '<a href="' . $link . '">' . $text . '</a>';
}
?>
<td class="b b-users"><span class="total-count"><?php
echo $num;
?>
</span></td>
<td class="last t users"><?php
echo $text;
?>
</td>
</tr>
<?php
if (isset($r['topic_count_hidden'])) {
?>
<tr>
<?php
$num = $r['topic_count_hidden'];
$text = _n('Hidden Topic', 'Hidden Topics', $r['topic_count_hidden'], 'bbpress');
$link = add_query_arg(array('post_type' => bbp_get_topic_post_type()), get_admin_url(null, 'edit.php'));
if ('0' !== $num) {
$link = add_query_arg(array('post_status' => bbp_get_spam_status_id()), $link);
}
$num = '<a href="' . esc_url($link) . '" title="' . esc_attr($r['hidden_topic_title']) . '">' . $num . '</a>';
$text = '<a class="waiting" href="' . esc_url($link) . '" title="' . esc_attr($r['hidden_topic_title']) . '">' . $text . '</a>';
?>
<td class="b b-hidden-topics"><?php
echo $num;
?>
</td>
<td class="last t hidden-replies"><?php
echo $text;
?>
</td>
</tr>
<?php
}
?>
<?php
if (isset($r['reply_count_hidden'])) {
?>
<tr>
<?php
$num = $r['reply_count_hidden'];
$text = _n('Hidden Reply', 'Hidden Replies', $r['reply_count_hidden'], 'bbpress');
$link = add_query_arg(array('post_type' => bbp_get_reply_post_type()), get_admin_url(null, 'edit.php'));
if ('0' !== $num) {
$link = add_query_arg(array('post_status' => bbp_get_spam_status_id()), $link);
示例15: bbp_unspam_reply
/**
* Unspams a reply
*
* @since bbPress (r2740)
*
* @param int $reply_id Reply id
* @uses get_post() To get the reply
* @uses do_action() Calls 'bbp_unspam_reply' with the reply ID
* @uses get_post_meta() To get the previous status meta
* @uses delete_post_meta() To delete the previous status meta
* @uses wp_insert_post() To insert the updated post
* @uses do_action() Calls 'bbp_unspammed_reply' with the reply ID
* @return mixed False or {@link WP_Error} on failure, reply id on success
*/
function bbp_unspam_reply($reply_id = 0)
{
// Get reply
$reply = get_post($reply_id, ARRAY_A);
if (empty($reply)) {
return $reply;
}
// Bail if already not spam
if (bbp_get_spam_status_id() != $reply['post_status']) {
return false;
}
// Execute pre unspam code
do_action('bbp_unspam_reply', $reply_id);
// Get pre spam status
$reply['post_status'] = get_post_meta($reply_id, '_bbp_spam_meta_status', true);
// Delete pre spam meta
delete_post_meta($reply_id, '_bbp_spam_meta_status');
// No revisions
remove_action('pre_post_update', 'wp_save_post_revision');
// Update the reply
$reply_id = wp_insert_post($reply);
// Execute post unspam code
do_action('bbp_unspammed_reply', $reply_id);
// Return reply_id
return $reply_id;
}