本文整理汇总了PHP中bbp_get_topic_author_link函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_get_topic_author_link函数的具体用法?PHP bbp_get_topic_author_link怎么用?PHP bbp_get_topic_author_link使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bbp_get_topic_author_link函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: bbp_topic_pagination
<?php
bbp_topic_pagination();
?>
<?php
do_action('bbp_theme_before_topic_meta');
?>
<p class="bbp-topic-meta">
<?php
do_action('bbp_theme_before_topic_started_by');
?>
<span class="bbp-topic-started-by"><?php
printf(__('Started by: %1$s', 'bbpress'), bbp_get_topic_author_link(array('type' => 'name')));
?>
</span>
<?php
do_action('bbp_theme_after_topic_started_by');
?>
<?php
if (!bbp_is_single_forum() || bbp_get_topic_forum_id() !== bbp_get_forum_id()) {
?>
<?php
do_action('bbp_theme_before_topic_started_in');
?>
示例3: bbp_topic_author_link
/**
* Output the author link of the topic
*
* @since 2.0.0 bbPress (r2717)
*
* @param mixed|int $args If it is an integer, it is used as topic_id. Optional.
* @uses bbp_get_topic_author_link() To get the topic author link
*/
function bbp_topic_author_link($args = array())
{
echo bbp_get_topic_author_link($args);
}
示例4: 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);
}
示例5: bbp_topic_pagination
?>
<?php
bbp_topic_pagination();
?>
<?php
do_action('bbp_theme_before_topic_meta');
?>
</div>
<p class="bbp-topic-meta">
<?php
do_action('bbp_theme_before_topic_started_by');
?>
<span class="bbp-topic-started-by"><?php
printf('%1$s', bbp_get_topic_author_link(array('size' => '14')));
?>
</span>
<?php
do_action('bbp_theme_after_topic_started_by');
?>
<?php
if (!bbp_is_single_forum() || bbp_get_topic_forum_id() !== bbp_get_forum_id()) {
?>
<?php
do_action('bbp_theme_before_topic_started_in');
?>
<span class="bbp-topic-started-in"><?php
printf(__('in: <a href="%1$s">%2$s</a>', 'bbpress'), bbp_get_forum_permalink(bbp_get_topic_forum_id()), bbp_get_forum_title(bbp_get_topic_forum_id()));
示例6: bbp_topic_author_link
/**
* Output the author link of the topic
*
* @since bbPress (r2717)
*
* @param mixed|int $args If it is an integer, it is used as topic_id. Optional.
* @uses bbp_get_topic_author_link() To get the topic author link
*/
function bbp_topic_author_link($args = '')
{
echo bbp_get_topic_author_link($args);
}
示例7: widget
/**
* Displays the output, the topic list
*
* @since bbPress (r2653)
*
* @param mixed $args
* @param array $instance
* @uses apply_filters() Calls 'bbp_topic_widget_title' with the title
* @uses bbp_topic_permalink() To display the topic permalink
* @uses bbp_topic_title() To display the topic title
* @uses bbp_get_topic_last_active_time() To get the topic last active
* time
* @uses bbp_get_topic_id() To get the topic id
* @uses bbp_get_topic_reply_count() To get the topic reply count
*/
public function widget($args, $instance)
{
extract($args);
$title = apply_filters('bbp_topic_widget_title', $instance['title']);
$max_shown = !empty($instance['max_shown']) ? (int) $instance['max_shown'] : 5;
$show_date = !empty($instance['show_date']) ? 'on' : false;
$show_user = !empty($instance['show_user']) ? 'on' : false;
$parent_forum = !empty($instance['parent_forum']) ? $instance['parent_forum'] : 'any';
$order_by = !empty($instance['order_by']) ? $instance['order_by'] : false;
// How do we want to order our results?
switch ($order_by) {
// Order by most recent replies
case 'freshness':
$topics_query = array('author' => 0, 'post_type' => bbp_get_topic_post_type(), 'post_parent' => $parent_forum, 'posts_per_page' => $max_shown, 'post_status' => join(',', array(bbp_get_public_status_id(), bbp_get_closed_status_id())), 'show_stickes' => false, 'meta_key' => '_bbp_last_active_time', 'orderby' => 'meta_value', 'order' => 'DESC', 'meta_query' => array(bbp_exclude_forum_ids('meta_query')));
break;
// Order by total number of replies
// Order by total number of replies
case 'popular':
$topics_query = array('author' => 0, 'post_type' => bbp_get_topic_post_type(), 'post_parent' => $parent_forum, 'posts_per_page' => $max_shown, 'post_status' => join(',', array(bbp_get_public_status_id(), bbp_get_closed_status_id())), 'show_stickes' => false, 'meta_key' => '_bbp_reply_count', 'orderby' => 'meta_value', 'order' => 'DESC', 'meta_query' => array(bbp_exclude_forum_ids('meta_query')));
break;
// Order by which topic was created most recently
// Order by which topic was created most recently
case 'newness':
default:
$topics_query = array('author' => 0, 'post_type' => bbp_get_topic_post_type(), 'post_parent' => $parent_forum, 'posts_per_page' => $max_shown, 'post_status' => join(',', array(bbp_get_public_status_id(), bbp_get_closed_status_id())), 'show_stickes' => false, 'order' => 'DESC', 'meta_query' => array(bbp_exclude_forum_ids('meta_query')));
break;
}
// Note: private and hidden forums will be excluded via the
// bbp_pre_get_posts_exclude_forums filter and function.
$widget_query = new WP_Query($topics_query);
// Topics exist
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();
$topic_id = bbp_get_topic_id($widget_query->post->ID);
$author_link = bbp_get_topic_author_link(array('post_id' => $topic_id, 'type' => 'both', 'size' => 14));
?>
<li>
<a class="bbp-forum-title" href="<?php
bbp_topic_permalink($topic_id);
?>
" title="<?php
bbp_topic_title($topic_id);
?>
"><?php
bbp_topic_title($topic_id);
?>
</a>
<?php
if ('on' == $show_user) {
?>
<?php
printf(_x('by %1$s', 'widgets', 'bbpress'), '<span class="topic-author">' . $author_link . '</span>');
?>
<?php
}
?>
<?php
if ('on' == $show_date) {
?>
<div><?php
bbp_topic_last_active_time($topic_id);
?>
</div>
<?php
}
?>
</li>
<?php
//.........这里部分代码省略.........
示例8: widget
/**
* Displays the output, the topic list
*
* @since bbPress (r2653)
*
* @param mixed $args
* @param array $instance
* @uses apply_filters() Calls 'bbp_topic_widget_title' with the title
* @uses bbp_topic_permalink() To display the topic permalink
* @uses bbp_topic_title() To display the topic title
* @uses bbp_get_topic_last_active_time() To get the topic last active
* time
* @uses bbp_get_topic_id() To get the topic id
*/
public function widget($args = array(), $instance = array())
{
// Get widget settings
$settings = $this->parse_settings($instance);
// Typical WordPress filter
$settings['title'] = apply_filters('widget_title', $settings['title'], $instance, $this->id_base);
// bbPress filter
$settings['title'] = apply_filters('bbp_topic_widget_title', $settings['title'], $instance, $this->id_base);
// How do we want to order our results?
switch ($settings['order_by']) {
// Order by most recent replies
case 'freshness':
$topics_query = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => $settings['parent_forum'], 'posts_per_page' => (int) $settings['max_shown'], 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'meta_key' => '_bbp_last_active_time', 'orderby' => 'meta_value', 'order' => 'DESC');
break;
// Order by total number of replies
// Order by total number of replies
case 'popular':
$topics_query = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => $settings['parent_forum'], 'posts_per_page' => (int) $settings['max_shown'], 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'meta_key' => '_bbp_reply_count', 'orderby' => 'meta_value', 'order' => 'DESC');
break;
// Order by which topic was created most recently
// Order by which topic was created most recently
case 'newness':
default:
$topics_query = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => $settings['parent_forum'], 'posts_per_page' => (int) $settings['max_shown'], 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'order' => 'DESC');
break;
}
// Note: private and hidden forums will be excluded via the
// bbp_pre_get_posts_normalize_forum_visibility action and function.
$widget_query = new WP_Query($topics_query);
// Bail if no topics are found
if (!$widget_query->have_posts()) {
return;
}
echo $args['before_widget'];
if (!empty($settings['title'])) {
echo $args['before_title'] . $settings['title'] . $args['after_title'];
}
?>
<ul>
<?php
while ($widget_query->have_posts()) {
$widget_query->the_post();
$topic_id = bbp_get_topic_id($widget_query->post->ID);
$author_link = '';
// Maybe get the topic author
if (!empty($settings['show_user'])) {
$author_link = bbp_get_topic_author_link(array('post_id' => $topic_id, 'type' => 'both', 'size' => 14));
}
?>
<li>
<a class="bbp-forum-title" href="<?php
bbp_topic_permalink($topic_id);
?>
"><?php
bbp_topic_title($topic_id);
?>
</a>
<?php
if (!empty($author_link)) {
?>
<?php
printf(_x('by %1$s', 'widgets', 'bbpress'), '<span class="topic-author">' . $author_link . '</span>');
?>
<?php
}
?>
<?php
if (!empty($settings['show_date'])) {
?>
<div><?php
bbp_topic_last_active_time($topic_id);
?>
</div>
<?php
}
?>
//.........这里部分代码省略.........
示例9: bbp_get_author_link
/**
* Return the author link of the post
*
* @since bbPress (r2875)
*
* @param mixed $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 = '')
{
// Default arguments
$defaults = array('post_id' => 0, 'link_title' => '', 'type' => 'both', 'size' => 80);
$r = bbp_parse_args($args, $defaults, 'get_author_link');
extract($r);
// Used as reply_id
if (is_numeric($args)) {
$post_id = $args;
}
// Confirmed topic
if (bbp_is_topic($post_id)) {
return bbp_get_topic_author_link($args);
} elseif (bbp_is_reply($post_id)) {
return bbp_get_reply_author_link($args);
} else {
$user_id = get_post_field('post_author', $post_id);
}
// Neither a reply nor a topic, so could be a revision
if (!empty($post_id)) {
// Generate title with the display name of the author
if (empty($link_title)) {
$link_title = sprintf(!bbp_is_reply_anonymous($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($link_title) ? ' title="' . $link_title . '"' : '';
$author_url = bbp_get_user_profile_url($user_id);
$anonymous = bbp_is_reply_anonymous($post_id);
// Get avatar
if ('avatar' == $type || 'both' == $type) {
$author_links[] = get_avatar($user_id, $size);
}
// Get display name
if ('name' == $type || 'both' == $type) {
$author_links[] = get_the_author_meta('display_name', $user_id);
}
// Add links if not anonymous
if (empty($anonymous)) {
foreach ($author_links as $link_text) {
$author_link[] = sprintf('<a href="%1$s"%2$s>%3$s</a>', $author_url, $link_title, $link_text);
}
$author_link = join(' ', $author_link);
// No links if anonymous
} else {
$author_link = join(' ', $author_links);
}
// No post so link is empty
} else {
$author_link = '';
}
return apply_filters('bbp_get_author_link', $author_link, $args);
}
示例10: bbp_show_lead_topic
<div class="bbp-topic-meta clearfix">
<div><span class="bbp-topic-reply-count badge"><?php
bbp_show_lead_topic() ? bbp_topic_reply_count() : bbp_topic_post_count();
?>
</span> <?php
bbp_show_lead_topic() ? _e('Replies', 'firmasite') : _e('Posts', 'firmasite');
?>
</div>
<?php
do_action('bbp_theme_before_topic_started_by');
?>
<div class="bbp-topic-started-by clearfix"> <?php
printf(__('Started by: %1$s', 'firmasite'), bbp_get_topic_author_link(array('size' => '14')));
?>
</div>
<?php
do_action('bbp_theme_after_topic_started_by');
?>
<div class="bbp-topic-freshness clearfix">
<?php
_e('Freshness', 'firmasite');
?>
:
<?php
do_action('bbp_theme_before_topic_freshness_author');
示例11: bbp_topic_pagination
<?php
bbp_topic_pagination();
?>
<?php
do_action('bbp_theme_before_topic_meta');
?>
<p class="bbp-topic-meta">
<?php
do_action('bbp_theme_before_topic_started_by');
?>
<span class="bbp-topic-started-by"><?php
printf(__('Started by: %1$s', 'omega-td'), bbp_get_topic_author_link(array('size' => '16', 'type' => 'name')));
?>
</span>
<?php
do_action('bbp_theme_after_topic_started_by');
?>
<?php
if (!bbp_is_single_forum() || bbp_get_topic_forum_id() !== bbp_get_forum_id()) {
?>
<?php
do_action('bbp_theme_before_topic_started_in');
?>
示例12: bbp_topic_pagination
<?php
bbp_topic_pagination();
?>
<?php
do_action('bbp_theme_before_topic_meta');
?>
<p class="bbp-topic-meta">
<?php
do_action('bbp_theme_before_topic_started_by');
?>
<span class="bbp-topic-started-by"><?php
printf(esc_html__('Started by: %1$s', 'monsoon'), bbp_get_topic_author_link(array('size' => '14')));
?>
</span>
<?php
do_action('bbp_theme_after_topic_started_by');
?>
</p>
<?php
do_action('bbp_theme_after_topic_meta');
?>
<?php
bbp_topic_row_actions();
示例13: 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;
}
示例14: array
$topics_query = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => $parent_forum, 'posts_per_page' => (int) $max_shown, 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'order' => 'DESC');
break;
}
// Note: private and hidden forums will be excluded via the
// bbp_pre_get_posts_normalize_forum_visibility action and function.
$widget_query = new WP_Query($topics_query);
?>
<div class="topics-thread">
<?php
while ($widget_query->have_posts()) {
$widget_query->the_post();
$topic_id = bbp_get_topic_id($widget_query->post->ID);
$author_link = '';
// Maybe get the topic author
$author_link = bbp_get_topic_author_link(array('post_id' => $topic_id, 'type' => 'both', 'size' => 50));
?>
<div class="discuss-topic">
<?php
if (!empty($author_link)) {
?>
<div class="topic-avatar">
<?php
printf(_x('%1$s', 'widgets', 'bbpress'), '<div class="topic-author">' . $author_link . '</div>');
?>
</div>
<?php
}
?>
<div class="topic-content">
<h4><a class="bbp-forum-title" href="<?php
示例15: do_action
}
?>
</div>
<div class="topic-desc">
<?php
do_action('bbp_theme_before_topic_freshness_author');
?>
<span class="bbp-topic-freshness-author"><?php
$last_reply_link = bbp_get_reply_author_link(bbp_get_forum_last_reply_id($sub_forum->ID), 50);
if ($last_reply_link != '') {
echo $last_reply_link;
} else {
echo bbp_get_topic_author_link($sub_forum->ID, 50);
}
//echo bbp_get_reply_author_link(bbp_get_forum_last_reply_id($sub_forum->ID), 50);
?>
</span>
<!-- <span class="bbp-topic-freshness-author">--><?php
//echo bbp_get_author_link( array( 'post_id' => $sub_forum->ID, 'size' => 14 ) );
?>
<!--</span>-->
<?php
do_action('bbp_theme_after_topic_freshness_author');
?>
<?php
do_action('bbp_theme_before_topic_freshness_link');