本文整理汇总了PHP中bbp_is_forum函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_is_forum函数的具体用法?PHP bbp_is_forum怎么用?PHP bbp_is_forum使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bbp_is_forum函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: pmpro_bbp_is_forum
function pmpro_bbp_is_forum($forum_id = NULL)
{
global $post;
if (bbp_is_forum($post->ID)) {
if (!empty($forum_id) && $post->ID == $forum_id) {
return true;
} elseif (empty($forum_id)) {
return true;
} else {
return false;
}
} elseif (bbp_is_topic($post->ID)) {
if (!empty($forum_id) && $post->post_parent == $forum_id) {
return true;
} elseif (empty($forum_id)) {
return true;
} else {
return false;
}
} elseif (bbp_is_reply($post->ID)) {
if (!empty($forum_id) && in_array($forum_id, $post->ancestors)) {
return true;
} elseif (empty($forum_id)) {
return true;
} else {
return false;
}
} else {
return false;
}
}
开发者ID:danielcoats,项目名称:schoolpress,代码行数:31,代码来源:functions.php
示例2: attributes_metabox_save
/**
* Pass the forum attributes for processing
*
* @since bbPress (r2746)
*
* @param int $forum_id Forum id
* @uses current_user_can() To check if the current user is capable of
* editing the forum
* @uses bbp_get_forum() To get the forum
* @uses bbp_is_forum_closed() To check if the forum is closed
* @uses bbp_is_forum_category() To check if the forum is a category
* @uses bbp_is_forum_private() To check if the forum is private
* @uses bbp_close_forum() To close the forum
* @uses bbp_open_forum() To open the forum
* @uses bbp_categorize_forum() To make the forum a category
* @uses bbp_normalize_forum() To make the forum normal (not category)
* @uses bbp_privatize_forum() To mark the forum as private
* @uses bbp_publicize_forum() To mark the forum as public
* @uses do_action() Calls 'bbp_forum_attributes_metabox_save' with the
* forum id
* @return int Forum id
*/
public function attributes_metabox_save($forum_id)
{
if ($this->bail()) {
return $forum_id;
}
// Bail if doing an autosave
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $forum_id;
}
// Bail if not a post request
if ('POST' != strtoupper($_SERVER['REQUEST_METHOD'])) {
return $forum_id;
}
// Nonce check
if (empty($_POST['bbp_forum_metabox']) || !wp_verify_nonce($_POST['bbp_forum_metabox'], 'bbp_forum_metabox_save')) {
return $forum_id;
}
// Only save for forum post-types
if (!bbp_is_forum($forum_id)) {
return $forum_id;
}
// Bail if current user cannot edit this forum
if (!current_user_can('edit_forum', $forum_id)) {
return $forum_id;
}
// Parent ID
$parent_id = !empty($_POST['parent_id']) && is_numeric($_POST['parent_id']) ? (int) $_POST['parent_id'] : 0;
// Update the forum meta bidness
bbp_update_forum(array('forum_id' => $forum_id, 'post_parent' => (int) $parent_id));
do_action('bbp_forum_attributes_metabox_save', $forum_id);
return $forum_id;
}
开发者ID:hscale,项目名称:webento,代码行数:54,代码来源:bbp-forums.php
示例3: bp_forums_root_slug
/<?php
echo bp_forums_root_slug();
?>
/" title="<?php
_e('Forums', 'framemarket');
?>
"><?php
_e('Forums', 'framemarket');
?>
</a>
</li>
<?php
} elseif (function_exists('bbpress')) {
?>
<li<?php
if (bbp_is_forum($post->ID) || bbp_is_topic($post->ID)) {
?>
class="selected"<?php
}
?>
>
<a href="<?php
bbp_forums_url();
?>
"><?php
_e('Forums', 'framemarket');
?>
</a>
</li>
<?php
}
开发者ID:JeffreyBue,项目名称:jb,代码行数:31,代码来源:header.php
示例4: bbp_is_forum_visibility
/**
* Check the forum visibility ID
*
* @since 2.6.0 bbPress (r5499)
*
* @param int $forum_id Optional. Forum id
* @param bool $status_name The post status name to check
* @param bool $check_ancestors Check the forum ancestors
* @param string $operator The logical operation to perform.
* 'OR' means only one forum from the tree needs to match;
* 'AND' means all forums must match. The default is 'AND'.
* @uses bbp_get_forum_id() To get the forum ID
* @uses bbp_get_forum_visibility() To get the forum visibility
* @uses bbp_get_forum_ancestors() To get the forum ancestors
* @uses bbp_is_forum() To check the post type
* @return bool True if match, false if not
*/
function bbp_is_forum_visibility($forum_id, $status_name, $check_ancestors = true, $operator = 'AND')
{
// Setup some default variables
$count = 0;
$retval = false;
$operator = strtoupper($operator);
$forum_id = bbp_get_forum_id($forum_id);
$visibility = bbp_get_forum_visibility($forum_id);
// Quickly compare visibility of first forum ID
if ($status_name === $visibility) {
$retval = true;
$count++;
}
// Let's check the forum's ancestors too
if (!empty($check_ancestors)) {
// Adjust the ancestor check based on the count
switch ($operator) {
// Adjust the ancestor check based on the count
default:
case 'AND':
$check_ancestors = $count > 0;
break;
case 'OR':
$check_ancestors = $count < 1;
break;
}
// Ancestor check passed, so continue looping through them
if (!empty($check_ancestors)) {
// Loop through the forum ancestors
foreach ((array) bbp_get_forum_ancestors($forum_id) as $ancestor) {
// Check if the forum is not a category
if (bbp_is_forum($ancestor)) {
// Check the forum visibility
$retval = bbp_is_forum_visibility($ancestor, $status_name, false);
if (true === $retval) {
$count++;
}
}
// Break when it reach the max count
if ($operator === 'OR' && $count >= 1) {
break;
}
}
}
}
// Filter and return
return (bool) apply_filters('bbp_is_forum_visibility', $retval, $count, $forum_id, $status_name, $check_ancestors, $operator);
}
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:65,代码来源:template.php
示例5: InBBPressPage
public function InBBPressPage()
{
if (!$this->IsBBPressInstalled()) {
return false;
}
if (!isset($this->_inBBPress)) {
$this->_inBBPress = false;
if (function_exists('bbp_is_forum')) {
// $this->_inBBPress = $this->_inBBPress || ('' !== bb_get_location());
$this->_inBBPress = $this->_inBBPress || bbp_is_forum(get_the_ID());
$this->_inBBPress = $this->_inBBPress || bbp_is_single_user();
}
if (RWLogger::IsOn()) {
RWLogger::Log('InBBPressPage', $this->_inBuddyPress ? 'TRUE' : 'FALSE');
}
}
return $this->_inBBPress;
}
开发者ID:robertoAg,项目名称:wordpress_humor,代码行数:18,代码来源:rating-widget.php
示例6: meta_params
public static function meta_params($forum_id, $admin = false)
{
if (!bbp_is_forum($forum_id)) {
return array();
}
$meta_params = get_post_meta($forum_id, 'bbpmeta_params', false);
if (empty($meta_params)) {
return array();
}
uasort($meta_params, array(__CLASS__, 'meta_order'));
return $meta_params;
return self::bbpmeta_order($forum_id, $meta_params);
}
开发者ID:082net,项目名称:bbpresskr,代码行数:13,代码来源:core.php
示例7: template_no_access
public static function template_no_access($template)
{
global $wp_query, $post;
$check_perm = false;
if (bbp_is_single_user_edit() || bbp_is_single_user()) {
} elseif (bbp_is_forum_archive()) {
} elseif (bbp_is_forum_edit()) {
$forum_id = bbp_get_forum_id();
if (bbp_is_forum($forum_id) && !bbp_user_can_view_forum(array('forum_id' => $forum_id)) && !bbp_is_forum_private($forum_id, false)) {
$check_perm = true;
}
} elseif (bbp_is_single_forum()) {
$forum_id = bbp_get_forum_id();
if (bbp_is_forum($forum_id) && !bbp_user_can_view_forum(array('forum_id' => $forum_id)) && !bbp_is_forum_private($forum_id, false)) {
$check_perm = true;
}
} elseif (bbp_is_topic_archive()) {
} elseif (bbp_is_topic_edit() || bbp_is_single_topic()) {
$check_perm = true;
} elseif (is_post_type_archive(bbp_get_reply_post_type())) {
} elseif (bbp_is_reply_edit() || bbp_is_single_reply()) {
$check_perm = true;
} elseif (bbp_is_single_view()) {
} elseif (bbp_is_search()) {
} elseif (bbp_is_topic_tag_edit() || bbp_is_topic_tag()) {
}
if ($check_perm && empty($post->post_content)) {
$user_id = get_current_user_id();
$forum_id = bbp_get_forum_id();
if (!self::view_forum(false, $forum_id, $user_id)) {
ob_start();
bbp_get_template_part('feedback', 'no-access');
$content = ob_get_clean();
$post->post_content = "\n{$content}\n";
$wp_query->post = $post;
$wp_query->posts = array($post);
}
}
return $template;
}
开发者ID:082net,项目名称:bbpresskr,代码行数:40,代码来源:permissions.php
示例8: bbp_untrashed_forum
/**
* Called after untrashing a forum
*
* @since bbPress (r3668)
* @uses bbp_get_forum_id() To get the forum id
* @uses bbp_is_forum() To check if the passed id is a forum
* @uses do_action() Calls 'bbp_untrashed_forum' with the forum id
*/
function bbp_untrashed_forum($forum_id = 0)
{
$forum_id = bbp_get_forum_id($forum_id);
if (empty($forum_id) || !bbp_is_forum($forum_id)) {
return false;
}
do_action('bbp_untrashed_forum', $forum_id);
}
开发者ID:jenia-buianov,项目名称:all_my_sites,代码行数:16,代码来源:functions.php
示例9: display_forum
/**
* Display the contents of a specific forum ID in an output buffer
* and return to ensure that post/page contents are displayed first.
*
* @since bbPress (r3031)
*
* @param array $attr
* @param string $content
* @uses get_template_part()
* @uses bbp_single_forum_description()
* @return string
*/
public function display_forum($attr, $content = '')
{
// Sanity check required info
if (!empty($content) || (empty($attr['id']) || !is_numeric($attr['id']))) {
return $content;
}
// Set passed attribute to $forum_id for clarity
$forum_id = bbpress()->current_forum_id = $attr['id'];
// Bail if ID passed is not a forum
if (!bbp_is_forum($forum_id)) {
return $content;
}
// Start output buffer
$this->start('bbp_single_forum');
// Check forum caps
if (bbp_user_can_view_forum(array('forum_id' => $forum_id))) {
bbp_get_template_part('content', 'single-forum');
// Forum is private and user does not have caps
} elseif (bbp_is_forum_private($forum_id, false)) {
bbp_get_template_part('feedback', 'no-access');
}
// Return contents of output buffer
return $this->end();
}
开发者ID:hscale,项目名称:webento,代码行数:36,代码来源:shortcodes.php
示例10: user_has_cap
public static function user_has_cap($allcaps, $caps, $args, $user)
{
if (!in_array('upload_files', $caps)) {
return $allcaps;
}
$can = isset($allcaps['upload_files']) ? $allcaps['upload_files'] : false;
// async-upload.php, admin-ajax.php 를 통해서 업로드할 때 권한 체크가 어려움
$ajax_attachment_actions = apply_filters('bbpkr_ajax_attachment_actions', array('upload-attachment', 'query-attachments'));
if ((isset($_REQUEST['post_id']) || !empty(self::$forum_id)) && empty($allcaps['upload_files']) && (defined('DOING_AJAX') && true === DOING_AJAX) && (isset($_REQUEST['action']) && in_array($_REQUEST['action'], $ajax_attachment_actions))) {
if (isset($_REQUEST['post_id'])) {
$the_id = (int) $_REQUEST['post_id'];
if (bbp_is_forum($the_id)) {
self::$forum_id = $the_id;
} elseif (bbp_is_topic($the_id)) {
self::$forum_id = (int) bbp_get_topic_forum_id($the_id);
} elseif (bbp_is_reply($the_id)) {
self::$forum_id = (int) bbp_get_reply_forum_id($the_id);
}
}
if (!self::$forum_id) {
return $allcaps;
}
$forum_id = self::$forum_id;
// unset post_id to avoid edit_post check( DO NOT UNSET $_POST['post_id'] )
$_REQUEST['post_id'] = null;
$allcaps['upload_files'] = self::can_upload($can, $forum_id);
return $allcaps;
}
$allcaps['upload_files'] = self::can_upload($can);
return $allcaps;
}
开发者ID:082net,项目名称:bbpresskr,代码行数:31,代码来源:attachments.php
示例11: bbp_update_reply_walker
/**
* Walk up the ancestor tree from the current reply, and update all the counts
*
* @since 2.0.0 bbPress (r2884)
*
* @param int $reply_id Optional. Reply id
* @param string $last_active_time Optional. Last active time
* @param int $forum_id Optional. Forum id
* @param int $topic_id Optional. Topic id
* @param bool $refresh If set to true, unsets all the previous parameters.
* Defaults to true
* @uses bbp_get_reply_id() To get the reply id
* @uses bbp_get_reply_topic_id() To get the reply topic id
* @uses bbp_get_reply_forum_id() To get the reply forum id
* @uses get_post_ancestors() To get the ancestors of the reply
* @uses bbp_is_reply() To check if the ancestor is a reply
* @uses bbp_is_topic() To check if the ancestor is a topic
* @uses bbp_update_topic_last_reply_id() To update the topic last reply id
* @uses bbp_update_topic_last_active_id() To update the topic last active id
* @uses bbp_get_topic_last_active_id() To get the topic last active id
* @uses get_post_field() To get the post date of the last active id
* @uses bbp_update_topic_last_active_time() To update the last active topic meta
* @uses bbp_update_topic_voice_count() To update the topic voice count
* @uses bbp_update_topic_reply_count() To update the topic reply count
* @uses bbp_update_topic_reply_count_hidden() To update the topic hidden reply
* count
* @uses bbp_is_forum() To check if the ancestor is a forum
* @uses bbp_update_forum_last_topic_id() To update the last topic id forum meta
* @uses bbp_update_forum_last_reply_id() To update the last reply id forum meta
* @uses bbp_update_forum_last_active_id() To update the forum last active id
* @uses bbp_get_forum_last_active_id() To get the forum last active id
* @uses bbp_update_forum_last_active_time() To update the forum last active time
* @uses bbp_update_forum_reply_count() To update the forum reply count
*/
function bbp_update_reply_walker($reply_id, $last_active_time = '', $forum_id = 0, $topic_id = 0, $refresh = true)
{
// Verify the reply ID
$reply_id = bbp_get_reply_id($reply_id);
// Reply was passed
if (!empty($reply_id)) {
// Get the topic ID if none was passed
if (empty($topic_id)) {
$topic_id = bbp_get_reply_topic_id($reply_id);
// Make every effort to get topic id
// https://bbpress.trac.wordpress.org/ticket/2529
if (empty($topic_id) && current_filter() === 'bbp_deleted_reply') {
$topic_id = get_post_field('post_parent', $reply_id);
}
}
// Get the forum ID if none was passed
if (empty($forum_id)) {
$forum_id = bbp_get_reply_forum_id($reply_id);
}
}
// Set the active_id based on topic_id/reply_id
$active_id = empty($reply_id) ? $topic_id : $reply_id;
// Setup ancestors array to walk up
$ancestors = array_values(array_unique(array_merge(array($topic_id, $forum_id), (array) get_post_ancestors($topic_id))));
// If we want a full refresh, unset any of the possibly passed variables
if (true === $refresh) {
$forum_id = $topic_id = $reply_id = $active_id = $last_active_time = 0;
}
// Walk up ancestors
if (!empty($ancestors)) {
foreach ($ancestors as $ancestor) {
// Reply meta relating to most recent reply
if (bbp_is_reply($ancestor)) {
// @todo - hierarchical replies
// Topic meta relating to most recent reply
} elseif (bbp_is_topic($ancestor)) {
// Last reply and active ID's
bbp_update_topic_last_reply_id($ancestor, $reply_id);
bbp_update_topic_last_active_id($ancestor, $active_id);
// Get the last active time if none was passed
$topic_last_active_time = $last_active_time;
if (empty($last_active_time)) {
$topic_last_active_time = get_post_field('post_date', bbp_get_topic_last_active_id($ancestor));
}
// Update the topic last active time regardless of reply status.
// See https://bbpress.trac.wordpress.org/ticket/2838
bbp_update_topic_last_active_time($ancestor, $topic_last_active_time);
// Counts
bbp_update_topic_voice_count($ancestor);
// Only update reply count if we're deleting a reply, or in the dashboard.
if (in_array(current_filter(), array('bbp_deleted_reply', 'save_post'), true)) {
bbp_update_topic_reply_count($ancestor);
bbp_update_topic_reply_count_hidden($ancestor);
}
// Forum meta relating to most recent topic
} elseif (bbp_is_forum($ancestor)) {
// Last topic and reply ID's
bbp_update_forum_last_topic_id($ancestor, $topic_id);
bbp_update_forum_last_reply_id($ancestor, $reply_id);
// Last Active
bbp_update_forum_last_active_id($ancestor, $active_id);
// Get the last active time if none was passed
$forum_last_active_time = $last_active_time;
if (empty($last_active_time)) {
$forum_last_active_time = get_post_field('post_date', bbp_get_forum_last_active_id($ancestor));
}
//.........这里部分代码省略.........
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:101,代码来源:functions.php
示例12: bbp_get_moderator_forum_ids
/**
* Get forums of a moderator
*
* @since 2.6.0 bbPress (r5834)
*
* @param int $user_id User id.
* @uses get_userdata() To get the user object
* @uses bbp_get_forum_mod_tax_id() To get the forum moderator taxonomy
* @uses bbp_get_user_taxonomy_term_id() To get the user taxonomy term id
* @uses get_term_by() To get the term id
* @uses get_objects_in_term() Get the forums the user moderates
* @uses is_wp_error() To check for errors
* @uses bbp_is_forum() To make sure the objects are forums
*
* @return boolean|array Return false on error or empty, or array of forum ids
*/
function bbp_get_moderator_forum_ids($user_id = 0)
{
// Bail if no user ID.
$user_id = bbp_get_user_id($user_id);
if (empty($user_id)) {
return false;
}
// Bail if user does not exist.
$user = get_userdata($user_id);
if (empty($user)) {
return false;
}
// Convert user id to term id.
$taxonomy = bbp_get_forum_mod_tax_id();
$term_id = bbp_get_user_taxonomy_term_id($user_id, $taxonomy);
// Get moderator forums.
$forums = get_objects_in_term($term_id, $taxonomy);
// Forums found.
if (empty($forums) || is_wp_error($forums)) {
return false;
}
// Make sure the ids returned are forums.
$forum_ids = array();
foreach ($forums as $forum_id) {
if (bbp_is_forum($forum_id)) {
$forum_ids[] = $forum_id;
}
}
// Remove empties
$retval = wp_parse_id_list(array_filter($forum_ids));
// Filter & return
return apply_filters('bbp_get_moderator_forum_ids', $retval, $user_id);
}
开发者ID:joeyblake,项目名称:bbpress,代码行数:49,代码来源:capabilities.php
示例13: display_topic_form
/**
* Display the topic form in an output buffer and return to ensure
* post/page contents are displayed first.
*
* Supports 'forum_id' attribute to display the topic form for a particular
* forum. This currently has styling issues from not being wrapped in
* <div id="bbpress-forums"></div> which will need to be sorted out later.
*
* @since bbPress (r3031)
*
* @param array $attr
* @param string $content
* @uses get_template_part()
* @return string
*/
public function display_topic_form($attr = array(), $content = '')
{
// Sanity check supplied info
if (!empty($content) || !empty($attr['forum_id']) && (!is_numeric($attr['forum_id']) || !bbp_is_forum($attr['forum_id']))) {
return $content;
}
// Unset globals
$this->unset_globals();
// If forum id is set, use the 'bbp_single_forum' query name
if (!empty($attr['forum_id'])) {
// Set the global current_forum_id for future requests
bbpress()->current_forum_id = $forum_id = bbp_get_forum_id($attr['forum_id']);
// Start output buffer
$this->start('bbp_single_forum');
// No forum id was passed
} else {
// Set the $forum_id variable to satisfy checks below
$forum_id = 0;
// Start output buffer
$this->start('bbp_topic_form');
}
// If the forum id is set, check forum caps else display normal topic form
if (empty($forum_id) || bbp_user_can_view_forum(array('forum_id' => $forum_id))) {
bbp_get_template_part('form', 'topic');
// Forum is private and user does not have caps
} elseif (bbp_is_forum_private($forum_id, false)) {
bbp_get_template_part('feedback', 'no-access');
}
// Return contents of output buffer
return $this->end();
}
开发者ID:danielcoats,项目名称:schoolpress,代码行数:46,代码来源:shortcodes.php
示例14: test_bbp_insert_forum
/**
* @group canonical
* @covers ::bbp_insert_forum
*/
public function test_bbp_insert_forum()
{
$c = $this->factory->forum->create(array('post_title' => 'Category 1', 'post_content' => 'Content of Category 1', 'forum_meta' => array('forum_type' => 'category', 'status' => 'open')));
$f = $this->factory->forum->create(array('post_title' => 'Forum 1', 'post_content' => 'Content of Forum 1', 'post_parent' => $c, 'forum_meta' => array('forum_id' => $c, 'forum_type' => 'forum', 'status' => 'open')));
$now = time();
$post_date = date('Y-m-d H:i:s', $now - 60 * 60 * 100);
$t = $this->factory->topic->create(array('post_parent' => $f, 'post_date' => $post_date, 'topic_meta' => array('forum_id' => $f)));
$r = $this->factory->reply->create(array('post_parent' => $t, 'post_date' => $post_date, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
// Get the category.
$category = bbp_get_forum($c);
// Get the forum.
$forum = bbp_get_forum($f);
// Category post.
$this->assertSame('Category 1', bbp_get_forum_title($c));
$this->assertSame('Content of Category 1', bbp_get_forum_content($c));
$this->assertSame('open', bbp_get_forum_status($c));
$this->assertSame('category', bbp_get_forum_type($c));
$this->assertTrue(bbp_is_forum($c));
$this->assertTrue(bbp_is_forum_category($c));
$this->assertTrue(bbp_is_forum_open($c));
$this->assertTrue(bbp_is_forum_public($c));
$this->assertFalse(bbp_is_forum_closed($c));
$this->assertFalse(bbp_is_forum_hidden($c));
$this->assertFalse(bbp_is_forum_private($c));
$this->assertSame(0, bbp_get_forum_parent_id($c));
$this->assertEquals('http://' . WP_TESTS_DOMAIN . '/?forum=' . $category->post_name, $category->guid);
// Forum post.
$this->assertSame('Forum 1', bbp_get_forum_title($f));
$this->assertSame('Content of Forum 1', bbp_get_forum_content($f));
$this->assertSame('open', bbp_get_forum_status($f));
$this->assertSame('forum', bbp_get_forum_type($f));
$this->assertTrue(bbp_is_forum($f));
$this->assertTrue(bbp_is_forum_open($f));
$this->assertTrue(bbp_is_forum_public($f));
$this->assertFalse(bbp_is_forum_closed($f));
$this->assertFalse(bbp_is_forum_hidden($f));
$this->assertFalse(bbp_is_forum_private($f));
$this->assertSame($c, bbp_get_forum_parent_id($f));
$this->assertEquals('http://' . WP_TESTS_DOMAIN . '/?forum=' . $category->post_name . '/' . $forum->post_name, $forum->guid);
// Category meta.
$this->assertSame(1, bbp_get_forum_subforum_count($c, true));
$this->assertSame(0, bbp_get_forum_topic_count($c, false, true));
$this->assertSame(1, bbp_get_forum_topic_count($c, true, true));
$this->assertSame(0, bbp_get_forum_topic_count_hidden($c, true));
$this->assertSame(0, bbp_get_forum_reply_count($c, false, true));
$this->assertSame(1, bbp_get_forum_reply_count($c, true, true));
$this->assertSame(0, bbp_get_forum_post_count($c, false, true));
$this->assertSame(2, bbp_get_forum_post_count($c, true, true));
$this->assertSame($t, bbp_get_forum_last_topic_id($c));
$this->assertSame($r, bbp_get_forum_last_reply_id($c));
$this->assertSame($r, bbp_get_forum_last_active_id($c));
$this->assertSame('4 days, 4 hours ago', bbp_get_forum_last_active_time($c));
// Forum meta.
$this->assertSame(0, bbp_get_forum_subforum_count($f, true));
$this->assertSame(1, bbp_get_forum_topic_count($f, false, true));
$this->assertSame(1, bbp_get_forum_topic_count($f, true, true));
$this->assertSame(0, bbp_get_forum_topic_count_hidden($f, true));
$this->assertSame(1, bbp_get_forum_reply_count($f, false, true));
$this->assertSame(1, bbp_get_forum_reply_count($f, true, true));
$this->assertSame(2, bbp_get_forum_post_count($f, false, true));
$this->assertSame(2, bbp_get_forum_post_count($f, true, true));
$this->assertSame($t, bbp_get_forum_last_topic_id($f));
$this->assertSame($r, bbp_get_forum_last_reply_id($f));
$this->assertSame($r, bbp_get_forum_last_active_id($f));
$this->assertSame('4 days, 4 hours ago', bbp_get_forum_last_active_time($f));
}
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:70,代码来源:forum.php
示例15: bbp_is_forum_hidden
/**
* Is the forum hidden?
*
* @since bbPress (r2997)
*
* @param int $forum_id Optional. Forum id
* @param bool $check_ancestors Check if the ancestors are private (only if
* they're a category)
* @uses get_post_meta() To get the forum private meta
* @uses bbp_get_forum_ancestors() To get the forum ancestors
* @uses bbp_is_forum_category() To check if the forum is a category
* @uses bbp_is_forum_closed() To check if the forum is closed
* @return bool True if closed, false if not
*/
function bbp_is_forum_hidden($forum_id = 0, $check_ancestors = true)
{
$forum_id = bbp_get_forum_id($forum_id);
$visibility = bbp_get_forum_visibility($forum_id);
// If post status is private, return true
$retval = bbp_get_hidden_status_id() == $visibility;
// Check ancestors and inherit their privacy setting for display
if (!empty($check_ancestors)) {
$ancestors = bbp_get_forum_ancestors($forum_id);
foreach ((array) $ancestors as $ancestor) {
if (bbp_is_forum($ancestor) && bbp_is_forum_hidden($ancestor, false)) {
$retval = true;
}
}
}
return (bool) apply_filters('bbp_is_forum_hidden', (bool) $retval, $forum_id, $check_ancestors);
}
开发者ID:hscale,项目名称:webento,代码行数:31,代码来源:bbp-forum-template.php
示例16: bbp_update_reply_walker
/**
* Walk up the ancestor tree from the current reply, and update all the counts
*
* @since bbPress (r2884)
*
* @param int $reply_id Optional. Reply id
* @param string $last_active_time Optional. Last active time
* @param int $forum_id Optional. Forum id
* @param int $topic_id Optional. Topic id
* @param bool $refresh If set to true, unsets all the previous parameters.
* Defaults to true
* @uses bbp_get_reply_id() To get the reply id
* @uses bbp_get_reply_topic_id() To get the reply topic id
* @uses bbp_get_reply_forum_id() To get the reply forum id
* @uses get_post_ancestors() To get the ancestors of the reply
* @uses bbp_is_reply() To check if the ancestor is a reply
* @uses bbp_is_topic() To check if the ancestor is a topic
* @uses bbp_update_topic_last_reply_id() To update the topic last reply id
* @uses bbp_update_topic_last_active_id() To update the topic last active id
* @uses bbp_get_topic_last_active_id() To get the topic last active id
* @uses get_post_field() To get the post date of the last active id
* @uses bbp_update_topic_last_active_time() To update the last active topic meta
* @uses bbp_update_topic_voice_count() To update the topic voice count
* @uses bbp_update_topic_reply_count() To update the topic reply count
* @uses bbp_update_topic_reply_count_hidden() To update the topic hidden reply
* count
* @uses bbp_is_forum() To check if the ancestor is a forum
* @uses bbp_update_forum_last_topic_id() To update the last topic id forum meta
* @uses bbp_update_forum_last_reply_id() To update the last reply id forum meta
* @uses bbp_update_forum_last_active_id() To update the forum last active id
* @uses bbp_get_forum_last_active_id() To get the forum last active id
* @uses bbp_update_forum_last_active_time() To update the forum last active time
* @uses bbp_update_forum_reply_count() To update the forum reply count
*/
function bbp_update_reply_walker($reply_id, $last_active_time = '', $forum_id = 0, $topic_id = 0, $refresh = true)
{
// Verify the reply ID
$reply_id = bbp_get_reply_id($reply_id);
// Reply was passed
if (!empty($reply_id)) {
// Get the topic ID if none was passed
if (empty($topic_id)) {
$topic_id = bbp_get_reply_topic_id($reply_id);
}
// Get the forum ID if none was passed
if (empty($forum_id)) {
$forum_id = bbp_get_reply_forum_id($reply_id);
}
}
// Set the active_id based on topic_id/reply_id
$active_id = empty($reply_id) ? $topic_id : $reply_id;
// Setup ancestors array to walk up
$ancestors = array_values(array_unique(array_merge(array($topic_id, $forum_id), (array) get_post_ancestors($topic_id))));
// If we want a full refresh, unset any of the possibly passed variables
if (true === $refresh) {
$forum_id = $topic_id = $reply_id = $active_id = $last_active_time = 0;
}
// Walk up ancestors
if (!empty($ancestors)) {
foreach ($ancestors as $ancestor) {
// Reply meta relating to most recent reply
if (bbp_is_reply($ancestor)) {
// @todo - hierarchical replies
// Topic meta relating to most recent reply
} elseif (bbp_is_topic($ancestor)) {
// Last reply and active ID's
bbp_update_topic_last_reply_id($ancestor, $reply_id);
bbp_update_topic_last_active_id($ancestor, $active_id);
// Get the last active time if none was passed
$topic_last_active_time = $last_active_time;
if (empty($last_active_time)) {
$topic_last_active_time = get_post_field('post_date', bbp_get_topic_last_active_id($ancestor));
}
// Only update if reply is published
if (bbp_is_reply_published($reply_id)) {
bbp_update_topic_last_active_time($ancestor, $topic_last_active_time);
}
// Counts
bbp_update_topic_voice_count($ancestor);
bbp_update_topic_reply_count($ancestor);
bbp_update_topic_reply_count_hidden($ancestor);
// Forum meta relating to most recent topic
} elseif (bbp_is_forum($ancestor)) {
// Last topic and reply ID's
bbp_update_forum_last_topic_id($ancestor, $topic_id);
bbp_update_forum_last_reply_id($ancestor, $reply_id);
// Last Active
bbp_update_forum_last_active_id($ancestor, $active_id);
// Get the last active time if none was passed
$forum_last_active_time = $last_active_time;
if (empty($last_active_time)) {
$forum_last_active_time = get_post_field('post_date', bbp_get_forum_last_active_id($ancestor));
}
// Only update if reply is published
if (bbp_is_reply_published($reply_id)) {
bbp_update_forum_last_active_time($ancestor, $forum_last_active_time);
}
// Counts
bbp_update_forum_reply_count($ancestor);
}
//.........这里部分代码省略.........
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:101,代码来源:functions.php
示例17: bbp_move_topic_handler
//.........这里部分代码省略.........
* @uses bbp_bump_forum_reply_count() To bump the forum reply count
* @uses bbp_increase_forum_topic_count() To bump the forum topic count by 1
* @uses bbp_decrease_forum_topic_count_hidden() To bump the forum topic hidden count by -1
* @uses bbp_increase_forum_topic_count_hidden() To bump the forum topic hidden count by 1
* @uses bbp_is_forum() To check if the ancestor is a forum
* @uses bbp_update_forum() To update the forum
*/
function bbp_move_topic_handler($topic_id, $old_forum_id, $new_forum_id)
{
// Validate parameters
$topic_id = bbp_get_topic_id($topic_id);
$old_forum_id = bbp_get_forum_id($old_forum_id);
$new_forum_id = bbp_get_forum_id($new_forum_id);
// Clean old and new forum caches before proceeding, to ensure subsequent
// calls to forum objects are using updated data.
bbp_clean_post_cache($old_forum_id);
bbp_clean_post_cache($new_forum_id);
// Update topic forum's ID
bbp_update_topic_forum_id($topic_id, $new_forum_id);
// Update topic post parent with the new forum ID
wp_update_post(array('ID' => $topic_id, 'post_parent' => $new_forum_id));
/** Stickies **************************************************************/
// Get forum stickies
$old_stickies = bbp_get_stickies($old_forum_id);
// Only proceed if stickies are found
if (!empty($old_stickies)) {
// Define local variables
$updated_stickies = array();
// Loop through stickies of forum and add misses to the updated array
foreach ((array) $old_stickies as $sticky_topic_id) {
if ($topic_id !== $sticky_topic_id) {
$updated_stickies[] = $sticky_topic_id;
}
}
// If stickies are different, update or delete them
if ($updated_stickies !== $old_stickies) {
// No more stickies so delete the meta
if (empty($updated_stickies)) {
delete_post_meta($old_forum_id, '_bbp_sticky_topics');
// Still stickies so update the meta
} else {
update_post_meta($old_forum_id, '_bbp_sticky_topics', $updated_stickies);
}
// Topic was sticky, so restick in new forum
bbp_stick_topic($topic_id);
}
}
/** Topic Replies *********************************************************/
// Get the topics replies
$replies = bbp_get_all_child_ids($topic_id, bbp_get_reply_post_type());
// Update the forum_id of all replies in the topic
foreach ($replies as $reply_id) {
bbp_update_reply_forum_id($reply_id, $new_forum_id);
}
/** Old forum_id **********************************************************/
// Get topic ancestors
$old_forum_ancestors = array_values(array_unique(array_merge(array($old_forum_id), (array) get_post_ancestors($old_forum_id))));
// Get reply count.
$public_reply_count = count(bbp_get_public_child_ids($topic_id, bbp_get_reply_post_type()));
// Topic status.
$topic_status = get_post_field('post_status', $topic_id);
// Update old/new forum counts.
if ($topic_status === bbp_get_public_status_id()) {
// Update old forum counts.
bbp_decrease_forum_topic_count($old_forum_id);
bbp_bump_forum_reply_count($old_forum_id, -$public_reply_count);
// Update new forum counts.
bbp_increase_forum_topic_count($new_forum_id);
bbp_bump_forum_reply_count($new_forum_id, $public_reply_count);
} else {
// Update old forum counts.
bbp_decrease_forum_topic_count_hidden($old_forum_id);
// Update new forum counts.
bbp_increase_forum_topic_count_hidden($new_forum_id);
}
// Loop through ancestors and update them
if (!empty($old_forum_ancestors)) {
foreach ($old_forum_ancestors as $ancestor) {
if (bbp_is_forum($ancestor)) {
bbp_update_forum(array('forum_id' => $ancestor));
}
}
}
/** New forum_id **********************************************************/
// Make sure we're not walking twice
if (!in_array($new_forum_id, $old_forum_ancestors)) {
// Get topic ancestors
$new_forum_ancestors = array_values(array_unique(array_merge(array($new_forum_id), (array) get_post_ancestors($new_forum_id))));
// Make sure we're not walking twice
$new_forum_ancestors = array_diff($new_forum_ancestors, $old_forum_ancestors);
// Loop through ancestors and update them
if (!empty($new_forum_ancestors)) {
foreach ($new_forum_ancestors as $ancestor) {
if (bbp_is_forum($ancestor)) {
bbp_update_forum(array('forum_id' => $ancestor));
}
}
}
}
}
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:101,代码来源:functions.php
示例18: bbp_move_topic_handler
/**
* Handle the moving of a topic from one forum to another. This includes walking
* up the old and new branches and updating the counts.
*
* @param int $topic_id Topic id
* @param int $old_forum_id Old forum id
* @param int $new_forum_id New forum id
* @uses bbp_get_topic_id() To get the topic id
* @uses bbp_get_forum_id() To get the forum id
* @uses bbp_get_stickies() To get the old forums sticky topics
* @uses delete_post_meta() To delete the forum sticky meta
* @uses update_post_meta() To update the old forum sticky meta
* @uses bbp_stick_topic() To stick the topic in the new forum
* @uses bbp_get_reply_post_type() To get the reply post type
* @uses bbp_get_all_child_ids() To get the public child ids
* @uses bbp_update_reply_forum_id() To update the reply forum id
* @uses bbp_update_topic_forum_id() To update the topic forum id
* @uses get_post_ancestors() To get the topic's ancestors
* @uses bbp_is_forum() To check if the ancestor is a forum
* @uses bbp_update_forum() To update the forum
*/
function bbp_move_topic_handler($topic_id, $old_forum_id, $new_forum_id)
{
// Validate parameters
$topic_id = bbp_get_topic_id($topic_id);
$old_forum_id = bbp_get_forum_id($old_forum_id);
$new_forum_id = bbp_get_forum_id($new_forum_id);
// Update topic forum's ID
bbp_update_topic_forum_id($topic_id, $new_forum_id);
/** Stickies **************************************************************/
// Get forum stickies
$old_stickies = bbp_get_stickies($old_forum_id);
// Only proceed if stickies are found
if (!empty($old_stickies)) {
// Define local variables
$updated_stickies = array();
// Loop through stickies of forum and add misses to the updated array
foreach ((array) $old_stickies as $sticky_topic_id) {
if ($topic_id !== $sticky_topic_id) {
$updated_stickies[] = $sticky_topic_id;
}
}
// If stickies are different, upda
|
请发表评论