本文整理汇总了PHP中bbp_is_topic函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_is_topic函数的具体用法?PHP bbp_is_topic怎么用?PHP bbp_is_topic使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bbp_is_topic函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: maybe_add_robots
function maybe_add_robots()
{
global $post;
if (is_singular() && bbp_is_topic($post->ID) && bbp_is_topic_closed($post->ID) && time() - get_post_time('U', true, $post) > YEAR_IN_SECONDS) {
echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
}
}
示例2: 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;
}
}
示例3: bbp_get_author_link
/**
* Return the author link of the post
*
* @since 2.0.0 bbPress (r2875)
*
* @param array $args Optional. If an integer, it is used as reply id.
* @uses bbp_is_topic() To check if it's a topic page
* @uses bbp_get_topic_author_link() To get the topic author link
* @uses bbp_is_reply() To check if it's a reply page
* @uses bbp_get_reply_author_link() To get the reply author link
* @uses get_post_field() To get the post author
* @uses bbp_is_reply_anonymous() To check if the reply is by an
* anonymous user
* @uses get_the_author_meta() To get the author name
* @uses bbp_get_user_profile_url() To get the author profile url
* @uses get_avatar() To get the author avatar
* @uses apply_filters() Calls 'bbp_get_reply_author_link' with the
* author link and args
* @return string Author link of reply
*/
function bbp_get_author_link($args = array())
{
$post_id = is_numeric($args) ? (int) $args : 0;
// Parse arguments against default values
$r = bbp_parse_args($args, array('post_id' => $post_id, 'link_title' => '', 'type' => 'both', 'size' => 80), 'get_author_link');
// Confirmed topic
if (bbp_is_topic($r['post_id'])) {
return bbp_get_topic_author_link($r);
// Confirmed reply
} elseif (bbp_is_reply($r['post_id'])) {
return bbp_get_reply_author_link($r);
}
// Get the post author and proceed
$user_id = get_post_field('post_author', $r['post_id']);
// Neither a reply nor a topic, so could be a revision
if (!empty($r['post_id'])) {
// Generate title with the display name of the author
if (empty($r['link_title'])) {
$r['link_title'] = sprintf(!bbp_is_reply_anonymous($r['post_id']) ? __('View %s\'s profile', 'bbpress') : __('Visit %s\'s website', 'bbpress'), get_the_author_meta('display_name', $user_id));
}
// Assemble some link bits
$link_title = !empty($r['link_title']) ? ' title="' . esc_attr($r['link_title']) . '"' : '';
$anonymous = bbp_is_reply_anonymous($r['post_id']);
// Declare empty array
$author_links = array();
// Get avatar
if ('avatar' === $r['type'] || 'both' === $r['type']) {
$author_links[] = get_avatar($user_id, $r['size']);
}
// Get display name
if ('name' === $r['type'] || 'both' === $r['type']) {
$author_links[] = esc_html(get_the_author_meta('display_name', $user_id));
}
// Add links if not anonymous
if (empty($anonymous) && bbp_user_has_profile($user_id)) {
$author_url = bbp_get_user_profile_url($user_id);
foreach ($author_links as $link_text) {
$author_link[] = sprintf('<a href="%1$s"%2$s>%3$s</a>', esc_url($author_url), $link_title, $link_text);
}
$author_link = implode(' ', $author_link);
// No links if anonymous
} else {
$author_link = implode(' ', $author_links);
}
// No post so link is empty
} else {
$author_link = '';
}
return apply_filters('bbp_get_author_link', $author_link, $r);
}
示例4: output_reply_notice
/**
* Ouput a notice on the front end when a reply has been reported
*
* @return null
*/
public function output_reply_notice()
{
global $post;
$reply_id = get_the_ID();
// If post is a topic, return. (handled with 'output_topic_notice')
if (bbp_is_topic($reply_id)) {
return;
}
if (!$this->is_reply_reported($reply_id)) {
return;
}
echo '<div class="error bbp-rc-reply-is-reported">';
echo '<p>';
echo apply_filters('bbp_rc_reply_notice', __('<em>This reply has been reported for inappropriate content.</em>', 'bbpress-report-content'));
echo '</p>';
echo '</div>';
}
示例5: get_post_ID
/**
* Get the Post ID
* Added support for sale of bbPress items.
* @since 1.3.3.2
* @version 1.0
*/
public function get_post_ID()
{
$post_id = $bbp_topic_id = $bbp_reply_id = 0;
if (function_exists('bbpress')) {
global $wp_query;
$bbp = bbpress();
// Currently inside a topic loop
if (!empty($bbp->topic_query->in_the_loop) && isset($bbp->topic_query->post->ID)) {
$bbp_topic_id = $bbp->topic_query->post->ID;
} elseif (!empty($bbp->search_query->in_the_loop) && isset($bbp->search_query->post->ID) && bbp_is_topic($bbp->search_query->post->ID)) {
$bbp_topic_id = $bbp->search_query->post->ID;
} elseif ((bbp_is_single_topic() || bbp_is_topic_edit()) && !empty($bbp->current_topic_id)) {
$bbp_topic_id = $bbp->current_topic_id;
} elseif ((bbp_is_single_topic() || bbp_is_topic_edit()) && isset($wp_query->post->ID)) {
$bbp_topic_id = $wp_query->post->ID;
}
// So far, no topic found, check if we are in a reply
if ($bbp_topic_id == 0) {
// Currently inside a replies loop
if (!empty($bbp->reply_query->in_the_loop) && isset($bbp->reply_query->post->ID)) {
$bbp_reply_id = $bbp->reply_query->post->ID;
} elseif (!empty($bbp->search_query->in_the_loop) && isset($bbp->search_query->post->ID) && bbp_is_reply($bbp->search_query->post->ID)) {
$bbp_reply_id = $bbp->search_query->post->ID;
} elseif ((bbp_is_single_reply() || bbp_is_reply_edit()) && !empty($bbp->current_reply_id)) {
$bbp_reply_id = $bbp->current_reply_id;
} elseif ((bbp_is_single_reply() || bbp_is_reply_edit()) && isset($wp_query->post->ID)) {
$bbp_reply_id = $wp_query->post->ID;
}
if ($bbp_reply_id != 0) {
$post_id = $bbp_reply_id;
}
} else {
$post_id = $bbp_topic_id;
}
}
if ($post_id == 0 && isset($GLOBALS['post'])) {
$post_id = $GLOBALS['post']->ID;
}
return apply_filters('mycred_sell_this_get_post_ID', $post_id, $this);
}
示例6: bbp_untrashed_topic
/**
* Called after untrashing a topic
*
* @uses bbp_get_topic_id() To get the topic id
* @uses bbp_is_topic() To check if the passed id is a topic
* @uses do_action() Calls 'bbp_untrashed_topic' with the topic id
*/
function bbp_untrashed_topic($topic_id = 0)
{
$topic_id = bbp_get_topic_id($topic_id);
if (empty($topic_id) || !bbp_is_topic($topic_id)) {
return false;
}
do_action('bbp_untrashed_topic', $topic_id);
}
示例7: 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);
}
示例8: 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);
}
//.........这里部分代码省略.........
示例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: 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;
}
示例12: 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));
}
//.........这里部分代码省略.........
示例13: bbp_reply_id
<?php
/**
* Replies Loop - Single Reply
*
* @package bbPress
* @subpackage Theme
*/
?>
<section id="post-<?php
bbp_reply_id();
?>
" class="bbp-reply">
<?php
if (!bbp_is_topic(bbp_get_reply_id())) {
?>
<header class="bbp-reply-header">
<div>
<hgroup class="bbp-reply-meta">
<ul>
<li class="bbp-reply-author">
<?php
do_action('bbp_theme_before_reply_author_details');
?>
<?php
bbp_reply_author_link(array('size' => 16, 'show_role' => true));
?>
<?php
do_action('bbp_theme_after_reply_author_details');
?>
示例14: pg_get_author_link
function pg_get_author_link()
{
$user_id2 = wp_get_current_user()->ID;
// Parse arguments against default values
$r = bbp_parse_args($args, array('post_id' => $post_id, 'link_title' => '', 'type' => 'both', 'size' => 14), 'pg_get_author_link');
//confirmed topic
if (bbp_is_topic($post_id)) {
$topic = bbp_get_topic_post_type();
$forum_id_check = private_groups_get_forum_id_from_post_id($post_id, $topic);
//now we can check if the user can view this
if (!private_groups_can_user_view_post($user_id2, $forum_id_check)) {
return;
}
return bbp_get_topic_author_link($r);
// Confirmed reply
} elseif (bbp_is_reply($post_id)) {
$reply = bbp_get_reply_post_type();
$forum_id_check = private_groups_get_forum_id_from_post_id($post_id, $reply);
//now we can check if the user can view this
if (!private_groups_can_user_view_post($user_id2, $forum_id_check)) {
return;
}
return bbp_get_reply_author_link($r);
}
// Neither a reply nor a topic, so could be a revision
//if it isn't a topic or reply, not sure so better to just not display the author in this case
//could be revised to look up the post_parent of this post and then churn that round the code above if required return ;
return;
}
示例15: 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
}