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>'; } }
public function getPostData() { $fooName = 'bbp_get_' . $this->postType . '_content'; $content = $fooName($this->postId); $return = array('autor' => array('isCurrentUser' => $this->autorId == get_current_user_id(), 'url' => bp_core_get_user_domain($this->autorId), 'avatar' => bp_core_fetch_avatar(array('item_id' => $autorId, 'height' => $imgSize, 'width' => $imgSize)), 'name' => bbp_get_reply_author_display_name($this->postId)), 'type' => $this->postType, 'attachmentList' => $this->_getAttachmentList(), 'sContent' => bbp_get_reply_content($this->postId), 'id' => $this->postId, 'likes' => 0, 'sDate' => get_post_time('j F ', false, $this->postId, true) . __('at', 'qode') . get_post_time(' H:i', false, $this->postId, true), 'sContentShort' => mb_substr($content, 0, 500), 'sContent' => $content, 'like' => get_post_meta($this->postId, 'likes', true), 'isLiked' => get_post_meta($this->postId, 'like_' . $autorId, true)); return $return; }
/** * @covers ::bbp_reply_author_display_name * @covers ::bbp_get_reply_author_display_name */ public function test_bbp_get_reply_author_display_name() { $u = $this->factory->user->create(array('display_name' => 'Barry B. Benson')); $t = $this->factory->topic->create(); $r = $this->factory->reply->create(array('post_parent' => $t, 'post_author' => $u, 'reply_meta' => array('topic_id' => $t))); $reply = bbp_get_reply_author_display_name($r); $this->assertSame('Barry B. Benson', $reply); }
/** * 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; }
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; }
/** * 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; }
/** * Return the author name of a topic or reply. * * Convenience function to ensure proper template functions are called * and correct filters are executed. Used primarily to display topic * and reply author information in the anonymous form template-part. * * @since 2.5.0 bbPress (r5119) * * @param int $post_id * * @uses bbp_is_topic_edit() * @uses bbp_get_topic_author_display_name() * @uses bbp_is_reply_edit() * @uses bbp_get_reply_author_display_name() * @uses bbp_current_anonymous_user_data() * * @return string The name of the author */ function bbp_get_author_display_name($post_id = 0) { // Define local variable(s) $retval = ''; // Topic edit if (bbp_is_topic_edit()) { $retval = bbp_get_topic_author_display_name($post_id); // Reply edit } elseif (bbp_is_reply_edit()) { $retval = bbp_get_reply_author_display_name($post_id); // Not an edit, so rely on current user cookie data } else { $retval = bbp_current_anonymous_user_data('name'); } return apply_filters('bbp_get_author_display_name', $retval, $post_id); }
/** * 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); }
public function AddBBPressForumThreadUserRating($author_link, $args) { RWLogger::LogEnterence('AddBBPressForumThreadUserRating'); $post_id = 0; $defaults = array('post_id' => 0, 'link_title' => '', 'type' => 'both', 'size' => 80, 'sep' => ' '); $r = wp_parse_args($args, $defaults); extract($r); $reply_id = bbp_get_reply_id($post_id); RWLogger::Log('AddBBPressForumThreadUserRating', 'post_id = ' . $post_id); RWLogger::Log('AddBBPressForumThreadUserRating', 'reply_id = ' . $reply_id); if (bbp_is_reply_anonymous($reply_id)) { return $author_link; } $options = array('show-info' => 'false'); // If accumulated user rating, then make sure it can not be directly rated. if ($this->IsUserAccumulatedRating()) { $options['read-only'] = 'true'; $options['show-report'] = 'false'; } $author_id = bbp_get_reply_author_id($reply_id); return $author_link . $this->EmbedRatingIfVisible($author_id, $author_id, bbp_get_reply_author_display_name($reply_id), bbp_get_reply_author_url($reply_id), 'user', false, false, false, $options); }
?> <?php bbp_reply_content(); ?> <?php do_action('bbp_theme_after_reply_content'); ?> </div> <div class="bbp-reply-footer"> <?php do_action('bbp_theme_before_reply_admin_links'); ?> <?php $reply_sep = ' - '; $reply_data = 'data-id="#content-' . bbp_get_reply_id() . '" data-url="' . bbp_get_reply_url() . '" data-author="' . bbp_get_reply_author_display_name(bbp_get_reply_id()) . '"'; $reply_link = is_user_logged_in() ? $reply_sep . '<a class="js-reply" href="#new-post" ' . $reply_data . '>Цитата</a>' : ''; bbp_reply_admin_links(array('sep' => $reply_sep, 'after' => $reply_link . '</span>')); ?> <?php do_action('bbp_theme_after_reply_admin_links'); ?> </div> </div><!-- .bbp-reply-content --> </div><!-- .reply --><!-- #post-<?php bbp_reply_id(); ?> -->
/** * Return the author link of the reply * * @since bbPress (r2717) * * @param mixed $args Optional. If an integer, it is used as reply id. * @uses bbp_get_reply_id() To get the reply id * @uses bbp_is_reply_anonymous() To check if the reply is by an * anonymous user * @uses bbp_get_reply_author() To get the reply author name * @uses bbp_get_reply_author_url() To get the reply author url * @uses bbp_get_reply_author_avatar() To get the reply author avatar * @uses bbp_get_reply_author_display_name() To get the reply author display * name * @uses bbp_get_user_display_role() To get the reply author display role * @uses bbp_get_reply_author_id() To get the reply author id * @uses apply_filters() Calls 'bbp_get_reply_author_link' with the * author link and args * @return string Author link of reply */ function bbp_get_reply_author_link($args = '') { $defaults = array('post_id' => 0, 'link_title' => '', 'type' => 'both', 'size' => 80, 'sep' => ' ', 'show_role' => false); $r = bbp_parse_args($args, $defaults, 'get_reply_author_link'); extract($r); // Used as reply_id if (is_numeric($args)) { $reply_id = bbp_get_reply_id($args); } else { $reply_id = bbp_get_reply_id($post_id); } if (!empty($reply_id)) { if (empty($link_title)) { $link_title = sprintf(!bbp_is_reply_anonymous($reply_id) ? __('View %s\'s profile', 'bbpress') : __('Visit %s\'s website', 'bbpress'), bbp_get_reply_author_display_name($reply_id)); } $link_title = !empty($link_title) ? ' title="' . $link_title . '"' : ''; $author_url = bbp_get_reply_author_url($reply_id); $anonymous = bbp_is_reply_anonymous($reply_id); // Get avatar if ('avatar' == $type || 'both' == $type) { $author_links['avatar'] = bbp_get_reply_author_avatar($reply_id, $size); } // Get display name if ('name' == $type || 'both' == $type) { $author_links['name'] = bbp_get_reply_author_display_name($reply_id); } // Add links if not anonymous if (empty($anonymous) && bbp_user_has_profile(bbp_get_reply_author_id($reply_id))) { foreach ($author_links as $link => $link_text) { $link_class = ' class="bbp-author-' . $link . '"'; $author_link[] = sprintf('<a href="%1$s"%2$s%3$s>%4$s</a>', $author_url, $link_title, $link_class, $link_text); } if (true === $show_role) { $author_link[] = bbp_get_reply_author_role(array('reply_id' => $reply_id)); } $author_link = join($sep, $author_link); // No links if anonymous } else { $author_link = join($sep, $author_links); } // No replies so link is empty } else { $author_link = ''; } return apply_filters('bbp_get_reply_author_link', $author_link, $args); }
public function AddBBPressForumThreadUserRating($author_link) { global $post; $reply_id = bbp_get_reply_id($post->ID); if (bbp_is_reply_anonymous($reply_id)) { return $author_link; } $options = array('show-info' => 'false'); // If accumulated user rating, then make sure it can not be directly rated. if ($this->IsUserAccumulatedRating()) { $options['read-only'] = 'true'; $options['show-report'] = 'false'; } $author_id = bbp_get_reply_author_id($reply_id); return $author_link . $this->EmbedRatingIfVisible($author_id, $author_id, bbp_get_reply_author_display_name($reply_id), bbp_get_reply_author_url($reply_id), 'user', false, false, false, $options); }
/** * Notify admins on new reply on the forum * * A modified/inspired version of bbp_notify_topic_subscribers() * @param type $reply_id * @param type $topic_id * @param type $forum_id * @param type $anonymous_data * @param type $reply_author * @param type $unknown_boolean * @param type $reply_to * @return boolean */ public function notify_reply($reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author, $unknown_boolean, $reply_to) { $reply_id = bbp_get_reply_id($reply_id); $topic_id = bbp_get_topic_id($topic_id); $forum_id = bbp_get_forum_id($forum_id); // Poster name $reply_author_name = bbp_get_reply_author_display_name($reply_id); remove_all_filters('bbp_get_reply_content'); remove_all_filters('bbp_get_topic_title'); // 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); $message = sprintf(__('%1$s wrote: %2$s Post Link: %3$s ----------- You are receiving this email because you askd for it. Login and visit the settings to disable these emails.', 'bbp-notify-admin'), $reply_author_name, $reply_content, $reply_url); $message = apply_filters('bbp_notify_admin_reply_mail_message', $message, $reply_id, $topic_id); if (empty($message)) { return; } $subject = apply_filters('bbp_notify_admin_reply_mail_title', $this->get_subject(__('New Reply: ', 'bbp-notify-admin') . $topic_title), $reply_id, $topic_id); if (empty($subject)) { return; } $headers = $this->get_headers(); //get all admin users $users = $this->get_users_to_notify('reply'); $users = apply_filters('bbp_notify_admin_reply_notifiable_users', $users); if (empty($users)) { return false; } //get all users emails $emails = $this->get_emails($users, 'reply'); if (empty($emails)) { return false; //no one to send to } $to_email = array_shift($emails); // Loop through users foreach ($emails as $email) { //add all other users as bcc(only applies in case we have more than 1 admin ) $headers[] = 'Bcc:' . $email; } $this->notify(array('subject' => $subject, 'message' => $message, 'to' => $to_email, 'headers' => $headers)); }
function load_more_topics() { $content = ''; ob_start(); $forum_id = $_POST['forum']; if ($topics = bbp_has_topics(array('post_parent' => $forum_id, 'posts_per_page' => 11, 'paged' => $_POST['list']))) { $counter = 0; while (bbp_topics()) { bbp_the_topic(); if (++$counter == 12) { break; } ?> <div class="topics_list_single_topic <?php $postUser = new WP_User(bbp_get_topic_author_id()); echo $postUser->has_cap('bbp_keymaster') || $postUser->has_cap('bbp_moderator') ? "isAdmin" : ""; ?> " id="topic-<?php echo bbp_get_topic_id(); ?> " data-bbp_forum_id="<?php echo $forum_id; ?> " data-id="<?php echo bbp_get_topic_id(); ?> "> <div class="single_topic_header"> <div class="photo"> <a href="<?php echo bp_core_get_user_domain(bbp_get_topic_author_id()); ?> "><?php echo bp_core_fetch_avatar(array('item_id' => bbp_get_topic_author_id(), 'height' => 40, 'width' => 40)); ?> </a> </div> <div class="info"> <div class="name"> <a href="<?php echo bp_core_get_user_domain(bbp_get_topic_author_id()); ?> "><?php echo bbp_get_topic_author_display_name(bbp_get_topic_id()); ?> </a> <?php if ($postUser->has_cap('bbp_keymaster')) { echo "<small>(Администратор форума)</small>"; } elseif ($postUser->has_cap('bbp_moderator')) { echo "<small>(Преподаватель)</small>"; } ?> </div> <div class="date"><?php echo get_post_time('j F ', false, bbp_get_topic_id(), true) . __('at', 'qode') . get_post_time(' H:i', false, bbp_get_topic_id(), true); ?> </div> </div> <?php if (bbp_get_topic_author_id() == get_current_user_id()) { ?> <a href="#" class="addi_actions_open"></a> <div class="addi_actions" style="display: none"> <ul> <li><a class="edit_action" href="#">Редактировать</a></li> <li><a class="remove_action" href="#">Удалить</a></li> </ul> </div> <?php } ?> </div> <div class="single_topic_content"> <?php $content = bbp_get_topic_content(); if (mb_strlen($content) > 500) { echo '<div class="show">' . mb_substr($content, 0, 500) . '... <a href="#" class="show_all">' . __('More', 'qode') . '</a></div>'; ?> <div class="hide"><?php echo $content; ?> </div> <?php } else { echo $content; } ?> </div> <div style="display: none" class="single_topic_content_edit"> <textarea class="edit_content"><?php echo get_post_field('post_content', bbp_get_topic_id()); ?> </textarea> <div class="edit_actions"> <button class="cancel"><?php _e('Cancel', 'qode'); ?> </button> <button class="save"><?php _e('Save', 'qode'); ?> </button> </div> </div> <div class="single_topic_replies_container"> <div class="single_topic_replies"> <?php $replies = get_posts($default = array('post_type' => bbp_get_reply_post_type(), 'post_parent' => bbp_get_topic_id(), 'posts_per_page' => 5, 'orderby' => 'date', 'order' => 'DESC', 'ignore_sticky_posts' => true)); // Stickies not supported $i = count($replies); if ($i == 5) { $count = new WP_Query($default = array('numberposts' => -1, 'post_type' => bbp_get_reply_post_type(), 'post_parent' => bbp_get_topic_id(), 'posts_per_page' => 5, 'orderby' => 'date', 'order' => 'DESC', 'ignore_sticky_posts' => true)); // Stickies not supported $count = $count->found_posts - 4; ?> <a href="#" class="load_all_replies"><i class="comments_img"></i>Просмотреть еще <?php echo $count . ' ' . custom_plural_form($count, 'комментарий', 'комментария', 'комментариев'); ?> </a> <?php } $replies = array_reverse($replies); //array_shift ( $replies ); foreach ($replies as $reply) { ?> <div class="single_topic_reply <?php $postUser = new WP_User($reply->post_author); echo $postUser->has_cap('bbp_keymaster') || $postUser->has_cap('bbp_moderator') ? "isAdmin" : ""; ?> " data-id="<?php echo $reply->ID; ?> "> <div class="photo"> <a href="<?php echo bp_core_get_user_domain($reply->post_author); ?> "><?php echo bp_core_fetch_avatar(array('item_id' => $reply->post_author, 'height' => 32, 'width' => 32)); ?> </a> </div> <div class="content_wrapper"> <div class="reply_content"> <a class="author-link" href="<?php echo bp_core_get_user_domain($reply->post_author); ?> "><?php echo bbp_get_reply_author_display_name($reply->ID); ?> </a> <?php if ($postUser->has_cap('bbp_keymaster')) { echo "<small>(Администратор форума)</small>"; } elseif ($postUser->has_cap('bbp_moderator')) { echo "<small>(Преподаватель)</small>"; } ?> <?php echo bbp_get_reply_content($reply->ID); ?> </div> <div style="display: none" class="reply_content_edit"> <textarea class="reply_content_edit_textarea"><?php echo get_post_field('post_content', $reply->ID); ?> </textarea> <div class="edit_actions"> <a class="cancel" href="#">Отменить</a> </div> </div> <div class="date"> <?php echo get_post_time('j F ', false, $reply->ID, true) . __('at', 'qode') . get_post_time(' H:i', false, $reply->ID, true); ?> </span><?php $like = get_post_meta($reply->ID, 'like_' . get_current_user_id(), true); ?> </div> </div> <?php if ($reply->post_author == get_current_user_id()) { ?> <a class="addi_actions_open" href="#"></a> <div class="addi_actions" style="display: none"> <ul> <li><a class="edit_action" href="#">Редактировать</a></li> <li><a class="remove_action" href="#">Удалить</a></li> </ul> </div> <?php } ?> </div> <?php } $url = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; ?> </div> <div class="single_topic_reply_form"> <form action="<?php echo $url; ?> #topic-<?php echo bbp_get_topic_id(); ?> " data-bbp_forum_id="<?php echo $forum_id; ?> " data-bbp_topic_id="<?php echo bbp_get_topic_id(); ?> " method="post"> <div class="photo"> <a href="<?php echo bp_core_get_user_domain(get_current_user_id()); ?> "><?php echo bp_core_fetch_avatar(array('item_id' => get_current_user_id(), 'height' => 32, 'width' => 32)); ?> </a> </div> <div class="reply-form"> <textarea placeholder="<?php _e('Введите текст сообщения...', 'qode'); ?> " name="content"></textarea> </div> <input type="hidden" name="bbp_forum_id" value="<?php echo $forum_id; ?> "> <input type="hidden" name="bbp_topic_id" value="<?php echo bbp_get_topic_id(); ?> "> <input type="hidden" name="action" value="custom-bbp-reply-create"> <input type="hidden" name="security" value="<?php echo wp_create_nonce('custom-bbp-reply-create'); ?> "> </form> </div> </div> </div> <?php } if ($counter == 11) { ?> <a class="load_more_topics" href="#"><?php _e('Load more discussions', 'qode'); ?> </a> <?php } } $content = ob_get_contents(); ob_end_clean(); die(json_encode(array('result' => 'OK', 'content' => $content))); }
href="<?php echo bp_core_get_user_domain($reply->post_author); ?> "><?php echo bp_core_fetch_avatar(array('item_id' => $reply->post_author, 'height' => 32, 'width' => 32)); ?> </a> </div> <div class="content_wrapper"> <div class="reply_content"><a class="author-link" href="<?php echo bp_core_get_user_domain($reply->post_author); ?> "><?php echo bbp_get_reply_author_display_name($reply->ID); ?> </a> <?php if ($postUser->has_cap('bbp_keymaster')) { echo "<small>(Администратор форума)</small>"; } elseif ($postUser->has_cap('bbp_moderator')) { echo "<small>(Преподаватель)</small>"; } ?> <?php echo bbp_get_reply_content($reply->ID); ?> </div> <div class="single_reply_attaches"> <?php
/** * Sends notification emails for new replies to subscribed topics * * Gets new post's ID and check if there are subscribed users to that topic, and * if there are, send notifications * * Note: in bbPress 2.6, we've moved away from 1 email per subscriber to 1 email * with everyone BCC'd. This may have negative repercussions for email services * that limit the number of addresses in a BCC field (often to around 500.) In * those cases, we recommend unhooking this function and creating your own * custom emailer script. * * @since 2.6.0 bbPress (r5413) * * @param int $reply_id ID of the newly made reply * @param int $topic_id ID of the topic of the reply * @param int $forum_id ID of the forum of the reply * @param mixed $anonymous_data Array of anonymous user data * @param int $reply_author ID of the topic author ID * * @uses bbp_is_subscriptions_active() To check if the subscriptions are active * @uses bbp_get_reply_id() To validate the reply ID * @uses bbp_get_topic_id() To validate the topic ID * @uses bbp_get_forum_id() To validate the forum ID * @uses bbp_get_reply() To get the reply * @uses bbp_is_reply_published() To make sure the reply is published * @uses bbp_get_topic_id() To validate the topic ID * @uses bbp_get_topic() To get the reply's topic * @uses bbp_is_topic_published() To make sure the topic is published * @uses bbp_get_reply_author_display_name() To get the reply author's display name * @uses do_action() Calls 'bbp_pre_notify_subscribers' with the reply id, * topic id and user id * @uses bbp_get_topic_subscribers() To get the topic subscribers * @uses apply_filters() Calls 'bbp_subscription_mail_message' with the * message, reply id, topic id and user id * @uses apply_filters() Calls 'bbp_subscription_mail_title' with the * topic title, reply id, topic id and user id * @uses apply_filters() Calls 'bbp_subscription_mail_headers' * @uses get_userdata() To get the user data * @uses wp_mail() To send the mail * @uses do_action() Calls 'bbp_post_notify_subscribers' with the reply id, * topic id and user id * @return bool True on success, false on failure */ function bbp_notify_topic_subscribers($reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $reply_author = 0) { // Bail if subscriptions are turned off if (!bbp_is_subscriptions_active()) { return false; } /** Validation ************************************************************/ $reply_id = bbp_get_reply_id($reply_id); $topic_id = bbp_get_topic_id($topic_id); $forum_id = bbp_get_forum_id($forum_id); /** Topic *****************************************************************/ // Bail if topic is not published if (!bbp_is_topic_published($topic_id)) { return false; } /** Reply *****************************************************************/ // Bail if reply is not published if (!bbp_is_reply_published($reply_id)) { return false; } // Poster name $reply_author_name = bbp_get_reply_author_display_name($reply_id); /** Mail ******************************************************************/ // Remove filters from reply content and topic title to prevent content // from being encoded with HTML entities, wrapped in paragraph tags, etc... remove_all_filters('bbp_get_reply_content'); remove_all_filters('bbp_get_topic_title'); // 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); // For plugins to filter messages per reply/topic/user $message = sprintf(__('%1$s wrote: %2$s Post Link: %3$s ----------- You are receiving this email because you subscribed to a forum topic. Login and visit the topic to unsubscribe from these emails.', 'bbpress'), $reply_author_name, $reply_content, $reply_url); $message = apply_filters('bbp_subscription_mail_message', $message, $reply_id, $topic_id); if (empty($message)) { return; } // For plugins to filter titles per reply/topic/user $subject = apply_filters('bbp_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $reply_id, $topic_id); if (empty($subject)) { return; } /** Users *****************************************************************/ // Get the noreply@ address $no_reply = bbp_get_do_not_reply_address(); // Setup "From" email address $from_email = apply_filters('bbp_subscription_from_email', $no_reply); // Setup the From header $headers = array('From: ' . get_bloginfo('name') . ' <' . $from_email . '>'); // Get topic subscribers and bail if empty $user_ids = bbp_get_topic_subscribers($topic_id, true); // Dedicated filter to manipulate user ID's to send emails to $user_ids = apply_filters('bbp_topic_subscription_user_ids', $user_ids); 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; } // Get email address of subscribed user $headers[] = 'Bcc: ' . get_userdata($user_id)->user_email; } /** Send it ***************************************************************/ // Custom headers $headers = apply_filters('bbp_subscription_mail_headers', $headers); $to_email = apply_filters('bbp_subscription_to_email', $no_reply); do_action('bbp_pre_notify_subscribers', $reply_id, $topic_id, $user_ids); // Send notification email wp_mail($to_email, $subject, $message, $headers); do_action('bbp_post_notify_subscribers', $reply_id, $topic_id, $user_ids); return true; }
/** * Sends notification emails for new posts * * Gets new post's ID and check if there are subscribed users to that topic, and * if there are, send notifications * * @since bbPress (r2668) * * @param int $reply_id ID of the newly made reply * @uses bbp_is_subscriptions_active() To check if the subscriptions are active * @uses bbp_get_reply_id() To validate the reply ID * @uses bbp_get_reply() To get the reply * @uses bbp_get_reply_topic_id() To get the topic ID of the reply * @uses bbp_is_reply_published() To make sure the reply is published * @uses bbp_get_topic_id() To validate the topic ID * @uses bbp_get_topic() To get the reply's topic * @uses bbp_is_topic_published() To make sure the topic is published * @uses get_the_author_meta() To get the author's display name * @uses do_action() Calls 'bbp_pre_notify_subscribers' with the reply id and * topic id * @uses bbp_get_topic_subscribers() To get the topic subscribers * @uses apply_filters() Calls 'bbp_subscription_mail_message' with the * message, reply id, topic id and user id * @uses get_userdata() To get the user data * @uses wp_mail() To send the mail * @uses do_action() Calls 'bbp_post_notify_subscribers' with the reply id * and topic id * @return bool True on success, false on failure */ function bbp_notify_subscribers($reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $reply_author = 0) { // Bail if subscriptions are turned off if (!bbp_is_subscriptions_active()) { return false; } /** Validation ************************************************************/ $reply_id = bbp_get_reply_id($reply_id); $topic_id = bbp_get_topic_id($topic_id); $forum_id = bbp_get_forum_id($forum_id); /** Reply *****************************************************************/ // Bail if reply is not published if (!bbp_is_reply_published($reply_id)) { return false; } /** Topic *****************************************************************/ // Bail if topic is not published if (!bbp_is_topic_published($topic_id)) { return false; } /** User ******************************************************************/ // Get subscribers and bail if empty $user_ids = bbp_get_topic_subscribers($topic_id, true); if (empty($user_ids)) { return false; } // Poster name $reply_author_name = bbp_get_reply_author_display_name($reply_id); /** Mail ******************************************************************/ do_action('bbp_pre_notify_subscribers', $reply_id, $topic_id, $user_ids); // Remove filters from reply content and topic title to prevent content // from being encoded with HTML entities, wrapped in paragraph tags, etc... remove_all_filters('bbp_get_reply_content'); remove_all_filters('bbp_get_topic_title'); // Strip tags from text $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 = get_option('blogname'); // 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; } // For plugins to filter messages per reply/topic/user $message = sprintf(__('%1$s wrote: %2$s Post Link: %3$s ----------- You are receiving this email because you subscribed to a forum topic. Login and visit the topic to unsubscribe from these emails.', 'bbpress'), $reply_author_name, $reply_content, $reply_url); $message = apply_filters('bbp_subscription_mail_message', $message, $reply_id, $topic_id, $user_id); if (empty($message)) { continue; } // For plugins to filter titles per reply/topic/user $subject = apply_filters('bbp_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $reply_id, $topic_id, $user_id); if (empty($subject)) { continue; } // Custom headers $headers = apply_filters('bbp_subscription_mail_headers', array()); // Get user data of this user $user = get_userdata($user_id); // Send notification email wp_mail($user->user_email, $subject, $message, $headers); } do_action('bbp_post_notify_subscribers', $reply_id, $topic_id, $user_ids); return true; }
/** * Return the author link of the reply * * @since bbPress (r2717) * * @param mixed $args Optional. If an integer, it is used as reply id. * @uses bbp_get_reply_id() To get the reply id * @uses bbp_is_reply_anonymous() To check if the reply is by an * anonymous user * @uses bbp_get_reply_author_url() To get the reply author url * @uses bbp_get_reply_author_avatar() To get the reply author avatar * @uses bbp_get_reply_author_display_name() To get the reply author display * name * @uses bbp_get_user_display_role() To get the reply author display role * @uses bbp_get_reply_author_id() To get the reply author id * @uses apply_filters() Calls 'bbp_get_reply_author_link' with the * author link and args * @return string Author link of reply */ function bbp_get_reply_author_link($args = '') { // Parse arguments against default values $r = bbp_parse_args($args, array('post_id' => 0, 'link_title' => '', 'type' => 'both', 'size' => 80, 'sep' => ' ', 'show_role' => false), 'get_reply_author_link'); // Used as reply_id if (is_numeric($args)) { $reply_id = bbp_get_reply_id($args); } else { $reply_id = bbp_get_reply_id($r['post_id']); } // Reply ID is good if (!empty($reply_id)) { // Get some useful reply information $author_url = bbp_get_reply_author_url($reply_id); $anonymous = bbp_is_reply_anonymous($reply_id); // Tweak link title if empty if (empty($r['link_title'])) { $link_title = sprintf(empty($anonymous) ? __('View %s\'s profile', 'bbpress') : __('Visit %s\'s website', 'bbpress'), bbp_get_reply_author_display_name($reply_id)); // Use what was passed if not } else { $link_title = $r['link_title']; } // Setup title and author_links array $link_title = !empty($link_title) ? ' title="' . esc_attr($link_title) . '"' : ''; $author_links = array(); // Get avatar if ('avatar' === $r['type'] || 'both' === $r['type']) { $author_links['avatar'] = bbp_get_reply_author_avatar($reply_id, $r['size']); } // Get display name if ('name' === $r['type'] || 'both' === $r['type']) { $author_links['name'] = bbp_get_reply_author_display_name($reply_id); } // Link class $link_class = ' class="bbp-author-' . esc_attr($r['type']) . '"'; // Add links if not anonymous and existing user if (empty($anonymous) && bbp_user_has_profile(bbp_get_reply_author_id($reply_id))) { // Assemble the links foreach ($author_links as $link => $link_text) { $link_class = ' class="bbp-author-' . $link . '"'; $author_link[] = sprintf('<a href="%1$s"%2$s%3$s>%4$s</a>', esc_url($author_url), $link_title, $link_class, $link_text); } if (true === $r['show_role']) { $author_link[] = bbp_get_reply_author_role(array('reply_id' => $reply_id)); } $author_link = implode($r['sep'], $author_link); // No links if anonymous } else { $author_link = implode($r['sep'], $author_links); } // No replies so link is empty } else { $author_link = ''; } return apply_filters('bbp_get_reply_author_link', $author_link, $r); }
public function shortcode_quote($atts, $content = null) { if (is_null($content)) return ''; if (!$this->_scope()) return $content; $atts = $this->_atts('quote', $atts); $args = isset($this->shortcodes['quote']['args']) ? $this->shortcodes['quote']['args'] : array(); $title = ''; if ($atts['quote'] != '') { $id = intval($atts['quote']); $url = bbp_get_reply_url($id); $ath = bbp_get_reply_author_display_name($id); $title = '<div class="d4p-bbt-quote-title"><a href="'.$url.'">'.$ath.' '.__("wrote", "gd-bbpress-tools").':</a></div>'; } return $this->_tag('blockquote', 'quote', $title.$content, $atts, $args); }