本文整理汇总了PHP中bbp_get_topic_id函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_get_topic_id函数的具体用法?PHP bbp_get_topic_id怎么用?PHP bbp_get_topic_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bbp_get_topic_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: td_bbp_change_avatar_size
function td_bbp_change_avatar_size($author_avatar, $topic_id, $size)
{
$author_avatar = '';
if ($size == 14) {
$size = 40;
}
$topic_id = bbp_get_topic_id($topic_id);
if (!empty($topic_id)) {
if (!bbp_is_topic_anonymous($topic_id)) {
$author_avatar = get_avatar(bbp_get_topic_author_id($topic_id), $size);
} else {
$author_avatar = get_avatar(get_post_meta($topic_id, '_bbp_anonymous_email', true), $size);
}
}
return $author_avatar;
}
示例2: get_views
static function get_views($topic_id = 0)
{
if (!($topic_id = bbp_get_topic_id($topic_id))) {
return 0;
}
return (int) get_post_meta($topic_id, 'topic_view_count', true);
}
示例3: test_bbp_get_topic_id
/**
* @covers ::bbp_topic_id
* @covers ::bbp_get_topic_id
*/
public function test_bbp_get_topic_id()
{
$f = $this->factory->forum->create();
$t = $this->factory->topic->create(array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f)));
$topic_id = bbp_get_topic_id($t);
$this->assertSame($t, $topic_id);
}
示例4: bbp_theme_before_topic_title
static function bbp_theme_before_topic_title()
{
$topic_id = bbp_get_topic_id();
if (post_password_required($topic_id)) {
_e('<span class="protected_title_format">Protected:</span> ', 'bbpresskr');
}
}
示例5: bbPress_submit
public function bbPress_submit()
{
$id = bbp_get_topic_id();
if (empty($id)) {
$id = bbp_get_forum_id();
}
$this->comments->Comment_form_action($id);
}
示例6: notify_on_reply
/**
* Send a notification to subscribers
*
* @wp-filter bbp_new_reply 1
*/
public function notify_on_reply($reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $reply_author = 0)
{
if ($this->handler === null) {
return false;
}
global $wpdb;
if (!bbp_is_subscriptions_active()) {
return false;
}
$reply_id = bbp_get_reply_id($reply_id);
$topic_id = bbp_get_topic_id($topic_id);
$forum_id = bbp_get_forum_id($forum_id);
if (!bbp_is_reply_published($reply_id)) {
return false;
}
if (!bbp_is_topic_published($topic_id)) {
return false;
}
$user_ids = bbp_get_topic_subscribers($topic_id, true);
if (empty($user_ids)) {
return false;
}
// Poster name
$reply_author_name = apply_filters('bbsub_reply_author_name', bbp_get_reply_author_display_name($reply_id));
do_action('bbp_pre_notify_subscribers', $reply_id, $topic_id, $user_ids);
// Don't send notifications to the person who made the post
$send_to_author = Falcon::get_option('bbsub_send_to_author', false);
if (!$send_to_author && !empty($reply_author)) {
$user_ids = array_filter($user_ids, function ($id) use($reply_author) {
return (int) $id !== (int) $reply_author;
});
}
// Get userdata for all users
$user_ids = array_map(function ($id) {
return get_userdata($id);
}, $user_ids);
// Sanitize the HTML into text
$content = apply_filters('bbsub_html_to_text', bbp_get_reply_content($reply_id));
// Build email
$text = "%1\$s\n\n";
$text .= "---\nReply to this email directly or view it online:\n%2\$s\n\n";
$text .= "You are receiving this email because you subscribed to it. Login and visit the topic to unsubscribe from these emails.";
$text = sprintf($text, $content, bbp_get_reply_url($reply_id));
$text = apply_filters('bbsub_email_message', $text, $reply_id, $topic_id, $content);
$subject = apply_filters('bbsub_email_subject', 'Re: [' . get_option('blogname') . '] ' . bbp_get_topic_title($topic_id), $reply_id, $topic_id);
$options = array('id' => $topic_id, 'author' => $reply_author_name);
$this->handler->send_mail($user_ids, $subject, $text, $options);
do_action('bbp_post_notify_subscribers', $reply_id, $topic_id, $user_ids);
return true;
}
示例7: d4p_is_bbpress
/**
* Check if the current page is forum, topic or other bbPress page.
*
* @return bool true if the current page is the forum related
*/
function d4p_is_bbpress()
{
$is = false;
if (function_exists("bbp_get_forum_id")) {
$is = bbp_get_forum_id() > 0 || bbp_get_reply_id() > 0 || bbp_get_topic_id() > 0;
if (!$is) {
global $template;
$templates = array("single-reply-edit.php", "single-topic-edit.php");
$file = pathinfo($template, PATHINFO_BASENAME);
$is = in_array($file, $templates);
}
}
return apply_filters('d4p_is_bbpress', $is);
}
示例8: change_freshness_topic
/**
* this function changes the bbp freshness data (time since) into a last post date for topics
*/
function change_freshness_topic($last_active, $topic_id)
{
$topic_id = bbp_get_topic_id($topic_id);
// Try to get the most accurate freshness time possible
$last_active = get_post_meta($topic_id, '_bbp_last_active_time', true);
if (empty($last_active)) {
$reply_id = bbp_get_topic_last_reply_id($topic_id);
if (!empty($reply_id)) {
$last_active = get_post_field('post_date', $reply_id);
} else {
$last_active = get_post_field('post_date', $topic_id);
}
}
$last_active = bbp_convert_date($last_active);
$date_format = get_option('date_format');
$time_format = get_option('time_format');
$date = date_i18n("{$date_format}", $last_active);
$time = date_i18n("{$time_format}", $last_active);
$active_time = sprintf(_x('%1$s, %2$s', 'date at time', 'bbp-last-post'), $date, $time);
return $active_time;
}
示例9: getTopicList
public function getTopicList()
{
if (is_null($_POST['param']) || empty($_POST['param'])) {
$this->_die();
}
$return = array();
$loadFrom = empty($_POST['param']['from']) ? 0 : $_POST['param']['from'];
$loadTo = empty($_POST['param']['to']) ? 0 : $_POST['param']['to'];
$param = array('post_parent' => $this->forumId);
if (!bbp_has_topics($param)) {
$this->_die();
}
while (bbp_topics()) {
bbp_the_topic();
$topicId = bbp_get_topic_id();
$topic = new ForumBbpAjaxIntegratorPost($topicId, 'topic');
$returnItem = $topic->getPostData();
$returnItem['replyList'] = $this->getReplyList($topicId);
$return[] = $returnItem;
}
wp_die(json_encode($return));
}
示例10: dont_show_form_if_resolved
public function dont_show_form_if_resolved($templates, $slug, $name)
{
if ($slug === 'form' && $name === 'reply') {
if (!function_exists('bbp_get_topic_id')) {
return $templates;
}
$topic_id = bbp_get_topic_id();
if ($topic_id && !current_user_can('moderate')) {
$status = get_post_meta($topic_id, '_bbps_topic_status', true);
if ($status) {
$value = intval($status);
} else {
$value = 1;
}
if ($value === 2 || $value === 3) {
$user_id = get_the_author_meta('ID');
if (get_current_user_id() !== $user_id) {
return array(0 => 'form-resolved.php', 1 => 'form.php');
}
}
}
}
return $templates;
}
示例11: bbp_template_include_theme_compat
/**
* Reset main query vars and filter 'the_content' to output a bbPress
* template part as needed.
*
* @since bbPress (r3032)
* @param string $template
* @uses bbp_is_single_user() To check if page is single user
* @uses bbp_get_single_user_template() To get user template
* @uses bbp_is_single_user_edit() To check if page is single user edit
* @uses bbp_get_single_user_edit_template() To get user edit template
* @uses bbp_is_single_view() To check if page is single view
* @uses bbp_get_single_view_template() To get view template
* @uses bbp_is_forum_edit() To check if page is forum edit
* @uses bbp_get_forum_edit_template() To get forum edit template
* @uses bbp_is_topic_merge() To check if page is topic merge
* @uses bbp_get_topic_merge_template() To get topic merge template
* @uses bbp_is_topic_split() To check if page is topic split
* @uses bbp_get_topic_split_template() To get topic split template
* @uses bbp_is_topic_edit() To check if page is topic edit
* @uses bbp_get_topic_edit_template() To get topic edit template
* @uses bbp_is_reply_edit() To check if page is reply edit
* @uses bbp_get_reply_edit_template() To get reply edit template
* @uses bbp_set_theme_compat_template() To set the global theme compat template
*/
function bbp_template_include_theme_compat($template = '')
{
// Bail if the template already matches a bbPress template. This includes
// archive-* and single-* WordPress post_type matches (allowing
// themes to use the expected format) as well as all bbPress-specific
// template files for users, topics, forums, etc...
if (!empty(bbpress()->theme_compat->bbpress_template)) {
return $template;
}
/** Users *************************************************************/
if (bbp_is_single_user_edit() || bbp_is_single_user()) {
// Reset post
bbp_theme_compat_reset_post(array('ID' => 0, 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => '', 'post_title' => esc_attr(bbp_get_displayed_user_field('display_name')), 'post_status' => bbp_get_public_status_id(), 'is_archive' => false, 'comment_status' => 'closed'));
/** Forums ************************************************************/
// Forum archive
} elseif (bbp_is_forum_archive()) {
// Reset post
bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => bbp_get_forum_archive_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_public_status_id(), 'is_archive' => true, 'comment_status' => 'closed'));
// Single Forum
} elseif (bbp_is_forum_edit() || bbp_is_single_forum()) {
// Reset post
bbp_theme_compat_reset_post(array('ID' => bbp_get_forum_id(), 'post_title' => bbp_get_forum_title(), 'post_author' => bbp_get_forum_author_id(), 'post_date' => 0, 'post_content' => get_post_field('post_content', bbp_get_forum_id()), 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_forum_visibility(), 'is_single' => true, 'comment_status' => 'closed'));
/** Topics ************************************************************/
// Topic archive
} elseif (bbp_is_topic_archive()) {
// Reset post
bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => bbp_get_topic_archive_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => bbp_get_topic_post_type(), 'post_status' => bbp_get_public_status_id(), 'is_archive' => true, 'comment_status' => 'closed'));
// Single Topic
} elseif (bbp_is_topic_edit() || bbp_is_single_topic()) {
// Reset post
bbp_theme_compat_reset_post(array('ID' => bbp_get_topic_id(), 'post_title' => bbp_get_topic_title(), 'post_author' => bbp_get_topic_author_id(), 'post_date' => 0, 'post_content' => get_post_field('post_content', bbp_get_topic_id()), 'post_type' => bbp_get_topic_post_type(), 'post_status' => bbp_get_topic_status(), 'is_single' => true, 'comment_status' => 'closed'));
/** Replies ***********************************************************/
// Reply archive
} elseif (is_post_type_archive(bbp_get_reply_post_type())) {
// Reset post
bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => __('Replies', 'bbpress'), 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed'));
// Single Reply
} elseif (bbp_is_reply_edit() || bbp_is_single_reply()) {
// Reset post
bbp_theme_compat_reset_post(array('ID' => bbp_get_reply_id(), 'post_title' => bbp_get_reply_title(), 'post_author' => bbp_get_reply_author_id(), 'post_date' => 0, 'post_content' => get_post_field('post_content', bbp_get_reply_id()), 'post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_reply_status(), 'comment_status' => 'closed'));
/** Views *************************************************************/
} elseif (bbp_is_single_view()) {
// Reset post
bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => bbp_get_view_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => '', 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed'));
/** Topic Tags ********************************************************/
// Topic Tag Edit
} elseif (bbp_is_topic_tag_edit() || bbp_is_topic_tag()) {
// Stash the current term in a new var
set_query_var('bbp_topic_tag', get_query_var('term'));
// Reset the post with our new title
bbp_theme_compat_reset_post(array('ID' => 0, 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => '', 'post_title' => sprintf(__('Topic Tag: %s', 'bbpress'), '<span>' . bbp_get_topic_tag_name() . '</span>'), 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed'));
}
/**
* If we are relying on bbPress's built in theme compatibility to load
* the proper content, we need to intercept the_content, replace the
* output, and display ours instead.
*
* To do this, we first remove all filters from 'the_content' and hook
* our own function into it, which runs a series of checks to determine
* the context, and then uses the built in shortcodes to output the
* correct results from inside an output buffer.
*
* Uses bbp_get_theme_compat_templates() to provide fall-backs that
* should be coded without superfluous mark-up and logic (prev/next
* navigation, comments, date/time, etc...)
*
* Hook into the 'bbp_get_bbpress_template' to override the array of
* possible templates, or 'bbp_bbpress_template' to override the result.
*/
if (bbp_is_theme_compat_active()) {
// Remove all filters from the_content
bbp_remove_all_filters('the_content');
// Add a filter on the_content late, which we will later remove
add_filter('the_content', 'bbp_replace_the_content');
// Find the appropriate template file
$template = bbp_get_theme_compat_templates();
//.........这里部分代码省略.........
示例12: bbp_get_reply_position_raw
/**
* Get the position of a reply by querying the DB directly for the replies
* of a given topic.
*
* @since bbPress (r3933)
*
* @param int $reply_id
* @param int $topic_id
*/
function bbp_get_reply_position_raw($reply_id = 0, $topic_id = 0)
{
// Get required data
$reply_id = bbp_get_reply_id($reply_id);
$topic_id = !empty($topic_id) ? bbp_get_topic_id($topic_id) : bbp_get_reply_topic_id($reply_id);
$reply_position = 0;
// If reply is actually the first post in a topic, return 0
if ($reply_id !== $topic_id) {
// Make sure the topic has replies before running another query
$reply_count = bbp_get_topic_reply_count($topic_id, false);
if (!empty($reply_count)) {
// Get reply id's
$topic_replies = bbp_get_all_child_ids($topic_id, bbp_get_reply_post_type());
if (!empty($topic_replies)) {
// Reverse replies array and search for current reply position
$topic_replies = array_reverse($topic_replies);
$reply_position = array_search((string) $reply_id, $topic_replies);
// Bump the position to compensate for the lead topic post
$reply_position++;
}
}
}
return (int) $reply_position;
}
示例13: edd_cr_hide_new_replies_form
/**
* Hides the new reply form
*
* @param bool $retval The current state of this permission check
* @global int $user_ID The ID of the current user
* @return mixed $return
*/
function edd_cr_hide_new_replies_form($retval)
{
global $user_ID;
if (!current_user_can('moderate') && bbp_current_user_can_publish_replies()) {
$restricted_to = edd_cr_is_restricted(bbp_get_topic_id());
$restricted_id = bbp_get_topic_id();
if (!$restricted_to) {
$restricted_to = edd_cr_is_restricted(bbp_get_forum_id());
// check for parent forum restriction
$restricted_id = bbp_get_forum_id();
if (!$restricted_to) {
$ancestors = array_reverse((array) get_post_ancestors(bbp_get_forum_id()));
if (!empty($ancestors)) {
// Loop through parents
foreach ((array) $ancestors as $parent_id) {
$restricted_to = edd_cr_is_restricted($parent_id);
if ($restricted_to) {
break;
}
}
}
}
}
$has_access = edd_cr_user_can_access($user_ID, $restricted_to);
if ($has_access['status']) {
$retval = true;
}
}
return $retval;
}
示例14: _e
<legend><?php
_e('Destination', 'bbpress');
?>
</legend>
<div>
<?php
if (bbp_has_topics(array('show_stickies' => false, 'post_parent' => bbp_get_topic_forum_id(bbp_get_topic_id()), 'post__not_in' => array(bbp_get_topic_id())))) {
?>
<label for="bbp_destination_topic"><?php
_e('Merge with this topic:', 'bbpress');
?>
</label>
<?php
bbp_dropdown(array('post_type' => bbp_get_topic_post_type(), 'post_parent' => bbp_get_topic_forum_id(bbp_get_topic_id()), 'selected' => -1, 'exclude' => bbp_get_topic_id(), 'select_id' => 'bbp_destination_topic'));
?>
<?php
} else {
?>
<label><?php
_e('There are no other topics in this forum to merge with.', 'bbpress');
?>
</label>
<?php
}
?>
示例15: printf
<?php
/**
* Move Reply
*
* @package bbPress
* @subpackage Theme
*/
?>
<div id="bbpress-forums">
<?php
if (is_user_logged_in() && current_user_can('edit_topic', bbp_get_topic_id())) {
?>
<div id="move-reply-<?php
bbp_topic_id();
?>
" class="bbp-reply-move">
<form id="move_reply" name="move_reply" method="post" action="<?php
the_permalink();
?>
">
<fieldset class="bbp-form">
<legend><?php
printf(__('Move reply "%s"', 'bbpress'), bbp_get_reply_title());
?>