Exemplo n.º 1
0
    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>';
        }
    }
Exemplo n.º 2
0
 /**
  * Notify user roles on new topic
  */
 public function notify_new_topic($topic_id = 0, $forum_id = 0, $anonymous_data = 0, $topic_author = 0)
 {
     $user_roles = Falcon::get_option('bbsub_topic_notification', array());
     // bail out if no user roles found
     if (!$user_roles) {
         return;
     }
     $recipients = array();
     foreach ($user_roles as $role) {
         $users = get_users(array('role' => $role, 'fields' => array('ID', 'user_email', 'display_name')));
         $recipients = array_merge($recipients, $users);
     }
     // still no users?
     if (!$recipients) {
         return;
     }
     // subscribe the users automatically
     foreach ($recipients as $user) {
         bbp_add_user_subscription($user->ID, $topic_id);
     }
     // Sanitize the HTML into text
     $content = apply_filters('bbsub_html_to_text', bbp_get_topic_content($topic_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_topic_permalink($topic_id));
     $text = apply_filters('bbsub_topic_email_message', $text, $topic_id, $content);
     $subject = apply_filters('bbsub_topic_email_subject', 'Re: [' . get_option('blogname') . '] ' . bbp_get_topic_title($topic_id), $topic_id);
     $options = array('author' => bbp_get_topic_author_display_name($topic_id), 'id' => $topic_id);
     $this->handler->send_mail($recipients, $subject, $text, $options);
     do_action('bbp_post_notify_topic_subscribers', $topic_id, $recipients);
 }
Exemplo n.º 3
0
 /**
  * @covers ::bbp_topic_author_display_name
  * @covers ::bbp_get_topic_author_display_name
  */
 public function test_bbp_get_topic_author_display_name()
 {
     $u = $this->factory->user->create(array('display_name' => 'Barry B. Benson'));
     $t = $this->factory->topic->create(array('post_author' => $u));
     $topic = bbp_get_topic_author_display_name($t);
     $this->assertSame('Barry B. Benson', $topic);
 }
/**
 * 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 topic_message($message, $topic_id, $forum_id, $user_id)
 {
     $topic_content = strip_tags(bbp_get_topic_content($topic_id));
     $topic_url = bbp_get_topic_permalink($topic_id);
     $topic_author = bbp_get_topic_author_display_name($topic_id);
     $custom_message = get_option('_bbp_topic_notice_body');
     $message = $custom_message ? $custom_message : $message;
     $message = str_replace('{author}', $topic_author, $message);
     $message = str_replace('{content}', $topic_content, $message);
     $message = str_replace('{url}', $topic_url, $message);
     return $message;
 }
    /**
     * Notify admins on new topic
     * 
     * @param type $topic_id
     * @param type $forum_id
     * @param type $anonymous_data
     * @param type $topic_author
     * @return boolean
     */
    public function notify_topic($topic_id, $forum_id, $anonymous_data, $topic_author)
    {
        $topic_id = bbp_get_topic_id($topic_id);
        $forum_id = bbp_get_forum_id($forum_id);
        remove_all_filters('bbp_get_topic_content');
        remove_all_filters('bbp_get_topic_title');
        $topic_title = strip_tags(bbp_get_topic_title($topic_id));
        $topic_content = strip_tags(bbp_get_topic_content($topic_id));
        $topic_url = bbp_get_topic_permalink($topic_id);
        $topic_author_name = bbp_get_topic_author_display_name($topic_id);
        $message = sprintf(__('%1$s created new topic:

%2$s

Topic 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'), $topic_author_name, $topic_content, $topic_url);
        $message = apply_filters('bbp_notify_admin_topic_mail_message', $message, $topic_id, $forum_id);
        if (empty($message)) {
            return;
        }
        $subject = apply_filters('bbp_notify_admin_reply_mail_title', $this->get_subject(__('New Topic: ', 'bbp-notify-admin') . $topic_title), $topic_id, $forum_id);
        if (empty($subject)) {
            return;
        }
        $headers = $this->get_headers();
        //get the users to send an email
        $users = $this->get_users_to_notify('topic');
        $users = apply_filters('bbp_notify_admin_topic_notifiable_users', $users);
        if (empty($users)) {
            return false;
        }
        //get all users emails
        $emails = $this->get_emails($users, 'topic');
        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;
        }
        //send email
        //even if an admin posts, It will notify everyone including him
        $this->notify(array('subject' => $subject, 'message' => $message, 'to' => $to_email, 'headers' => $headers));
    }
Exemplo n.º 7
0
/**
 * Return 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_id() To get the topic id
 * @uses bbp_get_topic_author_display_name() To get the topic author
 * @uses bbp_is_topic_anonymous() To check if the topic is by an
 *                                 anonymous user
 * @uses bbp_get_topic_author_url() To get the topic author url
 * @uses bbp_get_topic_author_avatar() To get the topic author avatar
 * @uses bbp_get_topic_author_display_name() To get the topic author display
 *                                      name
 * @uses bbp_get_user_display_role() To get the topic author display role
 * @uses bbp_get_topic_author_id() To get the topic author id
 * @uses apply_filters() Calls 'bbp_get_topic_author_link' with the link
 *                        and args
 * @return string Author link of topic
 */
function bbp_get_topic_author_link($args = array())
{
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('post_id' => 0, 'link_title' => '', 'type' => 'both', 'size' => 80, 'sep' => '&nbsp;', 'show_role' => false), 'get_topic_author_link');
    // Used as topic_id
    if (is_numeric($args)) {
        $topic_id = bbp_get_topic_id($args);
    } else {
        $topic_id = bbp_get_topic_id($r['post_id']);
    }
    // Topic ID is good
    if (!empty($topic_id)) {
        // Get some useful topic information
        $author_url = bbp_get_topic_author_url($topic_id);
        $anonymous = bbp_is_topic_anonymous($topic_id);
        // Tweak link title if empty
        if (empty($r['link_title'])) {
            $title = empty($anonymous) ? __('View %s\'s profile', 'bbpress') : __('Visit %s\'s website', 'bbpress');
            $author = bbp_get_topic_author_display_name($topic_id);
            $link_title = sprintf($title, $author);
            // 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_topic_author_avatar($topic_id, $r['size']);
        }
        // Get display name
        if ('name' === $r['type'] || 'both' === $r['type']) {
            $author_links['name'] = bbp_get_topic_author_display_name($topic_id);
        }
        // Link class
        $link_class = ' class="bbp-author-' . esc_attr($r['type']) . '"';
        // Add links if not anonymous
        if (empty($anonymous) && bbp_user_has_profile(bbp_get_topic_author_id($topic_id))) {
            // Assemble the links
            foreach ($author_links as $link => $link_text) {
                $link_class = ' class="bbp-author-' . esc_attr($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_topic_author_role(array('topic_id' => $topic_id));
            }
            $author_link = implode($r['sep'], $author_link);
            // No links if anonymous
        } else {
            $author_link = implode($r['sep'], $author_links);
        }
    } else {
        $author_link = '';
    }
    return apply_filters('bbp_get_topic_author_link', $author_link, $args);
}
Exemplo n.º 8
0
/**
 * Sends notification emails for new topics to subscribed forums
 *
 * Gets new post's ID and check if there are subscribed users to that forum, 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.5.0 bbPress (r5156)
 *
 * @param int $topic_id ID of the newly made reply
 * @param int $forum_id ID of the forum for the topic
 * @param mixed $anonymous_data Array of anonymous user data
 * @param int $topic_author ID of the topic author ID
 *
 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
 * @uses bbp_get_topic_id() To validate the topic ID
 * @uses bbp_get_forum_id() To validate the forum ID
 * @uses bbp_is_topic_published() To make sure the topic is published
 * @uses bbp_get_forum_subscribers() To get the forum subscribers
 * @uses bbp_get_topic_author_display_name() To get the topic author's display name
 * @uses do_action() Calls 'bbp_pre_notify_forum_subscribers' with the topic id,
 *                    forum id and user id
 * @uses apply_filters() Calls 'bbp_forum_subscription_mail_message' with the
 *                    message, topic id, forum id and user id
 * @uses apply_filters() Calls 'bbp_forum_subscription_mail_title' with the
 *                    topic title, topic id, forum id and user id
 * @uses apply_filters() Calls 'bbp_forum_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_forum_subscribers' with the topic,
 *                    id, forum id and user id
 * @return bool True on success, false on failure
 */
function bbp_notify_forum_subscribers($topic_id = 0, $forum_id = 0, $anonymous_data = false, $topic_author = 0)
{
    // Bail if subscriptions are turned off
    if (!bbp_is_subscriptions_active()) {
        return false;
    }
    /** Validation ************************************************************/
    $topic_id = bbp_get_topic_id($topic_id);
    $forum_id = bbp_get_forum_id($forum_id);
    /**
     * Necessary for backwards compatibility
     *
     * @see https://bbpress.trac.wordpress.org/ticket/2620
     */
    $user_id = 0;
    /** Topic *****************************************************************/
    // Bail if topic is not published
    if (!bbp_is_topic_published($topic_id)) {
        return false;
    }
    // Poster name
    $topic_author_name = bbp_get_topic_author_display_name($topic_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_topic_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));
    $topic_content = strip_tags(bbp_get_topic_content($topic_id));
    $topic_url = get_permalink($topic_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

Topic Link: %3$s

-----------

You are receiving this email because you subscribed to a forum.

Login and visit the topic to unsubscribe from these emails.', 'bbpress'), $topic_author_name, $topic_content, $topic_url);
    $message = apply_filters('bbp_forum_subscription_mail_message', $message, $topic_id, $forum_id, $user_id);
    if (empty($message)) {
        return;
    }
    // For plugins to filter titles per reply/topic/user
    $subject = apply_filters('bbp_forum_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $topic_id, $forum_id, $user_id);
    if (empty($subject)) {
        return;
    }
    /** User ******************************************************************/
    // 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_forum_subscribers($forum_id, true);
    // Dedicated filter to manipulate user ID's to send emails to
    $user_ids = apply_filters('bbp_forum_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($topic_author) && (int) $user_id === (int) $topic_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_forum_subscribers', $topic_id, $forum_id, $user_ids);
    // Send notification email
    wp_mail($to_email, $subject, $message, $headers);
    do_action('bbp_post_notify_forum_subscribers', $topic_id, $forum_id, $user_ids);
    return true;
}
Exemplo n.º 9
0
/**
 * 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);
}
Exemplo n.º 10
0
            bbp_user_profile_url($topic->post_author);
            ?>
"><?php 
            bbp_topic_author_display_name();
            ?>
</a>
                            </div>
                            <div class="td-topics-title-details">
                                <?php 
            //bbp_get_reply_author_link(array('post_id' => ));
            ?>
                                Last reply by <a href="<?php 
            bbp_reply_author_url(bbp_get_topic_last_active_id());
            ?>
"><?php 
            echo bbp_get_topic_author_display_name(bbp_get_topic_last_active_id());
            ?>
</a>

                                <?php 
            bbp_topic_last_active_time();
            ?>
                            </div>

                        </li><li class="td-forum-topics-replies">
                            <?php 
            bbp_topic_reply_count();
            ?>
                        </li>
                    </ul>
                        <?php 
Exemplo n.º 11
0
/**
 * Return 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_id() To get the topic id
 * @uses bbp_get_topic_author_display_name() To get the topic author
 * @uses bbp_is_topic_anonymous() To check if the topic is by an
 *                                 anonymous user
 * @uses bbp_get_topic_author_url() To get the topic author url
 * @uses bbp_get_topic_author_avatar() To get the topic author avatar
 * @uses bbp_get_topic_author_display_name() To get the topic author display
 *                                      name
 * @uses bbp_get_user_display_role() To get the topic author display role
 * @uses bbp_get_topic_author_id() To get the topic author id
 * @uses apply_filters() Calls 'bbp_get_topic_author_link' with the link
 *                        and args
 * @return string Author link of topic
 */
function bbp_get_topic_author_link($args = '')
{
    $defaults = array('post_id' => 0, 'link_title' => '', 'type' => 'both', 'size' => 80, 'sep' => '&nbsp;', 'show_role' => false);
    $r = bbp_parse_args($args, $defaults, 'get_topic_author_link');
    extract($r);
    // Used as topic_id
    if (is_numeric($args)) {
        $topic_id = bbp_get_topic_id($args);
    } else {
        $topic_id = bbp_get_topic_id($post_id);
    }
    // Topic ID is good
    if (!empty($topic_id)) {
        // Tweak link title if empty
        if (empty($link_title)) {
            $link_title = sprintf(!bbp_is_topic_anonymous($topic_id) ? __('View %s\'s profile', 'bbpress') : __('Visit %s\'s website', 'bbpress'), bbp_get_topic_author_display_name($topic_id));
        }
        $link_title = !empty($link_title) ? ' title="' . $link_title . '"' : '';
        $author_url = bbp_get_topic_author_url($topic_id);
        $anonymous = bbp_is_topic_anonymous($topic_id);
        $author_links = array();
        // Get avatar
        if ('avatar' == $type || 'both' == $type) {
            $author_links['avatar'] = bbp_get_topic_author_avatar($topic_id, $size);
        }
        // Get display name
        if ('name' == $type || 'both' == $type) {
            $author_links['name'] = bbp_get_topic_author_display_name($topic_id);
        }
        // Link class
        $link_class = ' class="bbp-author-' . $type . '"';
        // Add links if not anonymous
        if (empty($anonymous)) {
            // 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>', $author_url, $link_title, $link_class, $link_text);
            }
            if (true === $show_role) {
                $author_link[] = bbp_get_topic_author_role(array('topic_id' => $topic_id));
            }
            $author_link = join($sep, $author_link);
            // No links if anonymous
        } else {
            $author_link = join($sep, $author_links);
        }
    } else {
        $author_link = '';
    }
    return apply_filters('bbp_get_topic_author_link', $author_link, $args);
}
Exemplo n.º 12
0
/**
 * Sends notification emails for new topics to subscribed forums
 *
 * Gets new post's ID and check if there are subscribed users to that topic, and
 * if there are, send notifications
 *
 * @since bbPress (r5156)
 *
 * @param int $topic_id ID of the newly made reply
 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
 * @uses bbp_get_topic_id() To validate the topic ID
 * @uses bbp_get_forum_id() To validate the forum ID
 * @uses bbp_is_topic_published() To make sure the topic is published
 * @uses bbp_get_forum_subscribers() To get the forum subscribers
 * @uses bbp_get_topic_author_display_name() To get the topic author's display name
 * @uses do_action() Calls 'bbp_pre_notify_forum_subscribers' with the topic id,
 *                    forum id and user id
 * @uses apply_filters() Calls 'bbp_forum_subscription_mail_message' with the
 *                    message, topic id, forum id and user id
 * @uses apply_filters() Calls 'bbp_forum_subscription_mail_title' with the
 *                    topic title, topic id, forum id and user id
 * @uses apply_filters() Calls 'bbp_forum_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_forum_subscribers' with the topic,
 *                    id, forum id and user id
 * @return bool True on success, false on failure
 */
function bbp_notify_forum_subscribers($topic_id = 0, $forum_id = 0, $anonymous_data = false, $topic_author = 0)
{
    // Bail if subscriptions are turned off
    if (!bbp_is_subscriptions_active()) {
        return false;
    }
    /** Validation ************************************************************/
    $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;
    }
    /** User ******************************************************************/
    // Get forum subscribers and bail if empty
    $user_ids = bbp_get_forum_subscribers($forum_id, true);
    if (empty($user_ids)) {
        return false;
    }
    // Poster name
    $topic_author_name = bbp_get_topic_author_display_name($topic_id);
    /** Mail ******************************************************************/
    do_action('bbp_pre_notify_forum_subscribers', $topic_id, $forum_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_topic_content');
    remove_all_filters('bbp_get_topic_title');
    // Strip tags from text
    $topic_title = strip_tags(bbp_get_topic_title($topic_id));
    $topic_content = strip_tags(bbp_get_topic_content($topic_id));
    $topic_url = get_permalink($topic_id);
    $blog_name = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
    // Loop through users
    foreach ((array) $user_ids as $user_id) {
        // Don't send notifications to the person who made the post
        if (!empty($topic_author) && (int) $user_id === (int) $topic_author) {
            continue;
        }
        // For plugins to filter messages per reply/topic/user
        $message = sprintf(__('%1$s wrote:

%2$s

Topic Link: %3$s

-----------

You are receiving this email because you subscribed to a forum.

Login and visit the topic to unsubscribe from these emails.', 'bbpress'), $topic_author_name, $topic_content, $topic_url);
        $message = apply_filters('bbp_forum_subscription_mail_message', $message, $topic_id, $forum_id, $user_id);
        if (empty($message)) {
            continue;
        }
        // For plugins to filter titles per reply/topic/user
        $subject = apply_filters('bbp_forum_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $topic_id, $forum_id, $user_id);
        if (empty($subject)) {
            continue;
        }
        // Custom headers
        $headers = apply_filters('bbp_forum_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_forum_subscribers', $topic_id, $forum_id, $user_ids);
    return true;
}
Exemplo n.º 13
0
function td_show_forum($forum_object)
{
    $last_active = bbp_get_forum_last_active_id($forum_object->ID);
    $time_since = '';
    $last_updated_by_avatar = '';
    if (!empty($last_active)) {
        $time_since = bbp_get_forum_freshness_link($forum_object->ID);
        $last_updated_by_avatar = bbp_get_author_link(array('post_id' => $last_active, 'size' => 40, 'type' => 'avatar'));
        //echo $time_since;
    }
    ?>
    <div class="clearfix"></div>
    <ul class="td-forum-list-table td-forum-content">
        <li class="td-forum-category-title<?php 
    if (empty($forum_object->post_content)) {
        echo ' td-forum-title-no-desc';
    }
    ?>
">
            <div class="td-forum-index-padd">
                <a class="bbp-forum-title" href="<?php 
    bbp_forum_permalink($forum_object->ID);
    ?>
"><?php 
    bbp_forum_title($forum_object->ID);
    ?>
</a>
                <?php 
    if (!empty($forum_object->post_content)) {
        ?>
                    <div class="td-forum-description"><?php 
        echo $forum_object->post_content;
        ?>
</div>
                <?php 
    }
    ?>

                </li><li class="td-forum-replies">
                    <div><?php 
    echo bbp_get_forum_topic_count($forum_object->ID);
    ?>
 topics</div>
                    <div><?php 
    echo bbp_get_forum_reply_count($forum_object->ID);
    ?>
 replies</div>
                </li><li class="td-forum-last-comment">

                <div>
                    <?php 
    echo $last_updated_by_avatar;
    ?>
                </div>



                <div class="td-forum-last-comment-content">
                    <div class="td-forum-author-name">
                        by <a class="td-forum-last-author" href="<?php 
    bbp_reply_author_url($last_active);
    ?>
"><?php 
    echo bbp_get_topic_author_display_name($last_active);
    ?>
</a>
                    </div>
                    <div class="td-forum-time-comment">
                        <?php 
    bbp_forum_freshness_link($forum_object->ID);
    ?>
                    </div>
                </div>
        </li>
    </ul>
    <div class="clearfix"></div>
    <?php 
}
										                    <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>
Exemplo n.º 15
0
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)));
}