本文整理汇总了PHP中bbp_get_reply_topic_id函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_get_reply_topic_id函数的具体用法?PHP bbp_get_reply_topic_id怎么用?PHP bbp_get_reply_topic_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bbp_get_reply_topic_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bbp_format_buddypress_notifications
/**
* Format the BuddyBar/Toolbar notifications
*
* @since 2.5.0 bbPress (r5155)
*
* @package bbPress
*
* @param string $action The kind of notification being rendered
* @param int $item_id The primary item id
* @param int $secondary_item_id The secondary item id
* @param int $total_items The total number of messaging-related notifications waiting for the user
* @param string $format 'string' for BuddyBar-compatible notifications; 'array' for WP Toolbar
*/
function bbp_format_buddypress_notifications($action, $item_id, $secondary_item_id, $total_items, $format = 'string')
{
// Bail if not the notification action we are looking for
if ('bbp_new_reply' !== $action) {
return $action;
}
// New reply notifications
$topic_id = bbp_get_reply_topic_id($item_id);
$topic_title = bbp_get_topic_title($topic_id);
$topic_link = wp_nonce_url(add_query_arg(array('action' => 'bbp_mark_read', 'topic_id' => $topic_id), bbp_get_reply_url($item_id)), 'bbp_mark_topic_' . $topic_id);
$title_attr = __('Topic Replies', 'bbpress');
if ((int) $total_items > 1) {
$text = sprintf(__('You have %d new replies', 'bbpress'), (int) $total_items);
$filter = 'bbp_multiple_new_subscription_notification';
} else {
if (!empty($secondary_item_id)) {
$text = sprintf(__('You have %d new reply to %2$s from %3$s', 'bbpress'), (int) $total_items, $topic_title, bp_core_get_user_displayname($secondary_item_id));
} else {
$text = sprintf(__('You have %d new reply to %s', 'bbpress'), (int) $total_items, $topic_title);
}
$filter = 'bbp_single_new_subscription_notification';
}
// WordPress Toolbar
if ('string' === $format) {
$return = apply_filters($filter, '<a href="' . esc_url($topic_link) . '" title="' . esc_attr($title_attr) . '">' . esc_html($text) . '</a>', (int) $total_items, $text, $topic_link);
// Deprecated BuddyBar
} else {
$return = apply_filters($filter, array('text' => $text, 'link' => $topic_link), $topic_link, (int) $total_items, $text, $topic_title);
}
do_action('bbp_format_buddypress_notifications', $action, $item_id, $secondary_item_id, $total_items);
return $return;
}
示例2: bbpvotes_buddypress_voted_activity
function bbpvotes_buddypress_voted_activity($post_id, $user_id, $vote)
{
//check vote value
if (is_bool($vote) === false) {
return new WP_Error('vote_is_not_bool', __('Vote is not a boolean', 'bbpvotes'));
}
$voteplus = $vote === true;
$voteminus = $vote === false;
$post = get_post($post_id);
$user_link = bbp_get_user_profile_link($user_id);
//build item link
if ($post->post_type == bbp_get_topic_post_type()) {
$topic_id = $post->ID;
$post_permalink = get_permalink($post->ID);
} elseif ($post->post_type == bbp_get_reply_post_type()) {
$topic_id = bbp_get_reply_topic_id($post->ID);
$post_permalink = bbp_get_reply_url($post->ID);
}
//topic infos
$topic = get_post($topic_id);
$topic_author_link = bbp_get_user_profile_link($topic->post_author);
$topic_title = $topic->post_title;
$post_link = '<a href="' . $post_permalink . '">' . $topic_title . '</a>';
if ($voteplus) {
$type = 'bbpvotes_voted_up';
if ($post->post_type == bbp_get_topic_post_type()) {
$action = sprintf(esc_html__('%1$s voted up to the topic %2$s by %3$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
} elseif ($post->post_type == bbp_get_reply_post_type()) {
$action = sprintf(esc_html__('%1$s voted up to a reply by %3$s in the topic %2$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
}
} else {
$type = 'bbpvotes_voted_down';
if ($post->post_type == bbp_get_topic_post_type()) {
$action = sprintf(esc_html__('%1$s voted down to the topic %2$s by %3$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
} elseif ($post->post_type == bbp_get_reply_post_type()) {
$action = sprintf(esc_html__('%1$s voted down to a reply by %3$s in the topic %2$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
}
}
$args = array('action' => $action, 'component' => 'bbpress', 'type' => $type, 'item_id' => $topic->ID);
if ($post->post_type == bbp_get_reply_post_type()) {
$args['secondary_item_id'] = $post->ID;
}
/*
if ($is_update){
$previous_activity_id =
$args['id'] = $previous_activity_id;
}
*/
bp_activity_add($args);
}
示例3: add_protected_meta
/**
* When inserting a new reply, make sure the protected meta data is set correctly.
*
* We can't use WP_JSON_Posts::add_meta() here because the required meta is deemed
* protected by @see is_protected_meta().
*
* @see WP_JSON_Posts::insert_post()
* @see WP_JSON_Posts::add_meta()
*/
public function add_protected_meta($post, $data, $update)
{
if (!$update && $this->type == $post['post_type']) {
// Forum meta
$reply_meta = array('author_ip' => bbp_current_author_ip(), 'forum_id' => bbp_get_topic_forum_id($post['post_parent']), 'topic_id' => $post['post_parent']);
// Insert reply meta
foreach ($reply_meta as $meta_key => $meta_value) {
update_post_meta($post['ID'], '_bbp_' . $meta_key, $meta_value);
}
// Update the topic
$topic_id = bbp_get_reply_topic_id($post['ID']);
if (!empty($topic_id)) {
bbp_update_topic($topic_id);
}
}
}
示例4: bbp_reply_metabox
/**
* Reply metabox
*
* The metabox that holds all of the additional reply information
*
* @since bbPress (r2464)
*
* @uses bbp_get_topic_post_type() To get the topic post type
* @uses bbp_dropdown() To show a dropdown of the topics for reply parent
* @uses do_action() Calls 'bbp_reply_metabox'
*/
function bbp_reply_metabox()
{
// Post ID
$post_id = get_the_ID();
// Get some meta
$reply_topic_id = bbp_get_reply_topic_id($post_id);
$reply_forum_id = bbp_get_reply_forum_id($post_id);
// Allow individual manipulation of reply forum
if (current_user_can('edit_others_replies') || current_user_can('moderate')) {
// Forums
$args = array('selected' => $reply_forum_id, 'select_id' => 'bbp_forum_id', 'show_none' => __('(Use Forum of Topic)', 'bbpress'));
?>
<p><strong><?php
_e('Forum', 'bbpress');
?>
</strong></p>
<p>
<label class="screen-reader-text" for="bbp_forum_id"><?php
_e('Forum', 'bbpress');
?>
</label>
<?php
bbp_dropdown($args);
?>
</p>
<?php
}
// Topics
$args = array('post_type' => bbp_get_topic_post_type(), 'selected' => $reply_topic_id, 'select_id' => 'parent_id', 'orderby' => 'post_date', 'numberposts' => '250', 'show_none' => is_super_admin() ? __('(No Topic)', 'bbpress') : '');
// Allow the dropdown to be filtered, to extend or limit the available
// topics to choose as the reply parent.
$args = apply_filters('bbp_reply_parent_dropdown', $args);
?>
<p><strong><?php
_e('Topic', 'bbpress');
?>
</strong></p>
<p>
<label class="screen-reader-text" for="parent_id"><?php
_e('Topic', 'bbpress');
?>
</label>
<?php
bbp_dropdown($args);
?>
</p>
<?php
wp_nonce_field('bbp_reply_metabox_save', 'bbp_reply_metabox');
do_action('bbp_reply_metabox', $post_id);
}
示例5: do_trail_items
/**
* Runs through the various bbPress conditional tags to check the current page being viewed. Once
* a condition is met, add items to the $items array.
*
* @since 0.6.0
* @access public
* @return void
*/
public function do_trail_items()
{
/* Add the network and site home links. */
$this->do_network_home_link();
$this->do_site_home_link();
/* Get the forum post type object. */
$post_type_object = get_post_type_object(bbp_get_forum_post_type());
/* If not viewing the forum root/archive page and a forum archive exists, add it. */
if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
$this->items[] = '<a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a>';
}
/* If viewing the forum root/archive. */
if (bbp_is_forum_archive()) {
if (true === $this->args['show_title']) {
$this->items[] = bbp_get_forum_archive_title();
}
} elseif (bbp_is_topic_archive()) {
if (true === $this->args['show_title']) {
$this->items[] = bbp_get_topic_archive_title();
}
} elseif (bbp_is_topic_tag()) {
if (true === $this->args['show_title']) {
$this->items[] = bbp_get_topic_tag_name();
}
} elseif (bbp_is_topic_tag_edit()) {
$this->items[] = '<a href="' . bbp_get_topic_tag_link() . '">' . bbp_get_topic_tag_name() . '</a>';
if (true === $this->args['show_title']) {
$this->items[] = __('Edit', 'breadcrumb-trail');
}
} elseif (bbp_is_single_view()) {
if (true === $this->args['show_title']) {
$this->items[] = bbp_get_view_title();
}
} elseif (bbp_is_single_topic()) {
/* Get the queried topic. */
$topic_id = get_queried_object_id();
/* Get the parent items for the topic, which would be its forum (and possibly forum grandparents). */
$this->do_post_parents(bbp_get_topic_forum_id($topic_id));
/* If viewing a split, merge, or edit topic page, show the link back to the topic. Else, display topic title. */
if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
$this->items[] = '<a href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
} elseif (true === $this->args['show_title']) {
$this->items[] = bbp_get_topic_title($topic_id);
}
/* If viewing a topic split page. */
if (bbp_is_topic_split() && true === $this->args['show_title']) {
$this->items[] = __('Split', 'breadcrumb-trail');
} elseif (bbp_is_topic_merge() && true === $this->args['show_title']) {
$this->items[] = __('Merge', 'breadcrumb-trail');
} elseif (bbp_is_topic_edit() && true === $this->args['show_title']) {
$this->items[] = __('Edit', 'breadcrumb-trail');
}
} elseif (bbp_is_single_reply()) {
/* Get the queried reply object ID. */
$reply_id = get_queried_object_id();
/* Get the parent items for the reply, which should be its topic. */
$this->do_post_parents(bbp_get_reply_topic_id($reply_id));
/* If viewing a reply edit page, link back to the reply. Else, display the reply title. */
if (bbp_is_reply_edit()) {
$this->items[] = '<a href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a>';
if (true === $this->args['show_title']) {
$this->items[] = __('Edit', 'breadcrumb-trail');
}
} elseif (true === $this->args['show_title']) {
$this->items[] = bbp_get_reply_title($reply_id);
}
} elseif (bbp_is_single_forum()) {
/* Get the queried forum ID and its parent forum ID. */
$forum_id = get_queried_object_id();
$forum_parent_id = bbp_get_forum_parent_id($forum_id);
/* If the forum has a parent forum, get its parent(s). */
if (0 !== $forum_parent_id) {
$this->do_post_parents($forum_parent_id);
}
/* Add the forum title to the end of the trail. */
if (true === $this->args['show_title']) {
$this->items[] = bbp_get_forum_title($forum_id);
}
} elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
if (bbp_is_single_user_edit()) {
$this->items[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a>';
if (true === $this->args['show_title']) {
$this->items[] = __('Edit', 'breadcrumb-trail');
}
} elseif (true === $this->args['show_title']) {
$this->items[] = bbp_get_displayed_user_field('display_name');
}
}
/* Return the bbPress breadcrumb trail items. */
$this->items = apply_filters('breadcrumb_trail_get_bbpress_items', $this->items, $this->args);
}
示例6: bbp_get_form_topic_tags
/**
* Return value of topic tags field
*
* @since 2.0.0 bbPress (r2976)
*
* @uses bbp_is_topic_edit() To check if it's the topic edit page
* @uses apply_filters() Calls 'bbp_get_form_topic_tags' with the tags
* @return string Value of topic tags field
*/
function bbp_get_form_topic_tags()
{
// Default return value
$topic_tags = '';
// Get _POST data
if ((bbp_is_topic_form_post_request() || bbp_is_reply_form_post_request()) && isset($_POST['bbp_topic_tags'])) {
$topic_tags = wp_unslash($_POST['bbp_topic_tags']);
// Get edit data
} elseif (bbp_is_single_topic() || bbp_is_single_reply() || bbp_is_topic_edit() || bbp_is_reply_edit()) {
// Determine the topic id based on the post type
switch (get_post_type()) {
// Post is a topic
case bbp_get_topic_post_type():
$topic_id = bbp_get_topic_id(get_the_ID());
break;
// Post is a reply
// Post is a reply
case bbp_get_reply_post_type():
$topic_id = bbp_get_reply_topic_id(get_the_ID());
break;
}
// Topic exists
if (!empty($topic_id)) {
// Topic is spammed so display pre-spam terms
if (bbp_is_topic_spam($topic_id)) {
// Get pre-spam terms
$spam_terms = get_post_meta($topic_id, '_bbp_spam_topic_tags', true);
$topic_tags = !empty($spam_terms) ? implode(', ', $spam_terms) : '';
// Topic is not spam so get real terms
} else {
$topic_tags = bbp_get_topic_tag_names($topic_id);
}
}
}
return apply_filters('bbp_get_form_topic_tags', $topic_tags);
}
示例7: bbp_update_topic_anonymous_reply_count
/**
* Adjust the total anonymous reply count of a topic
*
* @since bbPress (r2567)
*
* @param int $topic_id Optional. Topic id to update
* @uses bbp_is_reply() To check if the passed topic id is a reply
* @uses bbp_get_reply_topic_id() To get the reply topic id
* @uses bbp_get_topic_id() To get the topic id
* @uses bbp_get_reply_topic_id() To get the reply topic id
* @uses bbp_get_reply_post_type() To get the reply post type
* @uses bbp_get_topic_post_type() To get the topic post type
* @uses wpdb::prepare() To prepare our sql query
* @uses wpdb::get_col() To execute our query and get the column back
* @uses update_post_meta() To update the topic anonymous reply count meta
* @uses apply_filters() Calls 'bbp_update_topic_anonymous_reply_count' with the
* anonymous reply count and topic id
* @return int Anonymous reply count
*/
function bbp_update_topic_anonymous_reply_count($topic_id = 0)
{
global $wpdb;
// If it's a reply, then get the parent (topic id)
if (bbp_is_reply($topic_id)) {
$topic_id = bbp_get_reply_topic_id($topic_id);
} elseif (bbp_is_topic($topic_id)) {
$topic_id = bbp_get_topic_id($topic_id);
} else {
return;
}
$anonymous_replies = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT( ID ) FROM {$wpdb->posts} WHERE ( post_parent = %d AND post_status = '%s' AND post_type = '%s' AND post_author = 0 ) OR ( ID = %d AND post_type = '%s' AND post_author = 0 );", $topic_id, bbp_get_public_status_id(), bbp_get_reply_post_type(), $topic_id, bbp_get_topic_post_type()));
update_post_meta($topic_id, '_bbp_anonymous_reply_count', (int) $anonymous_replies);
return apply_filters('bbp_update_topic_anonymous_reply_count', (int) $anonymous_replies, $topic_id);
}
示例8: 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;
}
示例9: hook_bbp_new_reply
function hook_bbp_new_reply($reply_id)
{
$topic_id = bbp_get_reply_topic_id($reply_id);
$topic_url = bbp_get_topic_permalink($topic_id);
//$dir = $this->get_folder() . '' . substr($topic_url, strlen(get_option('home'))) . '/';
$dir = $this->get_folder() . '/' . substr($topic_url, strpos($topic_url, '://') + 3) . '/';
$this->remove_dir($dir);
$forum_id = bbp_get_reply_forum_id($reply_id);
$forum_url = bbp_get_forum_permalink($forum_id);
//$dir = $this->get_folder() . '' . substr($forum_url, strlen(get_option('home'))) . '/';
$dir = $this->get_folder() . '/' . substr($topic_url, strpos($forum_url, '://') + 3) . '/';
$this->remove_dir($dir);
}
示例10: test_bbp_create_initial_content
/**
* @group canonical
* @covers ::bbp_create_initial_content
*/
public function test_bbp_create_initial_content()
{
$category_id = $this->factory->forum->create(array('forum_meta' => array('_bbp_forum_type' => 'category', '_bbp_status' => 'open')));
bbp_create_initial_content(array('forum_parent' => $category_id));
$forum_id = bbp_forum_query_subforum_ids($category_id);
$forum_id = (int) $forum_id[0];
$topic_id = bbp_get_forum_last_topic_id($forum_id);
$reply_id = bbp_get_forum_last_reply_id($forum_id);
// Forum post
$this->assertSame('General', bbp_get_forum_title($forum_id));
$this->assertSame('General chit-chat', bbp_get_forum_content($forum_id));
$this->assertSame('open', bbp_get_forum_status($forum_id));
$this->assertTrue(bbp_is_forum_public($forum_id));
$this->assertSame($category_id, bbp_get_forum_parent_id($forum_id));
// Topic post
$this->assertSame($forum_id, bbp_get_topic_forum_id($topic_id));
$this->assertSame('Hello World!', bbp_get_topic_title($topic_id));
remove_all_filters('bbp_get_topic_content');
$topic_content = "I am the first topic in your new forums.";
$this->assertSame($topic_content, bbp_get_topic_content($topic_id));
$this->assertSame('publish', bbp_get_topic_status($topic_id));
$this->assertTrue(bbp_is_topic_published($topic_id));
// Reply post
$this->assertSame($forum_id, bbp_get_reply_forum_id($reply_id));
$this->assertSame('Reply To: Hello World!', bbp_get_reply_title($reply_id));
$this->assertSame($reply_id, bbp_get_reply_title_fallback($reply_id));
remove_all_filters('bbp_get_reply_content');
$reply_content = "Oh, and this is what a reply looks like.";
$this->assertSame($reply_content, bbp_get_reply_content($reply_id));
$this->assertSame('publish', bbp_get_reply_status($reply_id));
$this->assertTrue(bbp_is_reply_published($reply_id));
// Category meta
$this->assertSame(1, bbp_get_forum_subforum_count($category_id, true));
$this->assertSame(0, bbp_get_forum_topic_count($category_id, false, true));
$this->assertSame(0, bbp_get_forum_topic_count_hidden($category_id, true));
$this->assertSame(0, bbp_get_forum_reply_count($category_id, false, true));
$this->assertSame(1, bbp_get_forum_topic_count($category_id, true, true));
$this->assertSame(1, bbp_get_forum_reply_count($category_id, true, true));
$this->assertSame(0, bbp_get_forum_post_count($category_id, false, true));
$this->assertSame(2, bbp_get_forum_post_count($category_id, true, true));
$this->assertSame($topic_id, bbp_get_forum_last_topic_id($category_id));
$this->assertSame('Hello World!', bbp_get_forum_last_topic_title($category_id));
$this->assertSame($reply_id, bbp_get_forum_last_reply_id($category_id));
$this->assertSame('Reply To: Hello World!', bbp_get_forum_last_reply_title($category_id));
$this->assertSame($reply_id, bbp_get_forum_last_active_id($category_id));
$this->assertSame('1 day, 16 hours ago', bbp_get_forum_last_active_time($category_id));
// Forum meta
$this->assertSame(0, bbp_get_forum_subforum_count($forum_id, true));
$this->assertSame(1, bbp_get_forum_topic_count($forum_id, false, true));
$this->assertSame(0, bbp_get_forum_topic_count_hidden($forum_id, true));
$this->assertSame(1, bbp_get_forum_reply_count($forum_id, false, true));
$this->assertSame(1, bbp_get_forum_topic_count($forum_id, true, true));
$this->assertSame(1, bbp_get_forum_reply_count($forum_id, true, true));
$this->assertSame(2, bbp_get_forum_post_count($forum_id, false, true));
$this->assertSame(2, bbp_get_forum_post_count($forum_id, true, true));
$this->assertSame($topic_id, bbp_get_forum_last_topic_id($forum_id));
$this->assertSame('Hello World!', bbp_get_forum_last_topic_title($forum_id));
$this->assertSame($reply_id, bbp_get_forum_last_reply_id($forum_id));
$this->assertSame('Reply To: Hello World!', bbp_get_forum_last_reply_title($forum_id));
$this->assertSame($reply_id, bbp_get_forum_last_active_id($forum_id));
$this->assertSame('1 day, 16 hours ago', bbp_get_forum_last_active_time($forum_id));
// Topic meta
$this->assertSame('127.0.0.1', bbp_current_author_ip($topic_id));
$this->assertSame($forum_id, bbp_get_topic_forum_id($topic_id));
$this->assertSame(1, bbp_get_topic_voice_count($topic_id, true));
$this->assertSame(1, bbp_get_topic_reply_count($topic_id, true));
$this->assertSame(0, bbp_get_topic_reply_count_hidden($topic_id, true));
$this->assertSame($reply_id, bbp_get_topic_last_reply_id($topic_id));
$this->assertSame($reply_id, bbp_get_topic_last_active_id($topic_id));
$this->assertSame('1 day, 16 hours ago', bbp_get_topic_last_active_time($topic_id));
// Reply Meta
$this->assertSame('127.0.0.1', bbp_current_author_ip($reply_id));
$this->assertSame($forum_id, bbp_get_reply_forum_id($reply_id));
$this->assertSame($topic_id, bbp_get_reply_topic_id($reply_id));
}
示例11: map_reply_permalink_to_group
/**
* Map a reply permalink to its group forum
*
* @since bbPress (r3802)
* @param string $url
* @param int $reply_id
* @uses maybe_map_permalink_to_group()
* @return string
*/
public function map_reply_permalink_to_group($url, $reply_id)
{
return $this->maybe_map_permalink_to_group(bbp_get_reply_topic_id($reply_id), $url);
}
示例12: bbp_reply_metabox
/**
* Reply metabox
*
* The metabox that holds all of the additional reply information
*
* @since bbPress (r2464)
*
* @uses bbp_get_topic_post_type() To get the topic post type
* @uses do_action() Calls 'bbp_reply_metabox'
*/
function bbp_reply_metabox()
{
// Post ID
$post_id = get_the_ID();
// Get some meta
$reply_topic_id = bbp_get_reply_topic_id($post_id);
$reply_forum_id = bbp_get_reply_forum_id($post_id);
$reply_to = bbp_get_reply_to($post_id);
// Allow individual manipulation of reply forum
if (current_user_can('edit_others_replies') || current_user_can('moderate')) {
?>
<p>
<strong class="label"><?php
esc_html_e('Forum:', 'bbpress');
?>
</strong>
<label class="screen-reader-text" for="bbp_forum_id"><?php
esc_html_e('Forum', 'bbpress');
?>
</label>
<?php
bbp_dropdown(array('post_type' => bbp_get_forum_post_type(), 'selected' => $reply_forum_id, 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC', 'walker' => '', 'exclude' => '', 'select_id' => 'bbp_forum_id', 'tab' => bbp_get_tab_index(), 'options_only' => false, 'show_none' => __('— No parent —', 'bbpress'), 'disable_categories' => current_user_can('edit_forums'), 'disabled' => ''));
?>
</p>
<?php
}
?>
<p>
<strong class="label"><?php
esc_html_e('Topic:', 'bbpress');
?>
</strong>
<label class="screen-reader-text" for="parent_id"><?php
esc_html_e('Topic', 'bbpress');
?>
</label>
<input name="parent_id" id="bbp_topic_id" type="text" value="<?php
echo esc_attr($reply_topic_id);
?>
" />
</p>
<p>
<strong class="label"><?php
esc_html_e('Reply To:', 'bbpress');
?>
</strong>
<label class="screen-reader-text" for="bbp_reply_to"><?php
esc_html_e('Reply To', 'bbpress');
?>
</label>
<input name="bbp_reply_to" id="bbp_reply_to" type="text" value="<?php
echo esc_attr($reply_to);
?>
" />
</p>
<input name="ping_status" type="hidden" id="ping_status" value="open" />
<?php
wp_nonce_field('bbp_reply_metabox_save', 'bbp_reply_metabox');
do_action('bbp_reply_metabox', $post_id);
}
示例13: bbp_update_topic_anonymous_reply_count
/**
* Adjust the total anonymous reply count of a topic
*
* @since 2.0.0 bbPress (r2567)
*
* @param int $topic_id Optional. Topic id to update
* @uses bbp_is_reply() To check if the passed topic id is a reply
* @uses bbp_get_reply_topic_id() To get the reply topic id
* @uses bbp_get_topic_id() To get the topic id
* @uses bbp_get_reply_topic_id() To get the reply topic id
* @uses bbp_get_reply_post_type() To get the reply post type
* @uses bbp_get_topic_post_type() To get the topic post type
* @uses wpdb::prepare() To prepare our sql query
* @uses wpdb::get_var() To execute our query and get the column back
* @uses update_post_meta() To update the topic anonymous reply count meta
* @uses apply_filters() Calls 'bbp_update_topic_anonymous_reply_count' with the
* anonymous reply count and topic id
* @return int Anonymous reply count
*/
function bbp_update_topic_anonymous_reply_count($topic_id = 0)
{
// If it's a reply, then get the parent (topic id)
if (bbp_is_reply($topic_id)) {
$topic_id = bbp_get_reply_topic_id($topic_id);
} elseif (bbp_is_topic($topic_id)) {
$topic_id = bbp_get_topic_id($topic_id);
} else {
return;
}
// Query the DB to get anonymous replies in this topic
$bbp_db = bbp_db();
$query = $bbp_db->prepare("SELECT COUNT( ID ) FROM {$bbp_db->posts} WHERE ( post_parent = %d AND post_status = '%s' AND post_type = '%s' AND post_author = 0 ) OR ( ID = %d AND post_type = '%s' AND post_author = 0 );", $topic_id, bbp_get_public_status_id(), bbp_get_reply_post_type(), $topic_id, bbp_get_topic_post_type());
$replies = (int) $bbp_db->get_var($query);
update_post_meta($topic_id, '_bbp_anonymous_reply_count', $replies);
return (int) apply_filters('bbp_update_topic_anonymous_reply_count', $replies, $topic_id);
}
示例14: test_bbp_get_reply_topic_id
/**
* @covers ::bbp_reply_topic_id
* @covers ::bbp_get_reply_topic_id
*/
public function test_bbp_get_reply_topic_id()
{
$f = $this->factory->forum->create();
$t = $this->factory->topic->create(array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f)));
$r = $this->factory->reply->create(array('post_parent' => $t, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
$reply_topic_id = bbp_get_reply_topic_id($r);
$this->assertSame($t, $reply_topic_id);
}
示例15: test_bbp_move_topic_handler
/**
* @covers ::bbp_move_topic_handler
*/
public function test_bbp_move_topic_handler()
{
$old_current_user = 0;
$this->old_current_user = get_current_user_id();
$this->set_current_user($this->factory->user->create(array('role' => 'administrator')));
$this->keymaster_id = get_current_user_id();
bbp_set_user_role($this->keymaster_id, bbp_get_keymaster_role());
$old_forum_id = $this->factory->forum->create();
$topic_id = $this->factory->topic->create(array('post_parent' => $old_forum_id, 'topic_meta' => array('forum_id' => $old_forum_id)));
$reply_id = $this->factory->reply->create(array('post_parent' => $topic_id, 'reply_meta' => array('forum_id' => $old_forum_id, 'topic_id' => $topic_id)));
// Topic post parent
$topic_parent = wp_get_post_parent_id($topic_id);
$this->assertSame($old_forum_id, $topic_parent);
// Forum meta
$this->assertSame(1, bbp_get_forum_topic_count($old_forum_id, true, true));
$this->assertSame(1, bbp_get_forum_reply_count($old_forum_id, true, true));
$this->assertSame($topic_id, bbp_get_forum_last_topic_id($old_forum_id));
$this->assertSame($reply_id, bbp_get_forum_last_reply_id($old_forum_id));
$this->assertSame($reply_id, bbp_get_forum_last_active_id($old_forum_id));
// Topic meta
$this->assertSame($old_forum_id, bbp_get_topic_forum_id($topic_id));
$this->assertSame(1, bbp_get_topic_voice_count($topic_id, true));
$this->assertSame(1, bbp_get_topic_reply_count($topic_id, true));
$this->assertSame($reply_id, bbp_get_topic_last_reply_id($topic_id));
$this->assertSame($reply_id, bbp_get_topic_last_active_id($topic_id));
// Reply Meta
$this->assertSame($old_forum_id, bbp_get_reply_forum_id($reply_id));
$this->assertSame($topic_id, bbp_get_reply_topic_id($reply_id));
// Create a new forum
$new_forum_id = $this->factory->forum->create();
// Move the topic into the new forum
bbp_move_topic_handler($topic_id, $old_forum_id, $new_forum_id);
// Topic post parent
$topic_parent = wp_get_post_parent_id($topic_id);
$this->assertSame($new_forum_id, $topic_parent);
// Forum meta
$this->assertSame(1, bbp_get_forum_topic_count($new_forum_id, true, true));
$this->assertSame(1, bbp_get_forum_reply_count($new_forum_id, true, true));
$this->assertSame($topic_id, bbp_get_forum_last_topic_id($new_forum_id));
$this->assertSame($reply_id, bbp_get_forum_last_reply_id($new_forum_id));
$this->assertSame($reply_id, bbp_get_forum_last_active_id($new_forum_id));
// Topic meta
$this->assertSame($new_forum_id, bbp_get_topic_forum_id($topic_id));
$this->assertSame(1, bbp_get_topic_voice_count($topic_id, true));
$this->assertSame(1, bbp_get_topic_reply_count($topic_id, true));
$this->assertSame($reply_id, bbp_get_topic_last_reply_id($topic_id));
$this->assertSame($reply_id, bbp_get_topic_last_active_id($topic_id));
// Reply Meta
$this->assertSame($new_forum_id, bbp_get_reply_forum_id($reply_id));
$this->assertSame($topic_id, bbp_get_reply_topic_id($reply_id));
// Retore the user
$this->set_current_user($this->old_current_user);
}