本文整理汇总了PHP中bbp_get_reply_url函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_get_reply_url函数的具体用法?PHP bbp_get_reply_url怎么用?PHP bbp_get_reply_url使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bbp_get_reply_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _quote
private function _quote() {
$id = bbp_get_reply_id();
$is_reply = true;
if ($id == 0) {
$is_reply = false;
$id = bbp_get_topic_id();
}
if (d4p_bbt_o('quote_method', 'tools') == 'html') {
$url = ''; $ath = '';
if ($is_reply) {
$url = bbp_get_reply_url($id);
$ath = bbp_get_reply_author_display_name($id);
} else {
$url = get_permalink($id);
$ath = bbp_get_topic_author_display_name($id);
}
return '<a href="#'.$id.'" bbp-url="'.$url.'" bbp-author="'.$ath.'" class="d4p-bbt-quote-link">'.__("Quote", "gd-bbpress-tools").'</a>';
} else {
return '<a href="#'.$id.'" class="d4p-bbt-quote-link">'.__("Quote", "gd-bbpress-tools").'</a>';
}
}
示例2: wp_slack_bbpress
/**
* Plugin Name: WP Slack bbPress
* Plugin URI: https://github.com/rolfkleef/wp-slack-bbpress
* Description: Send notifications to Slack channels for events in bbPress.
* Version: 0.5
* Author: Rolf Kleef
* Author URI: https://drostan.org
* License: GPL2
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: wp-slack-bbpress
*/
function wp_slack_bbpress($events)
{
$events['wp_slack_bbp_new_topic'] = array('action' => 'bbp_new_topic', 'description' => __('When a new topic is added in bbPress', 'wp-slack-bbpress'), 'message' => function ($topic_id, $forum_id, $anonymous_data, $topic_author) {
return array(array('fallback' => sprintf(__('<%1$s|New topic "%2$s"> in forum <%3$s|%4$s>', 'wp-slack-bbpress'), bbp_get_topic_permalink($topic_id), bbp_get_topic_title($topic_id), bbp_get_forum_permalink($forum_id), bbp_get_forum_title($forum_id)), 'pretext' => sprintf(__('New topic in forum <%1$s|%2$s>', 'wp-slack-bbpress'), bbp_get_forum_permalink($forum_id), bbp_get_forum_title($forum_id)), 'author_name' => bbp_get_topic_author_display_name($topic_id), 'author_link' => bbp_get_topic_author_link($topic_id), 'author_icon' => get_avatar_url($topic_author, array('size' => 16)), 'title' => sprintf('%1$s', bbp_get_topic_title($topic_id)), 'title_link' => bbp_get_topic_permalink($topic_id), 'text' => html_entity_decode(bbp_get_topic_excerpt($topic_id, 150))));
});
$events['wp_slack_bbp_new_reply'] = array('action' => 'bbp_new_reply', 'description' => __('When a new reply is added in bbPress', 'wp-slack-bbpress'), 'message' => function ($reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author, $bool, $reply_to) {
return array(array('fallback' => sprintf(__('<%1$s|New reply> in forum <%2$s|%3$s> on topic <%4$s|%5$s>', 'wp-slack-bbpress'), bbp_get_reply_url($reply_id), bbp_get_forum_permalink($forum_id), bbp_get_forum_title($forum_id), bbp_get_topic_permalink($topic_id), bbp_get_topic_title($topic_id)), 'pretext' => sprintf(__('New reply in forum <%1$s|%2$s> on topic <%3$s|%4$s>', 'wp-slack-bbpress'), bbp_get_forum_permalink($forum_id), bbp_get_forum_title($forum_id), bbp_get_topic_permalink($topic_id), bbp_get_topic_title($topic_id)), 'author_name' => bbp_get_reply_author_display_name($reply_id), 'author_link' => bbp_get_reply_author_link($reply_id), 'author_icon' => get_avatar_url($reply_author, array('size' => 16)), 'title' => sprintf(__('New reply to "%1$s"', 'wp-slack-bbpress'), bbp_get_topic_title($topic_id)), 'title_link' => bbp_get_reply_url($reply_id), 'text' => html_entity_decode(bbp_get_reply_excerpt($reply_id, 150))));
});
return $events;
}
示例3: widget
function widget($args, $instance)
{
extract($args, EXTR_SKIP);
$title = !empty($instance['title']) ? $instance['title'] : __('Recent Topics');
$title = apply_filters('widget_title', $title, $instance, $this->id_base);
$number = !empty($instance['number']) ? absint($instance['number']) : 5;
$orderby = !empty($instance['number']) ? strip_tags($instance['order_by']) : 'newness';
if ($orderby == 'newness') {
$cb_meta_key = $cb_order_by = NULL;
} elseif ($orderby == 'popular') {
$cb_meta_key = '_bbp_reply_count';
$cb_order_by = 'meta_value';
} elseif ($orderby == 'freshness') {
$cb_meta_key = '_bbp_last_active_time';
$cb_order_by = 'meta_value';
}
if (!$number) {
$number = 5;
}
$cb_qry = new WP_Query(array('post_type' => bbp_get_topic_post_type(), 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'order' => 'DESC', 'posts_per_page' => $number, 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'meta_key' => $cb_meta_key, 'orderby' => $cb_order_by));
echo $before_widget;
echo $before_title . $title . $after_title;
?>
<ul class="cb-bbp-recent-topics">
<?php
while ($cb_qry->have_posts()) {
$cb_qry->the_post();
?>
<li>
<?php
$cb_reply_id = bbp_get_reply_id($cb_qry->post->ID);
$cb_reply_url = '<a class="bbp-reply-topic-title" href="' . esc_url(bbp_get_reply_url($cb_reply_id)) . '" title="' . esc_attr(bbp_get_reply_excerpt($cb_reply_id, 50)) . '">' . bbp_get_reply_topic_title($cb_reply_id) . '</a>';
$cb_number_replies = bbp_get_topic_reply_count($cb_reply_id);
$cb_author_avatar = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'avatar', 'size' => 60));
$cb_author_name = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'name'));
echo $cb_author_avatar . '<div class="cb-bbp-meta">' . $cb_reply_url . '<div class="cb-bbp-byline">' . __('Started by', 'cubell') . ' ' . $cb_author_name . ' <i class="icon-long-arrow-right"></i> ' . $cb_number_replies . ' replies</div></div>';
?>
</li>
<?php
}
?>
</ul>
<?php
echo $after_widget;
// Reset the $post global
wp_reset_postdata();
}
示例4: reply_message
public static function reply_message($message, $reply_id, $topic_id, $user_id)
{
$reply_content = strip_tags(bbp_get_reply_content($reply_id));
$reply_url = bbp_get_reply_url($reply_id);
$reply_author = bbp_get_reply_author_display_name($reply_id);
$custom_message = get_option('_bbp_reply_notice_body');
$message = $custom_message ? $custom_message : $message;
$message = str_replace('{author}', $reply_author, $message);
$message = str_replace('{content}', $reply_content, $message);
$message = str_replace('{url}', $reply_url, $message);
return $message;
}
示例5: 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);
}
示例6: widget
function widget($args, $instance)
{
extract($args, EXTR_SKIP);
$title = !empty($instance['title']) ? $instance['title'] : __('Recent Comments');
$title = apply_filters('widget_title', $title, $instance, $this->id_base);
$number = !empty($instance['number']) ? absint($instance['number']) : 5;
if (!$number) {
$number = 5;
}
$cb_qry = new WP_Query(array('post_type' => bbp_get_reply_post_type(), 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'posts_per_page' => $number, 'ignore_sticky_posts' => true, 'no_found_rows' => true));
echo $before_widget;
echo $before_title . $title . $after_title;
?>
<ul class="cb-bbp-recent-replies">
<?php
while ($cb_qry->have_posts()) {
$cb_qry->the_post();
?>
<li>
<?php
$cb_reply_id = bbp_get_reply_id($cb_qry->post->ID);
$cb_reply_url = '<a class="bbp-reply-topic-title" href="' . esc_url(bbp_get_reply_url($cb_reply_id)) . '" title="' . esc_attr(bbp_get_reply_excerpt($cb_reply_id, 50)) . '">' . bbp_get_reply_topic_title($cb_reply_id) . '</a>';
$cb_author_avatar = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'avatar', 'size' => 60));
$cb_author_name = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'name'));
echo $cb_author_avatar . '<div class="cb-bbp-meta">' . $cb_author_name . ' <i class="icon-long-arrow-right"></i> ' . $cb_reply_url . '<div class="cb-bbp-recent-replies-time">' . bbp_get_time_since(get_the_time('U')) . '</div></div>';
?>
</li>
<?php
}
?>
</ul>
<?php
echo $after_widget;
// Reset the $post global
wp_reset_postdata();
}
示例7: mk_theme_breadcrumbs
//.........这里部分代码省略.........
foreach ($breadcrumbs as $crumb) {
echo $crumb . '' . $delimiter;
}
echo get_the_title();
} elseif (is_attachment()) {
$parent = get_post($post->post_parent);
$cat = get_the_category($parent->ID);
$cat = $cat[0];
/* admin@innodron.com patch:
Fix for Catchable fatal error: Object of class WP_Error could not be converted to string
ref: https://wordpress.org/support/topic/catchable-fatal-error-object-of-class-wp_error-could-not-be-converted-to-string-11
*/
echo is_wp_error($cat_parents = get_category_parents($cat, TRUE, '' . $delimiter . '')) ? '' : $cat_parents;
/* end admin@innodron.com patch */
echo '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a>' . $delimiter;
echo get_the_title();
} elseif (is_search()) {
echo __('Search results for “', 'mk_framework') . get_search_query() . '”';
} elseif (is_tag()) {
echo __('Tag “', 'mk_framework') . single_tag_title('', false) . '”';
} elseif (is_author()) {
$userdata = get_userdata(get_the_author_meta('ID'));
echo __('Author:', 'mk_framework') . ' ' . $userdata->display_name;
} elseif (is_day()) {
echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a>' . $delimiter;
echo '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '">' . get_the_time('F') . '</a>' . $delimiter;
echo get_the_time('d');
} elseif (is_month()) {
echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a>' . $delimiter;
echo get_the_time('F');
} elseif (is_year()) {
echo get_the_time('Y');
}
}
}
if (get_query_var('paged')) {
echo ' (' . __('Page', 'mk_framework') . ' ' . get_query_var('paged') . ')';
}
if (is_tax()) {
$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
if (function_exists('is_woocommerce') && is_woocommerce() && is_archive()) {
echo $delimiter;
}
echo '<span>' . $term->name . '</span>';
}
if (function_exists('is_bbpress') && is_bbpress()) {
$item = array();
$post_type_object = get_post_type_object(bbp_get_forum_post_type());
if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
$item[] = '<a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a>';
}
if (bbp_is_forum_archive()) {
$item[] = bbp_get_forum_archive_title();
} elseif (bbp_is_topic_archive()) {
$item[] = bbp_get_topic_archive_title();
} elseif (bbp_is_single_view()) {
$item[] = bbp_get_view_title();
} elseif (bbp_is_single_topic()) {
$topic_id = get_queried_object_id();
$item = array_merge($item, mk_breadcrumbs_get_parents(bbp_get_topic_forum_id($topic_id)));
if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
$item[] = '<a href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
} else {
$item[] = bbp_get_topic_title($topic_id);
}
if (bbp_is_topic_split()) {
$item[] = __('Split', 'mk_framework');
} elseif (bbp_is_topic_merge()) {
$item[] = __('Merge', 'mk_framework');
} elseif (bbp_is_topic_edit()) {
$item[] = __('Edit', 'mk_framework');
}
} elseif (bbp_is_single_reply()) {
$reply_id = get_queried_object_id();
$item = array_merge($item, mk_breadcrumbs_get_parents(bbp_get_reply_topic_id($reply_id)));
if (!bbp_is_reply_edit()) {
$item[] = bbp_get_reply_title($reply_id);
} else {
$item[] = '<a href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a>';
$item[] = __('Edit', 'mk_framework');
}
} elseif (bbp_is_single_forum()) {
$forum_id = get_queried_object_id();
$forum_parent_id = bbp_get_forum_parent_id($forum_id);
if (0 !== $forum_parent_id) {
$item = array_merge($item, mk_breadcrumbs_get_parents($forum_parent_id));
}
$item[] = bbp_get_forum_title($forum_id);
} elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
if (bbp_is_single_user_edit()) {
$item[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a>';
$item[] = __('Edit', 'mk_framework');
} else {
$item[] = bbp_get_displayed_user_field('display_name');
}
}
echo implode($delimiter, $item);
}
echo "</div></div>";
}
示例8: bbp_get_forum_last_reply_url
/**
* Return the url to the last reply in a forum
*
* @since bbPress (r2683)
*
* @param int $forum_id Optional. Forum id
* @uses bbp_get_forum_id() To get the forum id
* @uses bbp_get_forum_last_reply_id() To get the forum's last reply id
* @uses bbp_get_reply_url() To get the reply url
* @uses bbp_get_forum_last_topic_permalink() To get the forum's last
* topic's permalink
* @uses apply_filters() Calls 'bbp_get_forum_last_reply_url' with the
* reply url and forum id
* @return string Paginated URL to latest reply
*/
function bbp_get_forum_last_reply_url($forum_id = 0)
{
$forum_id = bbp_get_forum_id($forum_id);
// If forum has replies, get the last reply and use its url
$reply_id = bbp_get_forum_last_reply_id($forum_id);
if (!empty($reply_id)) {
$reply_url = bbp_get_reply_url($reply_id);
// No replies, so look for topics and use last permalink
} else {
$reply_url = bbp_get_forum_last_topic_permalink($forum_id);
// No topics either, so set $reply_url as empty string
if (empty($reply_url)) {
$reply_url = '';
}
}
// Filter and return
return apply_filters('bbp_get_forum_last_reply_url', $reply_url, $forum_id);
}
示例9: test_bbp_get_reply_url
/**
* @covers ::bbp_reply_url
* @covers ::bbp_get_reply_url
*
* @ticket BBP2845
*/
public function test_bbp_get_reply_url()
{
if (is_multisite()) {
$this->markTestSkipped('Skipping URL tests in multisite for now.');
}
$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_many(7, array('post_parent' => $t, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
// Store the original reply pagination option value.
$default_reply_page = bbp_get_replies_per_page();
// Lower the reply pagination value to test without so many replies.
update_option('_bbp_replies_per_page', 3);
// Reply menu position is unaltered when bbp_show_lead_topic() true.
add_filter('bbp_show_lead_topic', '__return_true');
// 1st reply is on the first page, 3 replies and 1 topic per page.
$reply_url = bbp_get_topic_permalink($t) . '/#post-' . bbp_get_reply_id($r[0]);
$this->assertSame($reply_url, bbp_get_reply_url($r[0]));
// 2nd reply is on the first page, 3 replies and 1 topic per page.
$reply_url = bbp_get_topic_permalink($t) . '/#post-' . bbp_get_reply_id($r[1]);
$this->assertSame($reply_url, bbp_get_reply_url($r[1]));
// 3rd reply is on the first page, 3 replies and 1 topic per page.
$reply_url = bbp_get_topic_permalink($t) . '/#post-' . bbp_get_reply_id($r[2]);
$this->assertSame($reply_url, bbp_get_reply_url($r[2]));
// 4th reply is on the second page, 3 replies and 1 topic per page.
$reply_url = bbp_get_topic_permalink($t) . '&paged=2#post-' . bbp_get_reply_id($r[3]);
$this->assertSame($reply_url, bbp_get_reply_url($r[3]));
// 5th reply is on the second page, 3 replies and 1 topic per page.
$reply_url = bbp_get_topic_permalink($t) . '&paged=2#post-' . bbp_get_reply_id($r[4]);
$this->assertSame($reply_url, bbp_get_reply_url($r[4]));
// 6th reply is on the second page, 3 replies and 1 topic per page.
$reply_url = bbp_get_topic_permalink($t) . '&paged=2#post-' . bbp_get_reply_id($r[5]);
$this->assertSame($reply_url, bbp_get_reply_url($r[5]));
// 7th reply is on the third page, 3 replies and 1 topic per page.
$reply_url = bbp_get_topic_permalink($t) . '&paged=3#post-' . bbp_get_reply_id($r[6]);
$this->assertSame($reply_url, bbp_get_reply_url($r[6]));
// Remove the filter for WordPress < 4.0 compatibility.
remove_filter('bbp_show_lead_topic', '__return_true');
// Reply menu position is bumped by 1 when bbp_show_lead_topic() false.
add_filter('bbp_show_lead_topic', '__return_false');
// 1st reply is on the first page, 2 replies and 1 topic per first page.
$reply_url = bbp_get_topic_permalink($t) . '/#post-' . bbp_get_reply_id($r[0]);
$this->assertSame($reply_url, bbp_get_reply_url($r[0]));
// 2nd reply is on the first page, 2 replies and 1 topic per first page.
$reply_url = bbp_get_topic_permalink($t) . '/#post-' . bbp_get_reply_id($r[1]);
$this->assertSame($reply_url, bbp_get_reply_url($r[1]));
// 3rd reply is on the second page, 2 replies and 1 topic per first page.
$reply_url = bbp_get_topic_permalink($t) . '&paged=2#post-' . bbp_get_reply_id($r[2]);
$this->assertSame($reply_url, bbp_get_reply_url($r[2]));
// 4th reply is on the second page, 3 replies per subsequent page.
$reply_url = bbp_get_topic_permalink($t) . '&paged=2#post-' . bbp_get_reply_id($r[3]);
$this->assertSame($reply_url, bbp_get_reply_url($r[3]));
// 5th reply is on the second page, 3 replies per subsequent page.
$reply_url = bbp_get_topic_permalink($t) . '&paged=2#post-' . bbp_get_reply_id($r[4]);
$this->assertSame($reply_url, bbp_get_reply_url($r[4]));
// 6th reply is on the third page, 3 replies per subsequent page.
$reply_url = bbp_get_topic_permalink($t) . '&paged=3#post-' . bbp_get_reply_id($r[5]);
$this->assertSame($reply_url, bbp_get_reply_url($r[5]));
// 7th reply is on the third page, 3 replies per subsequent page.
$reply_url = bbp_get_topic_permalink($t) . '&paged=3#post-' . bbp_get_reply_id($r[6]);
$this->assertSame($reply_url, bbp_get_reply_url($r[6]));
// Remove the filter for WordPress < 4.0 compatibility.
remove_filter('bbp_show_lead_topic', '__return_false');
// Restore the original reply pagination option value.
update_option('_bbp_replies_per_page', $default_reply_page);
}
示例10: breadcrumbs_plus_get_bbpress_items
/**
* Gets the items for the breadcrumb item if bbPress is installed.
*
* @since 0.4
*
* @param array $args Mixed arguments for the menu.
* @return array List of items to be shown in the item.
*/
function breadcrumbs_plus_get_bbpress_items($args = array())
{
$item = array();
$post_type_object = get_post_type_object(bbp_get_forum_post_type());
if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
if (function_exists('bp_is_active')) {
global $bp;
// we're outside the loop!
// Assign some variables here
$page1 = isset($bp->members->root_slug) ? $bp->members->root_slug : '';
// slug for the Members page. The BuddyPress default is 'members'.
$page2 = isset($bp->groups->root_slug) ? $bp->groups->root_slug : '';
// slug for the Groups page. The BuddyPress default is 'groups'.
$page3 = isset($bp->activity->root_slug) ? $bp->activity->root_slug : '';
// slug for the Activity page. The BuddyPress default is 'activity'.
$page4 = isset($bp->forums->root_slug) ? $bp->forums->root_slug : '';
// slug for the Forums page. The BuddyPress default is 'forums'.
$page5 = isset($bp->achievements->root_slug) ? $bp->achievements->root_slug : '';
// slug for the Achievements page. The BuddyPress default is 'achievements'.
if (!bp_is_blog_page() && (is_page() || is_page($page1) || is_page($page2) || is_page($page3) || is_page($page4) || is_page($page5)) && !bp_is_user() && !bp_is_single_item() && !bp_is_register_page()) {
$item[] = '';
}
if (bp_is_user() && !bp_is_register_page()) {
$item[] = '';
}
} else {
//$item[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . get_post_type_archive_link( bbp_get_forum_post_type() ) . '" rel="v:url" property="v:title">' . bbp_get_forum_archive_title() . '</a></div>';
}
}
if (bbp_is_forum_archive()) {
$item[] = bbp_get_forum_archive_title();
} else {
$item[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '" rel="v:url" property="v:title">' . bbp_get_forum_archive_title() . '</a></div>';
}
if (bbp_is_topic_archive()) {
$item[] = bbp_get_topic_archive_title();
} elseif (bbp_is_single_view()) {
$item[] = bbp_get_view_title();
} elseif (bbp_is_single_topic()) {
$topic_id = get_queried_object_id();
$item = array_merge($item, breadcrumbs_plus_get_parents(bbp_get_topic_forum_id($topic_id)));
if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
$item[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . bbp_get_topic_permalink($topic_id) . '" rel="v:url" property="v:title">' . bbp_get_topic_title($topic_id) . '</a></div>';
} else {
$item[] = '';
}
if (bbp_is_topic_split()) {
$item[] = __('Split', 'framework');
} elseif (bbp_is_topic_merge()) {
$item[] = __('Merge', 'framework');
} elseif (bbp_is_topic_edit()) {
$item[] = __('Edit', 'framework');
}
} elseif (bbp_is_single_reply()) {
$reply_id = get_queried_object_id();
$item = array_merge($item, breadcrumbs_plus_get_parents(bbp_get_reply_topic_id($reply_id)));
if (!bbp_is_reply_edit()) {
$item[] = bbp_get_reply_title($reply_id);
} else {
$item[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . bbp_get_reply_url($reply_id) . '" rel="v:url" property="v:title">' . bbp_get_reply_title($reply_id) . '</a></div>';
$item[] = __('Edit', 'framework');
}
} elseif (bbp_is_single_forum()) {
$forum_id = get_queried_object_id();
$forum_parent_id = bbp_get_forum_parent_id($forum_id);
if (0 !== $forum_parent_id) {
$item = array_merge($item, breadcrumbs_plus_get_parents($forum_parent_id));
}
$item[] = bbp_get_forum_title($forum_id);
} elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
if (bbp_is_single_user_edit()) {
$item[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . bbp_get_user_profile_url() . '" rel="v:url" property="v:title">' . bbp_get_displayed_user_field('display_name') . '</a></div>';
$item[] = __('Edit', 'framework');
} else {
$item[] = bbp_get_displayed_user_field('display_name');
}
}
return apply_filters('breadcrumbs_plus_get_bbpress_items', $item, $args);
}
示例11: subscription_email
/**
* Sends the new reply notification email to moderators on private replies
*
* @since 1.2
*
* @param $message string The email message
* @param $reply_id int The ID of the reply
* @param $topic_id int The ID of the reply's topic
*
* @return void
*/
public function subscription_email($message, $reply_id, $topic_id)
{
if (!$this->is_private($reply_id)) {
return false;
// reply isn't private so do nothing
}
$topic_author = bbp_get_topic_author_id($topic_id);
$reply_author = bbp_get_reply_author_id($reply_id);
$reply_author_name = bbp_get_reply_author_display_name($reply_id);
// Strip tags from text and setup mail data
$topic_title = strip_tags(bbp_get_topic_title($topic_id));
$reply_content = strip_tags(bbp_get_reply_content($reply_id));
$reply_url = bbp_get_reply_url($reply_id);
$blog_name = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
$do_not_reply = '<noreply@' . ltrim(get_home_url(), '^(http|https)://') . '>';
$subject = apply_filters('bbp_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $reply_id, $topic_id);
// Array to hold BCC's
$headers = array();
// Setup the From header
$headers[] = 'From: ' . get_bloginfo('name') . ' ' . $do_not_reply;
// Get topic subscribers and bail if empty
$user_ids = bbp_get_topic_subscribers($topic_id, true);
if (empty($user_ids)) {
return false;
}
// Loop through users
foreach ((array) $user_ids as $user_id) {
// Don't send notifications to the person who made the post
if (!empty($reply_author) && (int) $user_id === (int) $reply_author) {
continue;
}
if (user_can($user_id, 'moderate') || (int) $topic_author === (int) $user_id) {
// Get email address of subscribed user
$headers[] = 'Bcc: ' . get_userdata($user_id)->user_email;
}
}
wp_mail($do_not_reply, $subject, $message, $headers);
}
示例12: toggle_reply_handler
/**
* Handles the front end reporting/un-reporting of replies
*
* @since 1.0.0
*
* @param string $action The requested action to compare this function to
*/
public function toggle_reply_handler($action = '')
{
// Bail if required GET actions aren't passed
if (empty($_GET['reply_id'])) {
return;
}
// Setup possible get actions
$possible_actions = array('bbp_rc_toggle_reply_report');
// Bail if actions aren't meant for this function
if (!in_array($action, $possible_actions)) {
return;
}
$failure = '';
// Empty failure string
$view_all = false;
// Assume not viewing all
$reply_id = (int) $_GET['reply_id'];
// What's the reply id?
$success = false;
// Flag
$post_data = array('ID' => $reply_id);
// Prelim array
$redirect = '';
// Empty redirect URL
// Make sure reply exists
$reply = bbp_get_reply($reply_id);
if (empty($reply)) {
return;
}
// Bail if non-logged-in user
if (!is_user_logged_in()) {
return;
}
// What action are we trying to perform?
switch ($action) {
// Toggle reported
case 'bbp_rc_toggle_reply_report':
check_ajax_referer('report-reply_' . $reply_id);
$is_reported = $this->is_reply_reported($reply_id);
$success = true === $is_reported ? $this->unreport_reply($reply_id) : $this->report_reply($reply_id);
$failure = true === $is_reported ? __('<strong>ERROR</strong>: There was a problem unmarking the reply as reported.', 'bbpress-report-content') : __('<strong>ERROR</strong>: There was a problem reporting the reply.', 'bbpress-report-content');
// $view_all = !$is_reported; // Only need this if we want to hide it, like spam
break;
}
// No errors
if (false !== $success && !is_wp_error($success)) {
/** Redirect **********************************************************/
// Redirect to
$redirect_to = bbp_get_redirect_to();
// Get the reply URL
$reply_url = bbp_get_reply_url($reply_id, $redirect_to);
// Add view all if needed
if (!empty($view_all)) {
$reply_url = bbp_add_view_all($reply_url, true);
}
// Redirect back to reply
wp_safe_redirect($reply_url);
// For good measure
exit;
// Handle errors
} else {
bbp_add_error('bbp_rc_toggle_reply', $failure);
}
}
示例13: widget
/**
* Displays the output, the replies list
*
* @since bbPress (r2653)
*
* @param mixed $args
* @param array $instance
* @uses apply_filters() Calls 'bbp_reply_widget_title' with the title
* @uses bbp_get_reply_author_link() To get the reply author link
* @uses bbp_get_reply_author() To get the reply author name
* @uses bbp_get_reply_id() To get the reply id
* @uses bbp_get_reply_url() To get the reply url
* @uses bbp_get_reply_excerpt() To get the reply excerpt
* @uses bbp_get_reply_topic_title() To get the reply topic title
* @uses get_the_date() To get the date of the reply
* @uses get_the_time() To get the time of the reply
*/
public function widget($args, $instance)
{
extract($args);
$title = apply_filters('bbp_replies_widget_title', $instance['title']);
$max_shown = !empty($instance['max_shown']) ? $instance['max_shown'] : '5';
$show_date = !empty($instance['show_date']) ? 'on' : false;
$show_user = !empty($instance['show_user']) ? 'on' : false;
$post_types = !empty($instance['post_type']) ? array(bbp_get_topic_post_type(), bbp_get_reply_post_type()) : bbp_get_reply_post_type();
// Note: private and hidden forums will be excluded via the
// bbp_pre_get_posts_exclude_forums filter and function.
$widget_query = new WP_Query(array('post_type' => $post_types, 'post_status' => join(',', array(bbp_get_public_status_id(), bbp_get_closed_status_id())), 'posts_per_page' => $max_shown, 'meta_query' => array(bbp_exclude_forum_ids('meta_query'))));
// Get replies and display them
if ($widget_query->have_posts()) {
echo $before_widget;
echo $before_title . $title . $after_title;
?>
<ul>
<?php
while ($widget_query->have_posts()) {
$widget_query->the_post();
?>
<li>
<?php
$reply_id = bbp_get_reply_id($widget_query->post->ID);
$author_link = bbp_get_reply_author_link(array('post_id' => $reply_id, 'type' => 'both', 'size' => 14));
$reply_link = '<a class="bbp-reply-topic-title" href="' . esc_url(bbp_get_reply_url($reply_id)) . '" title="' . bbp_get_reply_excerpt($reply_id, 50) . '">' . bbp_get_reply_topic_title($reply_id) . '</a>';
// Reply author, link, and timestamp
if ('on' == $show_date && 'on' == $show_user) {
// translators: 1: reply author, 2: reply link, 3: reply timestamp
printf(_x('%1$s on %2$s %3$s', 'widgets', 'bbpress'), $author_link, $reply_link, '<div>' . bbp_get_time_since(get_the_time('U')) . '</div>');
// Reply link and timestamp
} elseif ($show_date == 'on') {
// translators: 1: reply link, 2: reply timestamp
printf(_x('%1$s %2$s', 'widgets', 'bbpress'), $reply_link, '<div>' . bbp_get_time_since(get_the_time('U')) . '</div>');
// Reply author and title
} elseif ($show_user == 'on') {
// translators: 1: reply author, 2: reply link
printf(_x('%1$s on %2$s', 'widgets', 'bbpress'), $author_link, $reply_link);
// Only the reply title
} else {
// translators: 1: reply link
printf(_x('%1$s', 'widgets', 'bbpress'), $reply_link);
}
?>
</li>
<?php
}
?>
</ul>
<?php
echo $after_widget;
// Reset the $post global
wp_reset_postdata();
}
}
示例14: breadcrumbs_plus_get_bbpress_items
/**
* Gets the items for the breadcrumb item if bbPress is installed.
*
* @since 0.4
*
* @param array $args Mixed arguments for the menu.
* @return array List of items to be shown in the item.
*/
function breadcrumbs_plus_get_bbpress_items($args = array())
{
$item = array();
$post_type_object = get_post_type_object(bbp_get_forum_post_type());
if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
$item[] = '<a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a>';
}
if (bbp_is_forum_archive()) {
$item[] = bbp_get_forum_archive_title();
} elseif (bbp_is_topic_archive()) {
$item[] = bbp_get_topic_archive_title();
} elseif (bbp_is_single_view()) {
$item[] = bbp_get_view_title();
} elseif (bbp_is_single_topic()) {
$topic_id = get_queried_object_id();
$item = array_merge($item, breadcrumbs_plus_get_parents(bbp_get_topic_forum_id($topic_id)));
if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
$item[] = '<a href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
} else {
$item[] = bbp_get_topic_title($topic_id);
}
if (bbp_is_topic_split()) {
$item[] = __('Split', 'theme_front');
} elseif (bbp_is_topic_merge()) {
$item[] = __('Merge', 'theme_front');
} elseif (bbp_is_topic_edit()) {
$item[] = __('Edit', 'theme_front');
}
} elseif (bbp_is_single_reply()) {
$reply_id = get_queried_object_id();
$item = array_merge($item, breadcrumbs_plus_get_parents(bbp_get_reply_topic_id($reply_id)));
if (!bbp_is_reply_edit()) {
$item[] = bbp_get_reply_title($reply_id);
} else {
$item[] = '<a href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a>';
$item[] = __('Edit', 'theme_front');
}
} elseif (bbp_is_single_forum()) {
$forum_id = get_queried_object_id();
$forum_parent_id = bbp_get_forum_parent($forum_id);
if (0 !== $forum_parent_id) {
$item = array_merge($item, breadcrumbs_plus_get_parents($forum_parent_id));
}
$item[] = bbp_get_forum_title($forum_id);
} elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
if (bbp_is_single_user_edit()) {
$item[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a>';
$item[] = __('Edit');
} else {
$item[] = bbp_get_displayed_user_field('display_name');
}
}
return apply_filters('breadcrumbs_plus_get_bbpress_items', $item, $args);
}
示例15: reply_create
/**
* Record an activity stream entry when a reply is created
*
* @since bbPress (r3395)
* @param int $topic_id
* @param int $forum_id
* @param array $anonymous_data
* @param int $topic_author_id
* @uses bbp_get_reply_id()
* @uses bbp_get_topic_id()
* @uses bbp_get_forum_id()
* @uses bbp_get_user_profile_link()
* @uses bbp_get_reply_url()
* @uses bbp_get_reply_content()
* @uses bbp_get_topic_permalink()
* @uses bbp_get_topic_title()
* @uses bbp_get_forum_permalink()
* @uses bbp_get_forum_title()
* @uses bp_create_excerpt()
* @uses apply_filters()
* @return Bail early if topic is by anonywous user
*/
public function reply_create($reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author_id)
{
// Do not log activity of anonymous users
if (!empty($anonymous_data)) {
return;
}
// Bail if site is private
if (!bbp_is_site_public()) {
return;
}
// Validate activity data
$user_id = $reply_author_id;
$reply_id = bbp_get_reply_id($reply_id);
$topic_id = bbp_get_topic_id($topic_id);
$forum_id = bbp_get_forum_id($forum_id);
// Bail if user is not active
if (bbp_is_user_inactive($user_id)) {
return;
}
// Bail if reply is not published
if (!bbp_is_reply_published($reply_id)) {
return;
}
// Setup links for activity stream
$user_link = bbp_get_user_profile_link($user_id);
// Reply
$reply_url = bbp_get_reply_url($reply_id);
$reply_content = get_post_field('post_content', $reply_id, 'raw');
// Topic
$topic_permalink = bbp_get_topic_permalink($topic_id);
$topic_title = get_post_field('post_title', $topic_id, 'raw');
$topic_link = '<a href="' . $topic_permalink . '" title="' . $topic_title . '">' . $topic_title . '</a>';
// Forum
$forum_permalink = bbp_get_forum_permalink($forum_id);
$forum_title = get_post_field('post_title', $forum_id, 'raw');
$forum_link = '<a href="' . $forum_permalink . '" title="' . $forum_title . '">' . $forum_title . '</a>';
// Activity action & text
$activity_text = sprintf(__('%1$s replied to the topic %2$s in the forum %3$s', 'bbpress'), $user_link, $topic_link, $forum_link);
$activity_action = apply_filters('bbp_activity_reply_create', $activity_text, $user_id, $reply_id, $topic_id);
$activity_content = apply_filters('bbp_activity_reply_create_excerpt', bp_create_excerpt($reply_content), $reply_content);
// Compile the activity stream results
$activity = array('id' => $this->get_activity_id($reply_id), 'user_id' => $user_id, 'action' => $activity_action, 'content' => $activity_content, 'primary_link' => $reply_url, 'type' => $this->reply_create, 'item_id' => $reply_id, 'secondary_item_id' => $topic_id, 'recorded_time' => get_post_time('Y-m-d H:i:s', true, $reply_id), 'hide_sitewide' => !bbp_is_forum_public($forum_id, false));
// Record the activity
$activity_id = $this->record_activity($activity);
// Add the activity entry ID as a meta value to the reply
if (!empty($activity_id)) {
update_post_meta($reply_id, '_bbp_activity_id', $activity_id);
}
}