Ejemplo n.º 1
0
function cuttz_bbpress_layout($layout)
{
    if (!is_bbpress()) {
        return $layout;
    }
    //get current layout saved in genesis setting
    $gsettings = get_option(GENESIS_SETTINGS_FIELD, null);
    $layout = isset($gsettings['site_layout']) ? $gsettings['site_layout'] : null;
    $set = genesis_get_option('bbpress-layout', cuttz_get_skin_page_id(), false);
    $set = $set == 'default' ? $layout : $set;
    // if no setting in Cuttz defined then use Genesis setting
    $forum_id = bbp_get_forum_id();
    $forumlayout = false;
    if (!empty($forum_id)) {
        $forumlayout = esc_attr(get_post_meta($forum_id, '_genesis_layout', true));
        if (!empty($forumlayout)) {
            return $forumlayout;
        }
    }
    if (empty($forumlayout)) {
        return $set;
    }
    if (is_user_logged_in()) {
    }
    return $set;
}
Ejemplo n.º 2
0
function pg_has_topics($args = '')
{
    //check if being called by subscriptions and if so skip filtering (as you can only subscribe to forums you can already see)
    if ($args['post__in']) {
        return $args;
    }
    $default_post_parent = bbp_is_single_forum() ? bbp_get_forum_id() : 'any';
    if ($default_post_parent == 'any') {
        if (bbp_is_user_keymaster()) {
            return $args;
        }
        $user_id = wp_get_current_user()->ID;
        if (user_can($user_id, 'moderate')) {
            $check = get_user_meta($user_id, 'private_group', true);
            if ($check == '') {
                return $args;
            }
        }
        global $wpdb;
        $topic = bbp_get_topic_post_type();
        $post_ids = $wpdb->get_col("select ID from {$wpdb->posts} where post_type = '{$topic}'");
        //check this list against those the user is allowed to see, and create a list of valid ones for the wp_query in bbp_has_topics
        $allowed_posts = check_private_groups_topic_ids($post_ids);
        $args['post__in'] = $allowed_posts;
    }
    return $args;
}
 public function bbPress_submit()
 {
     $id = bbp_get_topic_id();
     if (empty($id)) {
         $id = bbp_get_forum_id();
     }
     $this->comments->Comment_form_action($id);
 }
function bbps_hide_forum_meta($retval, $forum_id = 0)
{
    if (bbps_is_premium_forum(bbp_get_forum_id()) == false || current_user_can('administrator') || current_user_can('bbp_moderator')) {
        return $retval;
    } else {
        return $retval = '-';
    }
}
Ejemplo n.º 5
0
    /**
     * Displays the output, the forum list
     *
     * @since bbPress (r2653)
     *
     * @param mixed $args Arguments
     * @param array $instance Instance
     * @uses apply_filters() Calls 'bbp_forum_widget_title' with the title
     * @uses get_option() To get the forums per page option
     * @uses current_user_can() To check if the current user can read
     *                           private() To resety name
     * @uses bbp_has_forums() The main forum loop
     * @uses bbp_forums() To check whether there are more forums available
     *                     in the loop
     * @uses bbp_the_forum() Loads up the current forum in the loop
     * @uses bbp_forum_permalink() To display the forum permalink
     * @uses bbp_forum_title() To display the forum title
     */
    public function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('bbp_forum_widget_title', $instance['title']);
        $parent_forum = !empty($instance['parent_forum']) ? $instance['parent_forum'] : '0';
        // Note: private and hidden forums will be excluded via the
        // bbp_pre_get_posts_exclude_forums filter and function.
        $widget_query = new WP_Query(array('post_parent' => $parent_forum, 'post_type' => bbp_get_forum_post_type(), 'posts_per_page' => get_option('_bbp_forums_per_page', 50), 'orderby' => 'menu_order', 'order' => 'ASC'));
        if ($widget_query->have_posts()) {
            echo $before_widget;
            echo $before_title . $title . $after_title;
            $current_forum_id = bbp_get_forum_id();
            ?>

			<ul>

				<?php 
            while ($widget_query->have_posts()) {
                $widget_query->the_post();
                ?>

					<?php 
                $current = $widget_query->post->ID == $current_forum_id ? 'current' : '';
                ?>

					<li>
						<a class="bbp-forum-title <?php 
                echo $current;
                ?>
" href="<?php 
                bbp_forum_permalink($widget_query->post->ID);
                ?>
" title="<?php 
                bbp_forum_title($widget_query->post->ID);
                ?>
">
							<?php 
                bbp_forum_title($widget_query->post->ID);
                ?>
						</a>
						<span class="topic-count"><?php 
                bbp_forum_topic_count($widget_query->post->ID);
                ?>
</span>
					</li>

				<?php 
            }
            ?>

			</ul>

			<?php 
            echo $after_widget;
            // Reset the $post global
            wp_reset_postdata();
        }
    }
 public function get_envato_item_ids()
 {
     $item_ids = 0;
     if (function_exists('bbp_get_forum_id')) {
         $forum_id = bbp_get_forum_id();
         $item_ids = get_post_meta($forum_id, '_ss_envato_items', true);
     }
     return $item_ids;
 }
Ejemplo n.º 7
0
 /**
  * Sidebars to be displayed with forums will also 
  * be dislpayed with respective topics and replies
  *
  * @since  1.0
  * @param  string $where 
  * @return string 
  */
 public function add_forum_dependency($where)
 {
     if (is_singular(array('topic', 'reply'))) {
         $data = array(get_post_type(), get_the_ID(), 'forum');
         if (function_exists('bbp_get_forum_id')) {
             $data[] = bbp_get_forum_id();
         }
         $where = "(post_type.meta_value IS NULL OR post_type.meta_value IN('" . implode("','", $data) . "'))";
     }
     return $where;
 }
Ejemplo n.º 8
0
 /**
  * Check if the current page is forum, topic or other bbPress page.
  *
  * @return bool true if the current page is the forum related
  */
 function d4p_is_bbpress()
 {
     $is = false;
     if (function_exists("bbp_get_forum_id")) {
         $is = bbp_get_forum_id() > 0 || bbp_get_reply_id() > 0 || bbp_get_topic_id() > 0;
         if (!$is) {
             global $template;
             $templates = array("single-reply-edit.php", "single-topic-edit.php");
             $file = pathinfo($template, PATHINFO_BASENAME);
             $is = in_array($file, $templates);
         }
     }
     return apply_filters('d4p_is_bbpress', $is);
 }
Ejemplo n.º 9
0
 /**
  * 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;
 }
function gpbbp_new_post($post_id, $post, $update)
{
    $TOPIC_POST_TYPE = bbp_get_topic_post_type();
    $REPLY_POST_TYPE = bbp_get_reply_post_type();
    $post_type = get_post_type($post);
    $forum_id = NULL;
    if ($post_type == $TOPIC_POST_TYPE) {
        $forum_id = wp_get_post_parent_id($post_id);
        gpbbp_apply_capabilities_from_forum($post_id, $forum_id);
    }
    if ($post_type == $REPLY_POST_TYPE) {
        $forum_id = bbp_get_forum_id();
        gpbbp_apply_capabilities_from_forum($post_id, $forum_id);
    }
    gpbbp_new_post_notification($post_id, $post, $post_type);
}
Ejemplo n.º 11
0
 public function check_forum()
 {
     // check forum page
     if (!$this->options->get('redirect')) {
         return;
     }
     $forum_id = bbp_get_forum_id();
     if (!empty($forum_id) && !$this->user->can_create_topic()) {
         $verify_page_id = ss_get_verify_page_id();
         $verify_page = get_permalink($verify_page_id);
         $login_page = wp_login_url();
         if (!$this->user->is_logged()) {
             wp_redirect($login_page);
             die;
         }
         wp_redirect($verify_page);
         die;
     }
 }
Ejemplo n.º 12
0
function bbp_get_topic_write_url($forum_id = 0)
{
    global $wp_rewrite;
    $bbp = bbpress();
    $forum = bbp_get_forum(bbp_get_forum_id($forum_id));
    if (empty($forum)) {
        return;
    }
    // Remove view=all link from edit
    $forum_link = bbp_get_forum_permalink($forum_id);
    // Pretty permalinks
    if ($wp_rewrite->using_permalinks()) {
        $url = trailingslashit($forum_link) . $bbp->write_id;
        $url = trailingslashit($url);
        // Unpretty permalinks
    } else {
        $url = add_query_arg(array(bbp_get_forum_post_type() => $forum->post_name, $bbp->write_id => '1'), $forum_link);
    }
    return apply_filters('bbp_get_topic_write_url', $url, $forum_id);
}
Ejemplo n.º 13
0
 static function user_has_cap($allcaps, $caps, $args, $user)
 {
     static $doing = false;
     // bypass if non-bbpress contents and avoid infinite loop
     if ($doing === true || !did_action('wp') || !is_bbpress()) {
         return $allcaps;
     }
     $bbp_allcaps = bbp_get_caps_for_role(bbp_get_keymaster_role());
     $check_caps = array_intersect(array_values($caps), array_keys($bbp_allcaps));
     if (!$check_caps && in_array('upload_files', $caps)) {
         $check_caps = array('upload_files');
     }
     // bypass non bbpress caps
     if (!$check_caps || in_array('keep_gate', $check_caps)) {
         return $allcaps;
     }
     $doing = true;
     if (!($forum_id = bbp_get_forum_id())) {
         $doing = false;
         return $allcaps;
     }
     // Give all modorator capabilities to optional forum moderators per forum
     $moderators = bbpresskr()->forum_option('moderators', $forum_id);
     if (in_array($user->ID, $moderators) && ($new_caps = bbp_get_caps_for_role(bbp_get_moderator_role()))) {
         // remove all bbpress capabilities and append for asigned role only
         $_allcaps = array_diff_assoc($allcaps, $bbp_allcaps);
         $allcaps = array_merge($_allcaps, $new_caps);
         $allcaps['upload_files'] = true;
     }
     // In case we use usermeta for forum moderator setting
     /*$metakey = "forum_role_{$forum_id}";
     		// Dobule check forum role still exists. Role may excluded by plugin or updates.
     		if ( isset( $user->$metakey ) && ($new_caps = bbp_get_caps_for_role( $user->$metakey )) ) {
     			// remove all bbpress capabilities and append for asigned role only
     			$_allcaps = array_diff_assoc( $allcaps, $bbp_allcaps );
     			$allcaps = array_merge( $_allcaps, $new_caps );
     			$allcaps['upload_files'] = true;
     		}*/
     $doing = false;
     return $allcaps;
 }
/**
 * This function filters the list of sub-forums based on the the users group
 */
function private_groups_get_permitted_subforums($sub_forums = '')
{
    //this code is from includes/forums/template bbp_forum_get_subforums and sets up which forums to look in based on user capabilities
    // Use passed integer as post_parent
    if (is_numeric($args)) {
        $args = array('post_parent' => $args);
    }
    // Setup possible post__not_in array
    $post_stati[] = bbp_get_public_status_id();
    // Super admin get whitelisted post statuses
    if (bbp_is_user_keymaster()) {
        $post_stati = array(bbp_get_public_status_id(), bbp_get_private_status_id(), bbp_get_hidden_status_id());
        // Not a keymaster, so check caps
    } else {
        // Check if user can read private forums
        if (current_user_can('read_private_forums')) {
            $post_stati[] = bbp_get_private_status_id();
        }
        // Check if user can read hidden forums
        if (current_user_can('read_hidden_forums')) {
            $post_stati[] = bbp_get_hidden_status_id();
        }
    }
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('post_parent' => 0, 'post_type' => bbp_get_forum_post_type(), 'post_status' => implode(',', $post_stati), 'posts_per_page' => get_option('_bbp_forums_per_page', 50), 'orderby' => 'menu_order title', 'order' => 'ASC', 'ignore_sticky_posts' => true, 'no_found_rows' => true), 'forum_get_subforums');
    $r['post_parent'] = bbp_get_forum_id($r['post_parent']);
    // Create a new query for the subforums
    $get_posts = new WP_Query();
    // No forum passed
    $sub_forums = !empty($r['post_parent']) ? $get_posts->query($r) : array();
    global $rpg_settingsf;
    //if make forums visible set, then show all public forums
    if ($rpg_settingsf['set_forum_visibility']) {
        return (array) apply_filters('pg_forum_get_subforums', $sub_forums, $r);
    }
    //Otherwise now we filter this list to exclude those that the user can't see either because not logged in, or forum does not allowed this group
    $filtered_sub_forums = private_groups_get_permitted_forums($sub_forums);
    return (array) apply_filters('pg_forum_get_subforums', $filtered_sub_forums, $r);
    //}
}
function tehnik_bpp_get_forum_id_from_post_id($post_id, $post_type)
{
    $forum_id = 0;
    // Check post type
    switch ($post_type) {
        // Forum
        case bbp_get_forum_post_type():
            $forum_id = bbp_get_forum_id($post_id);
            break;
            // Topic
        // Topic
        case bbp_get_topic_post_type():
            $forum_id = bbp_get_topic_forum_id($post_id);
            break;
            // Reply
        // Reply
        case bbp_get_reply_post_type():
            $forum_id = bbp_get_reply_forum_id($post_id);
            break;
    }
    return $forum_id;
}
/**
 * This function filters the list of forums based on the users rank as set by the Mebmers plugin
 */
function tehnik_bpp_filter_forums_by_permissions($args = '')
{
    $bbp = bbpress();
    // Setup possible post__not_in array
    $post_stati[] = bbp_get_public_status_id();
    // Check if user can read private forums
    if (current_user_can('read_private_forums')) {
        $post_stati[] = bbp_get_private_status_id();
    }
    // Check if user can read hidden forums
    if (current_user_can('read_hidden_forums')) {
        $post_stati[] = bbp_get_hidden_status_id();
    }
    // The default forum query for most circumstances
    $meta_query = array('post_type' => bbp_get_forum_post_type(), 'post_parent' => bbp_is_forum_archive() ? 0 : bbp_get_forum_id(), 'post_status' => implode(',', $post_stati), 'posts_per_page' => get_option('_bbp_forums_per_page', 50), 'orderby' => 'menu_order', 'order' => 'ASC');
    //Get an array of IDs which the current user has permissions to view
    $allowed_forums = tehnik_bpp_get_permitted_post_ids(new WP_Query($meta_query));
    // The default forum query with allowed forum ids array added
    $meta_query['post__in'] = $allowed_forums;
    $bbp_f = bbp_parse_args($args, $meta_query, 'has_forums');
    // Run the query
    $bbp->forum_query = new WP_Query($bbp_f);
    return apply_filters('bpp_filter_forums_by_permissions', $bbp->forum_query->have_posts(), $bbp->forum_query);
}
Ejemplo n.º 17
0
/**
 * this function changes the bbp freshness data (time since) into a last post date for forums
 * @return string Formatted date-time
 */
function change_freshness_forum()
{
    // Verify forum and get last active meta
    $forum_id = bbp_get_forum_id($forum_id);
    $last_active = get_post_meta($forum_id, '_bbp_last_active_time', true);
    if (empty($last_active)) {
        $reply_id = bbp_get_forum_last_reply_id($forum_id);
        if (!empty($reply_id)) {
            $last_active = get_post_field('post_date', $reply_id);
        } else {
            $topic_id = bbp_get_forum_last_topic_id($forum_id);
            if (!empty($topic_id)) {
                $last_active = bbp_get_topic_last_active_time($topic_id);
            }
        }
    }
    $last_active = bbp_convert_date($last_active);
    $date_format = get_option('date_format');
    $time_format = get_option('time_format');
    $date = date_i18n("{$date_format}", $last_active);
    $time = date_i18n("{$time_format}", $last_active);
    $active_time = sprintf(_x('%1$s, %2$s', 'date at time', 'bbp-last-post'), $date, $time);
    return $active_time;
}
Ejemplo n.º 18
0
/**
 * Update the reply with its forum id it is in
 *
 * @since bbPress (r2855)
 *
 * @param int $reply_id Optional. Reply id to update
 * @param int $forum_id Optional. Forum id
 * @uses bbp_get_reply_id() To get the reply id
 * @uses bbp_get_forum_id() To get the forum id
 * @uses get_post_ancestors() To get the reply's forum
 * @uses get_post_field() To get the post type of the post
 * @uses update_post_meta() To update the reply forum id meta
 * @uses apply_filters() Calls 'bbp_update_reply_forum_id' with the forum id
 *                        and reply id
 * @return bool Reply's forum id
 */
function bbp_update_reply_forum_id($reply_id = 0, $forum_id = 0)
{
    // Validation
    $reply_id = bbp_get_reply_id($reply_id);
    $forum_id = bbp_get_forum_id($forum_id);
    // If no forum_id was passed, walk up ancestors and look for forum type
    if (empty($forum_id)) {
        // Get ancestors
        $ancestors = (array) get_post_ancestors($reply_id);
        // Loop through ancestors
        if (!empty($ancestors)) {
            foreach ($ancestors as $ancestor) {
                // Get first parent that is a forum
                if (get_post_field('post_type', $ancestor) === bbp_get_forum_post_type()) {
                    $forum_id = $ancestor;
                    // Found a forum, so exit the loop and continue
                    continue;
                }
            }
        }
    }
    // Update the forum ID
    bbp_update_forum_id($reply_id, $forum_id);
    return apply_filters('bbp_update_reply_forum_id', (int) $forum_id, $reply_id);
}
Ejemplo n.º 19
0
/**
 * Reset main query vars and filter 'the_content' to output a bbPress
 * template part as needed.
 *
 * @since bbPress (r3032)
 * @param string $template
 * @uses bbp_is_single_user() To check if page is single user
 * @uses bbp_get_single_user_template() To get user template
 * @uses bbp_is_single_user_edit() To check if page is single user edit
 * @uses bbp_get_single_user_edit_template() To get user edit template
 * @uses bbp_is_single_view() To check if page is single view
 * @uses bbp_get_single_view_template() To get view template
 * @uses bbp_is_forum_edit() To check if page is forum edit
 * @uses bbp_get_forum_edit_template() To get forum edit template
 * @uses bbp_is_topic_merge() To check if page is topic merge
 * @uses bbp_get_topic_merge_template() To get topic merge template
 * @uses bbp_is_topic_split() To check if page is topic split
 * @uses bbp_get_topic_split_template() To get topic split template
 * @uses bbp_is_topic_edit() To check if page is topic edit
 * @uses bbp_get_topic_edit_template() To get topic edit template
 * @uses bbp_is_reply_edit() To check if page is reply edit
 * @uses bbp_get_reply_edit_template() To get reply edit template
 * @uses bbp_set_theme_compat_template() To set the global theme compat template
 */
function bbp_template_include_theme_compat($template = '')
{
    // Bail if the template already matches a bbPress template. This includes
    // archive-* and single-* WordPress post_type matches (allowing
    // themes to use the expected format) as well as all bbPress-specific
    // template files for users, topics, forums, etc...
    if (!empty(bbpress()->theme_compat->bbpress_template)) {
        return $template;
    }
    /** Users *************************************************************/
    if (bbp_is_single_user_edit() || bbp_is_single_user()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => '', 'post_title' => esc_attr(bbp_get_displayed_user_field('display_name')), 'post_status' => bbp_get_public_status_id(), 'is_archive' => false, 'comment_status' => 'closed'));
        /** Forums ************************************************************/
        // Forum archive
    } elseif (bbp_is_forum_archive()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => bbp_get_forum_archive_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_public_status_id(), 'is_archive' => true, 'comment_status' => 'closed'));
        // Single Forum
    } elseif (bbp_is_forum_edit() || bbp_is_single_forum()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => bbp_get_forum_id(), 'post_title' => bbp_get_forum_title(), 'post_author' => bbp_get_forum_author_id(), 'post_date' => 0, 'post_content' => get_post_field('post_content', bbp_get_forum_id()), 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_forum_visibility(), 'is_single' => true, 'comment_status' => 'closed'));
        /** Topics ************************************************************/
        // Topic archive
    } elseif (bbp_is_topic_archive()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => bbp_get_topic_archive_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => bbp_get_topic_post_type(), 'post_status' => bbp_get_public_status_id(), 'is_archive' => true, 'comment_status' => 'closed'));
        // Single Topic
    } elseif (bbp_is_topic_edit() || bbp_is_single_topic()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => bbp_get_topic_id(), 'post_title' => bbp_get_topic_title(), 'post_author' => bbp_get_topic_author_id(), 'post_date' => 0, 'post_content' => get_post_field('post_content', bbp_get_topic_id()), 'post_type' => bbp_get_topic_post_type(), 'post_status' => bbp_get_topic_status(), 'is_single' => true, 'comment_status' => 'closed'));
        /** Replies ***********************************************************/
        // Reply archive
    } elseif (is_post_type_archive(bbp_get_reply_post_type())) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => __('Replies', 'bbpress'), 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed'));
        // Single Reply
    } elseif (bbp_is_reply_edit() || bbp_is_single_reply()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => bbp_get_reply_id(), 'post_title' => bbp_get_reply_title(), 'post_author' => bbp_get_reply_author_id(), 'post_date' => 0, 'post_content' => get_post_field('post_content', bbp_get_reply_id()), 'post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_reply_status(), 'comment_status' => 'closed'));
        /** Views *************************************************************/
    } elseif (bbp_is_single_view()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => bbp_get_view_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => '', 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed'));
        /** Topic Tags ********************************************************/
        // Topic Tag Edit
    } elseif (bbp_is_topic_tag_edit() || bbp_is_topic_tag()) {
        // Stash the current term in a new var
        set_query_var('bbp_topic_tag', get_query_var('term'));
        // Reset the post with our new title
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => '', 'post_title' => sprintf(__('Topic Tag: %s', 'bbpress'), '<span>' . bbp_get_topic_tag_name() . '</span>'), 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed'));
    }
    /**
     * If we are relying on bbPress's built in theme compatibility to load
     * the proper content, we need to intercept the_content, replace the
     * output, and display ours instead.
     *
     * To do this, we first remove all filters from 'the_content' and hook
     * our own function into it, which runs a series of checks to determine
     * the context, and then uses the built in shortcodes to output the
     * correct results from inside an output buffer.
     *
     * Uses bbp_get_theme_compat_templates() to provide fall-backs that
     * should be coded without superfluous mark-up and logic (prev/next
     * navigation, comments, date/time, etc...)
     * 
     * Hook into the 'bbp_get_bbpress_template' to override the array of
     * possible templates, or 'bbp_bbpress_template' to override the result.
     */
    if (bbp_is_theme_compat_active()) {
        // Remove all filters from the_content
        bbp_remove_all_filters('the_content');
        // Add a filter on the_content late, which we will later remove
        add_filter('the_content', 'bbp_replace_the_content');
        // Find the appropriate template file
        $template = bbp_get_theme_compat_templates();
    }
    return apply_filters('bbp_template_include_theme_compat', $template);
}
Ejemplo n.º 20
0
 public function is_hidden_from_visitors($forum_id = 0)
 {
     $forum_id = $forum_id == 0 ? bbp_get_forum_id() : $forum_id;
     $value = $this->o['hide_from_visitors'];
     $meta = get_post_meta($forum_id, '_gdbbatt_settings', true);
     if (is_array($meta) && $meta['to_override'] == 1) {
         $value = $meta['hide_from_visitors'];
     }
     return apply_filters('d4p_bbpressattchment_is_hidden_from_visitors', $value == 1);
 }
Ejemplo n.º 21
0
			<?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');
    ?>

				<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()));
    ?>
</span>

				<?php 
    do_action('bbp_theme_after_topic_started_in');
    ?>
Ejemplo n.º 22
0
    function stachestack_bbps_add_support_forum_features()
    {
        //only display all this stuff if the support forum option has been selected.
        if (bbps_is_support_forum(bbp_get_forum_id())) {
            $can_edit = bbps_get_update_capabilities();
            $topic_id = bbp_get_topic_id();
            $status = bbps_get_topic_status($topic_id);
            $forum_id = bbp_get_forum_id();
            $user_id = get_current_user_id();
            ?>
 <div id="bbps_support_forum_options"> <?php 
            //get out the option to tell us who is allowed to view and update the drop down list.
            if ($can_edit == true) {
                ?>
			<?php 
                bbps_generate_status_options($topic_id, $status);
            } else {
                ?>
			This topic is: <?php 
                echo $status;
            }
            ?>
 </div> <?php 
            //has the user enabled the move topic feature?
            if (get_option('_bbps_enable_topic_move') == 1 && (current_user_can('administrator') || current_user_can('bbp_moderator'))) {
                ?>
		<div id ="bbps_support_forum_move">
			<form id="bbps-topic-move" class="form-horizontal" role="form" name="bbps_support_topic_move" action="" method="post">
				<div class="form-group">
					<label for="bbp_forum_id" class="control-label">Move topic to: </label><?php 
                stachestack_bbp_dropdown();
                ?>
					<input type="hidden" value="bbps_move_topic" name="bbps_action"/>
					<input type="hidden" value="<?php 
                echo $topic_id;
                ?>
" name="bbps_topic_id" />
					<input type="hidden" value="<?php 
                echo $forum_id;
                ?>
" name="bbp_old_forum_id" />
				</div>
				<input type="submit" value="Move" name="bbps_topic_move_submit" class="btn btn-default" />
			</form>
		</div>  <?php 
            }
        }
    }
Ejemplo n.º 23
0
/**
 * Output an RSS2 feed of topics, based on the query passed.
 *
 * @since bbPress (r3171)
 *
 * @uses bbp_version()
 * @uses bbp_is_single_topic()
 * @uses bbp_user_can_view_forum()
 * @uses bbp_get_topic_forum_id()
 * @uses bbp_show_load_topic()
 * @uses bbp_topic_permalink()
 * @uses bbp_topic_title()
 * @uses bbp_get_topic_reply_count()
 * @uses bbp_topic_content()
 * @uses bbp_has_topics()
 * @uses bbp_topics()
 * @uses bbp_the_topic()
 * @uses get_wp_title_rss()
 * @uses get_option()
 * @uses bloginfo_rss
 * @uses self_link()
 * @uses the_author()
 * @uses get_post_time()
 * @uses rss_enclosure()
 * @uses do_action()
 * @uses apply_filters()
 *
 * @param array $topics_query
 */
function bbp_display_topics_feed_rss2($topics_query = array())
{
    // User cannot access this forum
    if (bbp_is_single_forum() && !bbp_user_can_view_forum(array('forum_id' => bbp_get_forum_id()))) {
        return;
    }
    // Display the feed
    header('Content-Type: ' . feed_content_type('rss2') . '; charset=' . get_option('blog_charset'), true);
    header('Status: 200 OK');
    echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . '>';
    ?>

	<rss version="2.0"
		xmlns:content="http://purl.org/rss/1.0/modules/content/"
		xmlns:wfw="http://wellformedweb.org/CommentAPI/"
		xmlns:dc="http://purl.org/dc/elements/1.1/"
		xmlns:atom="http://www.w3.org/2005/Atom"

		<?php 
    do_action('bbp_feed');
    ?>
	>

	<channel>

		<title><?php 
    bloginfo_rss('name');
    ?>
 &#187; <?php 
    _e('All Topics', 'bbpress');
    ?>
</title>
		<atom:link href="<?php 
    self_link();
    ?>
" rel="self" type="application/rss+xml" />
		<link><?php 
    self_link();
    ?>
</link>
		<description><?php 
    //
    ?>
</description>
		<pubDate><?php 
    echo mysql2date('D, d M Y H:i:s O', current_time('mysql'), false);
    ?>
</pubDate>
		<generator>http://bbpress.org/?v=<?php 
    bbp_version();
    ?>
</generator>
		<language><?php 
    bloginfo_rss('language');
    ?>
</language>

		<?php 
    do_action('bbp_feed_head');
    ?>

		<?php 
    if (bbp_has_topics($topics_query)) {
        ?>

			<?php 
        while (bbp_topics()) {
            bbp_the_topic();
            ?>

				<item>
					<guid><?php 
            bbp_topic_permalink();
            ?>
</guid>
					<title><![CDATA[<?php 
            bbp_topic_title();
            ?>
]]></title>
					<link><?php 
            bbp_topic_permalink();
            ?>
</link>
					<pubDate><?php 
            echo mysql2date('D, d M Y H:i:s +0000', get_post_meta(bbp_get_topic_id(), '_bbp_last_active_time', true));
            ?>
</pubDate>
					<dc:creator><?php 
            the_author();
            ?>
</dc:creator>

					<?php 
            if (!post_password_required()) {
                ?>

					<description>
						<![CDATA[
						<p><?php 
                printf(esc_html__('Replies: %s', 'bbpress'), bbp_get_topic_reply_count());
                ?>
</p>
						<?php 
                bbp_topic_content();
                ?>
						]]>
					</description>

					<?php 
                rss_enclosure();
                ?>

					<?php 
            }
            ?>

					<?php 
            do_action('bbp_feed_item');
            ?>

				</item>

				<?php 
        }
        ?>
			<?php 
    }
    ?>

		<?php 
    do_action('bbp_feed_footer');
    ?>

	</channel>
	</rss>

<?php 
    exit;
}
Ejemplo n.º 24
0
/**
 * The main topic loop. WordPress makes this easy for us
 *
 * @since 2.0.0 bbPress (r2485)
 *
 * @param array $args All the arguments supported by {@link WP_Query}
 * @uses current_user_can() To check if the current user can edit other's topics
 * @uses bbp_get_topic_post_type() To get the topic post type
 * @uses WP_Query To make query and get the topics
 * @uses is_page() To check if it's a page
 * @uses bbp_is_single_forum() To check if it's a forum
 * @uses bbp_get_forum_id() To get the forum id
 * @uses bbp_get_paged() To get the current page value
 * @uses bbp_get_super_stickies() To get the super stickies
 * @uses bbp_get_stickies() To get the forum stickies
 * @uses bbp_use_pretty_urls() To check if the site is using pretty URLs
 * @uses get_permalink() To get the permalink
 * @uses add_query_arg() To add custom args to the url
 * @uses apply_filters() Calls 'bbp_topics_pagination' with the pagination args
 * @uses paginate_links() To paginate the links
 * @uses apply_filters() Calls 'bbp_has_topics' with
 *                        bbPres::topic_query::have_posts()
 *                        and bbPres::topic_query
 * @return object Multidimensional array of topic information
 */
function bbp_has_topics($args = array())
{
    /** Defaults **************************************************************/
    // Other defaults
    $default_topic_search = !empty($_REQUEST['ts']) ? $_REQUEST['ts'] : false;
    $default_show_stickies = (bool) (bbp_is_single_forum() || bbp_is_topic_archive()) && false === $default_topic_search;
    $default_post_parent = bbp_is_single_forum() ? bbp_get_forum_id() : 'any';
    // Default argument array
    $default = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => $default_post_parent, 'meta_key' => '_bbp_last_active_time', 'meta_type' => 'DATETIME', 'orderby' => 'meta_value', 'order' => 'DESC', 'posts_per_page' => bbp_get_topics_per_page(), 'paged' => bbp_get_paged(), 'show_stickies' => $default_show_stickies, 'max_num_pages' => false);
    // Only add 's' arg if searching for topics
    // See https://bbpress.trac.wordpress.org/ticket/2607
    if (!empty($default_topic_search)) {
        $default['s'] = $default_topic_search;
    }
    // What are the default allowed statuses (based on user caps)
    if (bbp_get_view_all()) {
        // Default view=all statuses
        $post_statuses = array(bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id(), bbp_get_pending_status_id());
        // Add support for private status
        if (current_user_can('read_private_topics')) {
            $post_statuses[] = bbp_get_private_status_id();
        }
        // Join post statuses together
        $default['post_status'] = implode(',', $post_statuses);
        // Lean on the 'perm' query var value of 'readable' to provide statuses
    } else {
        $default['perm'] = 'readable';
    }
    // Maybe query for topic tags
    if (bbp_is_topic_tag()) {
        $default['term'] = bbp_get_topic_tag_slug();
        $default['taxonomy'] = bbp_get_topic_tag_tax_id();
    }
    /** Setup *****************************************************************/
    // Parse arguments against default values
    $r = bbp_parse_args($args, $default, 'has_topics');
    // Get bbPress
    $bbp = bbpress();
    // Call the query
    $bbp->topic_query = new WP_Query($r);
    // Set post_parent back to 0 if originally set to 'any'
    if ('any' === $r['post_parent']) {
        $r['post_parent'] = 0;
    }
    // Limited the number of pages shown
    if (!empty($r['max_num_pages'])) {
        $bbp->topic_query->max_num_pages = $r['max_num_pages'];
    }
    /** Stickies **************************************************************/
    // Put sticky posts at the top of the posts array
    if (!empty($r['show_stickies']) && $r['paged'] <= 1) {
        // Get super stickies and stickies in this forum
        $stickies = bbp_get_super_stickies();
        // Get stickies for current forum
        if (!empty($r['post_parent'])) {
            $stickies = array_merge($stickies, bbp_get_stickies($r['post_parent']));
        }
        // Remove any duplicate stickies
        $stickies = array_unique($stickies);
        // We have stickies
        if (is_array($stickies) && !empty($stickies)) {
            // Start the offset at -1 so first sticky is at correct 0 offset
            $sticky_offset = -1;
            // Loop over topics and relocate stickies to the front.
            foreach ($stickies as $sticky_index => $sticky_ID) {
                // Get the post offset from the posts array
                $post_offsets = wp_filter_object_list($bbp->topic_query->posts, array('ID' => $sticky_ID), 'OR', 'ID');
                // Continue if no post offsets
                if (empty($post_offsets)) {
                    continue;
                }
                // Loop over posts in current query and splice them into position
                foreach (array_keys($post_offsets) as $post_offset) {
                    $sticky_offset++;
                    $sticky = $bbp->topic_query->posts[$post_offset];
                    // Remove sticky from current position
                    array_splice($bbp->topic_query->posts, $post_offset, 1);
                    // Move to front, after other stickies
                    array_splice($bbp->topic_query->posts, $sticky_offset, 0, array($sticky));
                    // Cleanup
                    unset($stickies[$sticky_index]);
                    unset($sticky);
                }
                // Cleanup
                unset($post_offsets);
            }
            // Cleanup
            unset($sticky_offset);
            // If any posts have been excluded specifically, Ignore those that are sticky.
            if (!empty($stickies) && !empty($r['post__not_in'])) {
                $stickies = array_diff($stickies, $r['post__not_in']);
            }
            // Fetch sticky posts that weren't in the query results
            if (!empty($stickies)) {
                // Query to use in get_posts to get sticky posts
                $sticky_query = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => 'any', 'meta_key' => '_bbp_last_active_time', 'meta_type' => 'DATETIME', 'orderby' => 'meta_value', 'order' => 'DESC', 'include' => $stickies);
                // Cleanup
                unset($stickies);
                // Conditionally exclude private/hidden forum ID's
                $exclude_forum_ids = bbp_exclude_forum_ids('array');
                if (!empty($exclude_forum_ids)) {
                    $sticky_query['post_parent__not_in'] = $exclude_forum_ids;
                }
                // What are the default allowed statuses (based on user caps)
                if (bbp_get_view_all()) {
                    $sticky_query['post_status'] = $r['post_status'];
                    // Lean on the 'perm' query var value of 'readable' to provide statuses
                } else {
                    $sticky_query['post_status'] = $r['perm'];
                }
                // Get all stickies
                $sticky_posts = get_posts($sticky_query);
                if (!empty($sticky_posts)) {
                    // Get a count of the visible stickies
                    $sticky_count = count($sticky_posts);
                    // Merge the stickies topics with the query topics .
                    $bbp->topic_query->posts = array_merge($sticky_posts, $bbp->topic_query->posts);
                    // Adjust loop and counts for new sticky positions
                    $bbp->topic_query->found_posts = (int) $bbp->topic_query->found_posts + (int) $sticky_count;
                    $bbp->topic_query->post_count = (int) $bbp->topic_query->post_count + (int) $sticky_count;
                    // Cleanup
                    unset($sticky_posts);
                }
            }
        }
    }
    // If no limit to posts per page, set it to the current post_count
    if (-1 === $r['posts_per_page']) {
        $r['posts_per_page'] = $bbp->topic_query->post_count;
    }
    // Add pagination values to query object
    $bbp->topic_query->posts_per_page = $r['posts_per_page'];
    $bbp->topic_query->paged = $r['paged'];
    // Only add pagination if query returned results
    if (((int) $bbp->topic_query->post_count || (int) $bbp->topic_query->found_posts) && (int) $bbp->topic_query->posts_per_page) {
        // Limit the number of topics shown based on maximum allowed pages
        if (!empty($r['max_num_pages']) && $bbp->topic_query->found_posts > $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count) {
            $bbp->topic_query->found_posts = $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count;
        }
        // If pretty permalinks are enabled, make our pagination pretty
        if (bbp_use_pretty_urls()) {
            // User's topics
            if (bbp_is_single_user_topics()) {
                $base = bbp_get_user_topics_created_url(bbp_get_displayed_user_id());
                // User's favorites
            } elseif (bbp_is_favorites()) {
                $base = bbp_get_favorites_permalink(bbp_get_displayed_user_id());
                // User's subscriptions
            } elseif (bbp_is_subscriptions()) {
                $base = bbp_get_subscriptions_permalink(bbp_get_displayed_user_id());
                // Root profile page
            } elseif (bbp_is_single_user()) {
                $base = bbp_get_user_profile_url(bbp_get_displayed_user_id());
                // View
            } elseif (bbp_is_single_view()) {
                $base = bbp_get_view_url();
                // Topic tag
            } elseif (bbp_is_topic_tag()) {
                $base = bbp_get_topic_tag_link();
                // Page or single post
            } elseif (is_page() || is_single()) {
                $base = get_permalink();
                // Forum archive
            } elseif (bbp_is_forum_archive()) {
                $base = bbp_get_forums_url();
                // Topic archive
            } elseif (bbp_is_topic_archive()) {
                $base = bbp_get_topics_url();
                // Default
            } else {
                $base = get_permalink((int) $r['post_parent']);
            }
            // Use pagination base
            $base = trailingslashit($base) . user_trailingslashit(bbp_get_paged_slug() . '/%#%/');
            // Unpretty pagination
        } else {
            $base = add_query_arg('paged', '%#%');
        }
        // Pagination settings with filter
        $bbp_topic_pagination = apply_filters('bbp_topic_pagination', array('base' => $base, 'format' => '', 'total' => $r['posts_per_page'] === $bbp->topic_query->found_posts ? 1 : ceil((int) $bbp->topic_query->found_posts / (int) $r['posts_per_page']), 'current' => (int) $bbp->topic_query->paged, 'prev_text' => is_rtl() ? '&rarr;' : '&larr;', 'next_text' => is_rtl() ? '&larr;' : '&rarr;', 'mid_size' => 1));
        // Add pagination to query object
        $bbp->topic_query->pagination_links = paginate_links($bbp_topic_pagination);
        // Remove first page from pagination
        $bbp->topic_query->pagination_links = str_replace(bbp_get_paged_slug() . "/1/'", "'", $bbp->topic_query->pagination_links);
    }
    // Return object
    return apply_filters('bbp_has_topics', $bbp->topic_query->have_posts(), $bbp->topic_query);
}
Ejemplo n.º 25
0
/**
 * Called after untrashing a forum
 *
 * @since bbPress (r3668)
 * @uses bbp_get_forum_id() To get the forum id
 * @uses bbp_is_forum() To check if the passed id is a forum
 * @uses do_action() Calls 'bbp_untrashed_forum' with the forum id
 */
function bbp_untrashed_forum($forum_id = 0)
{
    $forum_id = bbp_get_forum_id($forum_id);
    if (empty($forum_id) || !bbp_is_forum($forum_id)) {
        return false;
    }
    do_action('bbp_untrashed_forum', $forum_id);
}
Ejemplo n.º 26
0
/**
 * Output the required hidden fields when creating/editing a forum
 *
 * @since bbPress (r3553)
 *
 * @uses bbp_is_forum_edit() To check if it's the forum edit page
 * @uses wp_nonce_field() To generate hidden nonce fields
 * @uses bbp_forum_id() To output the forum id
 * @uses bbp_is_single_forum() To check if it's a forum page
 * @uses bbp_forum_id() To output the forum id
 */
function bbp_forum_form_fields()
{
    if (bbp_is_forum_edit()) {
        ?>

		<input type="hidden" name="action"       id="bbp_post_action" value="bbp-edit-forum" />
		<input type="hidden" name="bbp_forum_id" id="bbp_forum_id"    value="<?php 
        bbp_forum_id();
        ?>
" />

		<?php 
        if (current_user_can('unfiltered_html')) {
            wp_nonce_field('bbp-unfiltered-html-forum_' . bbp_get_forum_id(), '_bbp_unfiltered_html_forum', false);
        }
        ?>

		<?php 
        wp_nonce_field('bbp-edit-forum_' . bbp_get_forum_id());
    } else {
        if (bbp_is_single_forum()) {
            ?>

			<input type="hidden" name="bbp_forum_parent_id" id="bbp_forum_parent_id" value="<?php 
            bbp_forum_parent_id();
            ?>
" />

		<?php 
        }
        ?>

		<input type="hidden" name="action" id="bbp_post_action" value="bbp-new-forum" />

		<?php 
        if (current_user_can('unfiltered_html')) {
            wp_nonce_field('bbp-unfiltered-html-forum_new', '_bbp_unfiltered_html_forum', false);
        }
        ?>

		<?php 
        wp_nonce_field('bbp-new-forum');
    }
}
Ejemplo n.º 27
0
/**
 * Return the forum id a reply belongs to
 *
 * @since bbPress (r2679)
 *
 * @param int $reply_id Optional. Reply id
 * @uses bbp_get_reply_id() To get the reply id
 * @uses get_post_meta() To get the reply forum id
 * @uses apply_filters() Calls 'bbp_get_reply_forum_id' with the forum
 *                        id and reply id
 * @return int Reply's forum id
 */
function bbp_get_reply_forum_id($reply_id = 0)
{
    // Assume there is no forum
    $forum_id = 0;
    // Check that reply_id is valid
    if ($reply_id = bbp_get_reply_id($reply_id)) {
        // Get forum_id from reply
        if ($forum_id = get_post_meta($reply_id, '_bbp_forum_id', true)) {
            // Validate the forum_id
            $forum_id = bbp_get_forum_id($forum_id);
        }
    }
    return (int) apply_filters('bbp_get_reply_forum_id', $forum_id, $reply_id);
}
Ejemplo n.º 28
0
/**
 * Loads up the current search result in the loop
 *
 * @since bbPress (r4579)
 *
 * @uses WP_Query bbPress::search_query::the_post() To get the current search result
 * @return object Search information
 */
function bbp_the_search_result()
{
    $search_result = bbpress()->search_query->the_post();
    // Reset each current (forum|topic|reply) id
    bbpress()->current_forum_id = bbp_get_forum_id();
    bbpress()->current_topic_id = bbp_get_topic_id();
    bbpress()->current_reply_id = bbp_get_reply_id();
    return $search_result;
}
Ejemplo n.º 29
-1
 static function options($forum_id = 0, $admin = false)
 {
     $forum_id = bbp_get_forum_id($forum_id);
     if ($cached = wp_cache_get($forum_id, 'forum_options')) {
         return $cached;
     }
     $forum_options = self::$defaults;
     if (get_post_meta($forum_id, 'bbpkr_custom_settings', true)) {
         $forum_options = array_merge($forum_options, (array) get_post_meta($forum_id, 'bbpkr_options', true));
         // var_dump( $this->options()['skin'], $options);
     } elseif (!$admin) {
         // follow closest parent forum custom settings
         $forum_parent = (int) get_post_field('post_parent', $forum_id);
         if ($forum_parent) {
             while ($forum_parent) {
                 if (get_post_meta($forum_parent, 'bbpkr_custom_settings', true)) {
                     $forum_options = array_merge($forum_options, (array) get_post_meta($forum_parent, 'bbpkr_options', true));
                     break;
                 }
                 $forum_parent = (int) get_post_field('post_parent', $forum_parent);
             }
         }
     }
     $return = array_merge(bbpresskr()->options(), (array) $forum_options);
     wp_cache_set($forum_id, $return, 'forum_options');
     return $return;
 }
function new_reply_notification($reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $reply_author = 0, $is_edit = false, $reply_to = 0)
{
    $admin_email = get_option('admin_email');
    $user_id = (int) $reply_author_id;
    $reply_id = bbp_get_reply_id($reply_id);
    $topic_id = bbp_get_topic_id($topic_id);
    $forum_id = bbp_get_forum_id($forum_id);
    $email_subject = get_option('bbpress_notify_newreply_email_subject');
    $email_body = get_option('bbpress_notify_newreply_email_body');
    $blog_name = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
    $topic_title = html_entity_decode(strip_tags(bbp_get_topic_title($topic_id)), ENT_NOQUOTES, 'UTF-8');
    $topic_content = html_entity_decode(strip_tags(bbp_get_topic_content($topic_id)), ENT_NOQUOTES, 'UTF-8');
    $topic_excerpt = html_entity_decode(strip_tags(bbp_get_topic_excerpt($topic_id, 100)), ENT_NOQUOTES, 'UTF-8');
    $topic_author = bbp_get_topic_author($topic_id);
    $topic_url = bbp_get_topic_permalink($topic_id);
    $topic_reply = bbp_get_reply_url($topic_id);
    $reply_url = bbp_get_reply_url($reply_id);
    $reply_content = get_post_field('post_content', $reply_id, 'raw');
    $reply_author = bbp_get_topic_author($user_id);
    $email_subject = $blog_name . " New Reply Alert: " . $topic_title;
    $email_body = $blog_name . ": {$topic_title}\n\r";
    $email_body .= $reply_content;
    $email_body .= "\n\r--------------------------------\n\r";
    $email_body .= "Reply Url: " . $reply_url . "\n\rAuthor: {$reply_author}" . "\n\rYou can reply at: {$reply_url}";
    @wp_mail($admin_email, $email_subject, $email_body);
}