Example #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>';
        }
    }
/**
 * 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;
}
        function widget($args, $instance)
        {
            extract($args, EXTR_SKIP);
            $title = !empty($instance['title']) ? $instance['title'] : __('Recent Topics');
            $title = apply_filters('widget_title', $title, $instance, $this->id_base);
            $number = !empty($instance['number']) ? absint($instance['number']) : 5;
            $orderby = !empty($instance['number']) ? strip_tags($instance['order_by']) : 'newness';
            if ($orderby == 'newness') {
                $cb_meta_key = $cb_order_by = NULL;
            } elseif ($orderby == 'popular') {
                $cb_meta_key = '_bbp_reply_count';
                $cb_order_by = 'meta_value';
            } elseif ($orderby == 'freshness') {
                $cb_meta_key = '_bbp_last_active_time';
                $cb_order_by = 'meta_value';
            }
            if (!$number) {
                $number = 5;
            }
            $cb_qry = new WP_Query(array('post_type' => bbp_get_topic_post_type(), 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'order' => 'DESC', 'posts_per_page' => $number, 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'meta_key' => $cb_meta_key, 'orderby' => $cb_order_by));
            echo $before_widget;
            echo $before_title . $title . $after_title;
            ?>
            <ul class="cb-bbp-recent-topics">

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

                    <li>

                        <?php 
                $cb_reply_id = bbp_get_reply_id($cb_qry->post->ID);
                $cb_reply_url = '<a class="bbp-reply-topic-title" href="' . esc_url(bbp_get_reply_url($cb_reply_id)) . '" title="' . esc_attr(bbp_get_reply_excerpt($cb_reply_id, 50)) . '">' . bbp_get_reply_topic_title($cb_reply_id) . '</a>';
                $cb_number_replies = bbp_get_topic_reply_count($cb_reply_id);
                $cb_author_avatar = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'avatar', 'size' => 60));
                $cb_author_name = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'name'));
                echo $cb_author_avatar . '<div class="cb-bbp-meta">' . $cb_reply_url . '<div class="cb-bbp-byline">' . __('Started by', 'cubell') . ' ' . $cb_author_name . ' <i class="icon-long-arrow-right"></i> ' . $cb_number_replies . ' replies</div></div>';
                ?>

                    </li>

                <?php 
            }
            ?>

            </ul>

<?php 
            echo $after_widget;
            // Reset the $post global
            wp_reset_postdata();
        }
 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;
 }
function bbpvotes_buddypress_voted_activity($post_id, $user_id, $vote)
{
    //check vote value
    if (is_bool($vote) === false) {
        return new WP_Error('vote_is_not_bool', __('Vote is not a boolean', 'bbpvotes'));
    }
    $voteplus = $vote === true;
    $voteminus = $vote === false;
    $post = get_post($post_id);
    $user_link = bbp_get_user_profile_link($user_id);
    //build item link
    if ($post->post_type == bbp_get_topic_post_type()) {
        $topic_id = $post->ID;
        $post_permalink = get_permalink($post->ID);
    } elseif ($post->post_type == bbp_get_reply_post_type()) {
        $topic_id = bbp_get_reply_topic_id($post->ID);
        $post_permalink = bbp_get_reply_url($post->ID);
    }
    //topic infos
    $topic = get_post($topic_id);
    $topic_author_link = bbp_get_user_profile_link($topic->post_author);
    $topic_title = $topic->post_title;
    $post_link = '<a href="' . $post_permalink . '">' . $topic_title . '</a>';
    if ($voteplus) {
        $type = 'bbpvotes_voted_up';
        if ($post->post_type == bbp_get_topic_post_type()) {
            $action = sprintf(esc_html__('%1$s voted up to the topic %2$s by %3$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
        } elseif ($post->post_type == bbp_get_reply_post_type()) {
            $action = sprintf(esc_html__('%1$s voted up to a reply by %3$s in the topic %2$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
        }
    } else {
        $type = 'bbpvotes_voted_down';
        if ($post->post_type == bbp_get_topic_post_type()) {
            $action = sprintf(esc_html__('%1$s voted down to the topic %2$s by %3$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
        } elseif ($post->post_type == bbp_get_reply_post_type()) {
            $action = sprintf(esc_html__('%1$s voted down to a reply by %3$s in the topic %2$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
        }
    }
    $args = array('action' => $action, 'component' => 'bbpress', 'type' => $type, 'item_id' => $topic->ID);
    if ($post->post_type == bbp_get_reply_post_type()) {
        $args['secondary_item_id'] = $post->ID;
    }
    /*
        if ($is_update){
       $previous_activity_id = 
       $args['id'] = $previous_activity_id;
        }
    */
    bp_activity_add($args);
}
        function widget($args, $instance)
        {
            extract($args, EXTR_SKIP);
            $title = !empty($instance['title']) ? $instance['title'] : __('Recent Comments');
            $title = apply_filters('widget_title', $title, $instance, $this->id_base);
            $number = !empty($instance['number']) ? absint($instance['number']) : 5;
            if (!$number) {
                $number = 5;
            }
            $cb_qry = new WP_Query(array('post_type' => bbp_get_reply_post_type(), 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'posts_per_page' => $number, 'ignore_sticky_posts' => true, 'no_found_rows' => true));
            echo $before_widget;
            echo $before_title . $title . $after_title;
            ?>
            <ul class="cb-bbp-recent-replies">

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

                    <li>

                        <?php 
                $cb_reply_id = bbp_get_reply_id($cb_qry->post->ID);
                $cb_reply_url = '<a class="bbp-reply-topic-title" href="' . esc_url(bbp_get_reply_url($cb_reply_id)) . '" title="' . esc_attr(bbp_get_reply_excerpt($cb_reply_id, 50)) . '">' . bbp_get_reply_topic_title($cb_reply_id) . '</a>';
                $cb_author_avatar = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'avatar', 'size' => 60));
                $cb_author_name = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'name'));
                echo $cb_author_avatar . '<div class="cb-bbp-meta">' . $cb_author_name . ' <i class="icon-long-arrow-right"></i> ' . $cb_reply_url . '<div class="cb-bbp-recent-replies-time">' . bbp_get_time_since(get_the_time('U')) . '</div></div>';
                ?>

                    </li>

                <?php 
            }
            ?>

            </ul>

        <?php 
            echo $after_widget;
            // Reset the $post global
            wp_reset_postdata();
        }
Example #7
0
 function mk_theme_breadcrumbs()
 {
     global $mk_options, $post;
     $post_id = global_get_post_id();
     if ($post_id) {
         $local_skining = get_post_meta($post_id, '_enable_local_backgrounds', true);
         $breadcrumb_skin = get_post_meta($post_id, '_breadcrumb_skin', true);
         if ($local_skining == 'true' && !empty($breadcrumb_skin)) {
             $breadcrumb_skin_class = $breadcrumb_skin;
         } else {
             $breadcrumb_skin_class = $mk_options['breadcrumb_skin'];
         }
     } else {
         $breadcrumb_skin_class = $mk_options['breadcrumb_skin'];
     }
     $delimiter = ' &#47; ';
     echo '<div id="mk-breadcrumbs"><div class="mk-breadcrumbs-inner ' . $breadcrumb_skin_class . '-skin">';
     if (!is_front_page()) {
         echo '<a href="';
         echo home_url();
         echo '">' . __('Home', 'mk_framework');
         echo "</a>" . $delimiter;
     }
     if (function_exists('is_woocommerce') && is_woocommerce() && is_archive()) {
         $shop_page_id = wc_get_page_id('shop');
         $shop_page = get_post($shop_page_id);
         $permalinks = get_option('woocommerce_permalinks');
         if ($shop_page_id && $shop_page && get_option('page_on_front') !== $shop_page_id) {
             echo '<a href="' . get_permalink($shop_page) . '">' . $shop_page->post_title . '</a> ';
         }
     }
     if (is_category() && !is_singular('portfolio')) {
         $category = get_the_category();
         $ID = $category[0]->cat_ID;
         echo is_wp_error($cat_parents = get_category_parents($ID, TRUE, '', FALSE)) ? '' : '<span>' . $cat_parents . '</span>';
     } else {
         if (is_singular('news')) {
             echo '<span>' . get_the_title() . '</span>';
         } else {
             if (is_single() && !is_attachment()) {
                 if (get_post_type() == 'product') {
                     if ($terms = wc_get_product_terms($post->ID, 'product_cat', array('orderby' => 'parent', 'order' => 'DESC'))) {
                         $main_term = $terms[0];
                         $ancestors = get_ancestors($main_term->term_id, 'product_cat');
                         $ancestors = array_reverse($ancestors);
                         foreach ($ancestors as $ancestor) {
                             $ancestor = get_term($ancestor, 'product_cat');
                             if (!is_wp_error($ancestor) && $ancestor) {
                                 echo '<a href="' . get_term_link($ancestor->slug, 'product_cat') . '">' . $ancestor->name . '</a>' . $delimiter;
                             }
                         }
                         echo '<a href="' . get_term_link($main_term->slug, 'product_cat') . '">' . $main_term->name . '</a>' . $delimiter;
                     }
                     echo get_the_title();
                 } elseif (is_singular('portfolio')) {
                     $portfolio_category = get_the_term_list($post->ID, 'portfolio_category', '', ' / ');
                     if (!empty($portfolio_category)) {
                         echo $portfolio_category . $delimiter;
                     }
                     echo '<span>' . get_the_title() . '</span>';
                 } elseif (get_post_type() != 'post') {
                     if (function_exists('is_bbpress') && is_bbpress()) {
                     } else {
                         $post_type = get_post_type_object(get_post_type());
                         $slug = $post_type->rewrite;
                         echo '<a href="' . get_post_type_archive_link(get_post_type()) . '">' . $post_type->labels->singular_name . '</a>' . $delimiter;
                         echo get_the_title();
                     }
                 } else {
                     $cat = current(get_the_category());
                     echo get_category_parents($cat, true, $delimiter);
                     echo get_the_title();
                 }
             } elseif (is_page() && !$post->post_parent) {
                 echo get_the_title();
             } elseif (is_page() && $post->post_parent) {
                 $parent_id = $post->post_parent;
                 $breadcrumbs = array();
                 while ($parent_id) {
                     $page = get_page($parent_id);
                     $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
                     $parent_id = $page->post_parent;
                 }
                 $breadcrumbs = array_reverse($breadcrumbs);
                 foreach ($breadcrumbs as $crumb) {
                     echo $crumb . '' . $delimiter;
                 }
                 echo get_the_title();
             } elseif (is_attachment()) {
                 $parent = get_post($post->post_parent);
                 $cat = get_the_category($parent->ID);
                 $cat = $cat[0];
                 /* admin@innodron.com patch:
                 			   Fix for Catchable fatal error: Object of class WP_Error could not be converted to string
                 			   ref: https://wordpress.org/support/topic/catchable-fatal-error-object-of-class-wp_error-could-not-be-converted-to-string-11
                 			*/
                 echo is_wp_error($cat_parents = get_category_parents($cat, TRUE, '' . $delimiter . '')) ? '' : $cat_parents;
                 /* end admin@innodron.com patch */
                 echo '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a>' . $delimiter;
                 echo get_the_title();
             } elseif (is_search()) {
                 echo __('Search results for &ldquo;', 'mk_framework') . get_search_query() . '&rdquo;';
             } elseif (is_tag()) {
                 echo __('Tag &ldquo;', 'mk_framework') . single_tag_title('', false) . '&rdquo;';
             } elseif (is_author()) {
                 $userdata = get_userdata(get_the_author_meta('ID'));
                 echo __('Author:', 'mk_framework') . ' ' . $userdata->display_name;
             } elseif (is_day()) {
                 echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a>' . $delimiter;
                 echo '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '">' . get_the_time('F') . '</a>' . $delimiter;
                 echo get_the_time('d');
             } elseif (is_month()) {
                 echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a>' . $delimiter;
                 echo get_the_time('F');
             } elseif (is_year()) {
                 echo get_the_time('Y');
             }
         }
     }
     if (get_query_var('paged')) {
         echo ' (' . __('Page', 'mk_framework') . ' ' . get_query_var('paged') . ')';
     }
     if (is_tax()) {
         $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
         if (function_exists('is_woocommerce') && is_woocommerce() && is_archive()) {
             echo $delimiter;
         }
         echo '<span>' . $term->name . '</span>';
     }
     if (function_exists('is_bbpress') && is_bbpress()) {
         $item = array();
         $post_type_object = get_post_type_object(bbp_get_forum_post_type());
         if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
             $item[] = '<a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a>';
         }
         if (bbp_is_forum_archive()) {
             $item[] = bbp_get_forum_archive_title();
         } elseif (bbp_is_topic_archive()) {
             $item[] = bbp_get_topic_archive_title();
         } elseif (bbp_is_single_view()) {
             $item[] = bbp_get_view_title();
         } elseif (bbp_is_single_topic()) {
             $topic_id = get_queried_object_id();
             $item = array_merge($item, mk_breadcrumbs_get_parents(bbp_get_topic_forum_id($topic_id)));
             if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
                 $item[] = '<a href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
             } else {
                 $item[] = bbp_get_topic_title($topic_id);
             }
             if (bbp_is_topic_split()) {
                 $item[] = __('Split', 'mk_framework');
             } elseif (bbp_is_topic_merge()) {
                 $item[] = __('Merge', 'mk_framework');
             } elseif (bbp_is_topic_edit()) {
                 $item[] = __('Edit', 'mk_framework');
             }
         } elseif (bbp_is_single_reply()) {
             $reply_id = get_queried_object_id();
             $item = array_merge($item, mk_breadcrumbs_get_parents(bbp_get_reply_topic_id($reply_id)));
             if (!bbp_is_reply_edit()) {
                 $item[] = bbp_get_reply_title($reply_id);
             } else {
                 $item[] = '<a href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a>';
                 $item[] = __('Edit', 'mk_framework');
             }
         } elseif (bbp_is_single_forum()) {
             $forum_id = get_queried_object_id();
             $forum_parent_id = bbp_get_forum_parent_id($forum_id);
             if (0 !== $forum_parent_id) {
                 $item = array_merge($item, mk_breadcrumbs_get_parents($forum_parent_id));
             }
             $item[] = bbp_get_forum_title($forum_id);
         } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
             if (bbp_is_single_user_edit()) {
                 $item[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a>';
                 $item[] = __('Edit', 'mk_framework');
             } else {
                 $item[] = bbp_get_displayed_user_field('display_name');
             }
         }
         echo implode($delimiter, $item);
     }
     echo "</div></div>";
 }
Example #8
0
/**
 * Return the url to the last reply in a forum
 *
 * @since bbPress (r2683)
 *
 * @param int $forum_id Optional. Forum id
 * @uses bbp_get_forum_id() To get the forum id
 * @uses bbp_get_forum_last_reply_id() To get the forum's last reply id
 * @uses bbp_get_reply_url() To get the reply url
 * @uses bbp_get_forum_last_topic_permalink() To get the forum's last
 *                                             topic's permalink
 * @uses apply_filters() Calls 'bbp_get_forum_last_reply_url' with the
 *                        reply url and forum id
 * @return string Paginated URL to latest reply
 */
function bbp_get_forum_last_reply_url($forum_id = 0)
{
    $forum_id = bbp_get_forum_id($forum_id);
    // If forum has replies, get the last reply and use its url
    $reply_id = bbp_get_forum_last_reply_id($forum_id);
    if (!empty($reply_id)) {
        $reply_url = bbp_get_reply_url($reply_id);
        // No replies, so look for topics and use last permalink
    } else {
        $reply_url = bbp_get_forum_last_topic_permalink($forum_id);
        // No topics either, so set $reply_url as empty string
        if (empty($reply_url)) {
            $reply_url = '';
        }
    }
    // Filter and return
    return apply_filters('bbp_get_forum_last_reply_url', $reply_url, $forum_id);
}
Example #9
0
 /**
  * @covers ::bbp_reply_url
  * @covers ::bbp_get_reply_url
  *
  * @ticket BBP2845
  */
 public function test_bbp_get_reply_url()
 {
     if (is_multisite()) {
         $this->markTestSkipped('Skipping URL tests in multisite for now.');
     }
     $f = $this->factory->forum->create();
     $t = $this->factory->topic->create(array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f)));
     $r = $this->factory->reply->create_many(7, array('post_parent' => $t, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
     // Store the original reply pagination option value.
     $default_reply_page = bbp_get_replies_per_page();
     // Lower the reply pagination value to test without so many replies.
     update_option('_bbp_replies_per_page', 3);
     // Reply menu position is unaltered when bbp_show_lead_topic() true.
     add_filter('bbp_show_lead_topic', '__return_true');
     // 1st reply is on the first page, 3 replies and 1 topic per page.
     $reply_url = bbp_get_topic_permalink($t) . '/#post-' . bbp_get_reply_id($r[0]);
     $this->assertSame($reply_url, bbp_get_reply_url($r[0]));
     // 2nd reply is on the first page, 3 replies and 1 topic per page.
     $reply_url = bbp_get_topic_permalink($t) . '/#post-' . bbp_get_reply_id($r[1]);
     $this->assertSame($reply_url, bbp_get_reply_url($r[1]));
     // 3rd reply is on the first page, 3 replies and 1 topic per page.
     $reply_url = bbp_get_topic_permalink($t) . '/#post-' . bbp_get_reply_id($r[2]);
     $this->assertSame($reply_url, bbp_get_reply_url($r[2]));
     // 4th reply is on the second page, 3 replies and 1 topic per page.
     $reply_url = bbp_get_topic_permalink($t) . '&paged=2#post-' . bbp_get_reply_id($r[3]);
     $this->assertSame($reply_url, bbp_get_reply_url($r[3]));
     // 5th reply is on the second page, 3 replies and 1 topic per page.
     $reply_url = bbp_get_topic_permalink($t) . '&paged=2#post-' . bbp_get_reply_id($r[4]);
     $this->assertSame($reply_url, bbp_get_reply_url($r[4]));
     // 6th reply is on the second page, 3 replies and 1 topic per page.
     $reply_url = bbp_get_topic_permalink($t) . '&paged=2#post-' . bbp_get_reply_id($r[5]);
     $this->assertSame($reply_url, bbp_get_reply_url($r[5]));
     // 7th reply is on the third page, 3 replies and 1 topic per page.
     $reply_url = bbp_get_topic_permalink($t) . '&paged=3#post-' . bbp_get_reply_id($r[6]);
     $this->assertSame($reply_url, bbp_get_reply_url($r[6]));
     // Remove the filter for WordPress < 4.0 compatibility.
     remove_filter('bbp_show_lead_topic', '__return_true');
     // Reply menu position is bumped by 1 when bbp_show_lead_topic() false.
     add_filter('bbp_show_lead_topic', '__return_false');
     // 1st reply is on the first page, 2 replies and 1 topic per first page.
     $reply_url = bbp_get_topic_permalink($t) . '/#post-' . bbp_get_reply_id($r[0]);
     $this->assertSame($reply_url, bbp_get_reply_url($r[0]));
     // 2nd reply is on the first page, 2 replies and 1 topic per first page.
     $reply_url = bbp_get_topic_permalink($t) . '/#post-' . bbp_get_reply_id($r[1]);
     $this->assertSame($reply_url, bbp_get_reply_url($r[1]));
     // 3rd reply is on the second page, 2 replies and 1 topic per first page.
     $reply_url = bbp_get_topic_permalink($t) . '&paged=2#post-' . bbp_get_reply_id($r[2]);
     $this->assertSame($reply_url, bbp_get_reply_url($r[2]));
     // 4th reply is on the second page, 3 replies per subsequent page.
     $reply_url = bbp_get_topic_permalink($t) . '&paged=2#post-' . bbp_get_reply_id($r[3]);
     $this->assertSame($reply_url, bbp_get_reply_url($r[3]));
     // 5th reply is on the second page, 3 replies per subsequent page.
     $reply_url = bbp_get_topic_permalink($t) . '&paged=2#post-' . bbp_get_reply_id($r[4]);
     $this->assertSame($reply_url, bbp_get_reply_url($r[4]));
     // 6th reply is on the third page, 3 replies per subsequent page.
     $reply_url = bbp_get_topic_permalink($t) . '&paged=3#post-' . bbp_get_reply_id($r[5]);
     $this->assertSame($reply_url, bbp_get_reply_url($r[5]));
     // 7th reply is on the third page, 3 replies per subsequent page.
     $reply_url = bbp_get_topic_permalink($t) . '&paged=3#post-' . bbp_get_reply_id($r[6]);
     $this->assertSame($reply_url, bbp_get_reply_url($r[6]));
     // Remove the filter for WordPress < 4.0 compatibility.
     remove_filter('bbp_show_lead_topic', '__return_false');
     // Restore the original reply pagination option value.
     update_option('_bbp_replies_per_page', $default_reply_page);
 }
Example #10
0
/**
 * Gets the items for the breadcrumb item if bbPress is installed.
 *
 * @since 0.4
 *
 * @param array $args Mixed arguments for the menu.
 * @return array List of items to be shown in the item.
 */
function breadcrumbs_plus_get_bbpress_items($args = array())
{
    $item = array();
    $post_type_object = get_post_type_object(bbp_get_forum_post_type());
    if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
        if (function_exists('bp_is_active')) {
            global $bp;
            // we're outside the loop!
            // Assign some variables here
            $page1 = isset($bp->members->root_slug) ? $bp->members->root_slug : '';
            // slug for the Members page. The BuddyPress default is 'members'.
            $page2 = isset($bp->groups->root_slug) ? $bp->groups->root_slug : '';
            // slug for the Groups page. The BuddyPress default is 'groups'.
            $page3 = isset($bp->activity->root_slug) ? $bp->activity->root_slug : '';
            // slug for the Activity page. The BuddyPress default is 'activity'.
            $page4 = isset($bp->forums->root_slug) ? $bp->forums->root_slug : '';
            // slug for the Forums page. The BuddyPress default is 'forums'.
            $page5 = isset($bp->achievements->root_slug) ? $bp->achievements->root_slug : '';
            // slug for the Achievements page. The BuddyPress default is 'achievements'.
            if (!bp_is_blog_page() && (is_page() || is_page($page1) || is_page($page2) || is_page($page3) || is_page($page4) || is_page($page5)) && !bp_is_user() && !bp_is_single_item() && !bp_is_register_page()) {
                $item[] = '';
            }
            if (bp_is_user() && !bp_is_register_page()) {
                $item[] = '';
            }
        } else {
            //$item[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . get_post_type_archive_link( bbp_get_forum_post_type() ) . '" rel="v:url" property="v:title">' . bbp_get_forum_archive_title() . '</a></div>';
        }
    }
    if (bbp_is_forum_archive()) {
        $item[] = bbp_get_forum_archive_title();
    } else {
        $item[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '" rel="v:url" property="v:title">' . bbp_get_forum_archive_title() . '</a></div>';
    }
    if (bbp_is_topic_archive()) {
        $item[] = bbp_get_topic_archive_title();
    } elseif (bbp_is_single_view()) {
        $item[] = bbp_get_view_title();
    } elseif (bbp_is_single_topic()) {
        $topic_id = get_queried_object_id();
        $item = array_merge($item, breadcrumbs_plus_get_parents(bbp_get_topic_forum_id($topic_id)));
        if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
            $item[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . bbp_get_topic_permalink($topic_id) . '" rel="v:url" property="v:title">' . bbp_get_topic_title($topic_id) . '</a></div>';
        } else {
            $item[] = '';
        }
        if (bbp_is_topic_split()) {
            $item[] = __('Split', 'framework');
        } elseif (bbp_is_topic_merge()) {
            $item[] = __('Merge', 'framework');
        } elseif (bbp_is_topic_edit()) {
            $item[] = __('Edit', 'framework');
        }
    } elseif (bbp_is_single_reply()) {
        $reply_id = get_queried_object_id();
        $item = array_merge($item, breadcrumbs_plus_get_parents(bbp_get_reply_topic_id($reply_id)));
        if (!bbp_is_reply_edit()) {
            $item[] = bbp_get_reply_title($reply_id);
        } else {
            $item[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . bbp_get_reply_url($reply_id) . '" rel="v:url" property="v:title">' . bbp_get_reply_title($reply_id) . '</a></div>';
            $item[] = __('Edit', 'framework');
        }
    } elseif (bbp_is_single_forum()) {
        $forum_id = get_queried_object_id();
        $forum_parent_id = bbp_get_forum_parent_id($forum_id);
        if (0 !== $forum_parent_id) {
            $item = array_merge($item, breadcrumbs_plus_get_parents($forum_parent_id));
        }
        $item[] = bbp_get_forum_title($forum_id);
    } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
        if (bbp_is_single_user_edit()) {
            $item[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . bbp_get_user_profile_url() . '" rel="v:url" property="v:title">' . bbp_get_displayed_user_field('display_name') . '</a></div>';
            $item[] = __('Edit', 'framework');
        } else {
            $item[] = bbp_get_displayed_user_field('display_name');
        }
    }
    return apply_filters('breadcrumbs_plus_get_bbpress_items', $item, $args);
}
 /**
  * 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);
 }
 /**
  * Handles the front end reporting/un-reporting of replies
  *
  * @since 1.0.0
  *
  * @param string $action The requested action to compare this function to
  */
 public function toggle_reply_handler($action = '')
 {
     // Bail if required GET actions aren't passed
     if (empty($_GET['reply_id'])) {
         return;
     }
     // Setup possible get actions
     $possible_actions = array('bbp_rc_toggle_reply_report');
     // Bail if actions aren't meant for this function
     if (!in_array($action, $possible_actions)) {
         return;
     }
     $failure = '';
     // Empty failure string
     $view_all = false;
     // Assume not viewing all
     $reply_id = (int) $_GET['reply_id'];
     // What's the reply id?
     $success = false;
     // Flag
     $post_data = array('ID' => $reply_id);
     // Prelim array
     $redirect = '';
     // Empty redirect URL
     // Make sure reply exists
     $reply = bbp_get_reply($reply_id);
     if (empty($reply)) {
         return;
     }
     // Bail if non-logged-in user
     if (!is_user_logged_in()) {
         return;
     }
     // What action are we trying to perform?
     switch ($action) {
         // Toggle reported
         case 'bbp_rc_toggle_reply_report':
             check_ajax_referer('report-reply_' . $reply_id);
             $is_reported = $this->is_reply_reported($reply_id);
             $success = true === $is_reported ? $this->unreport_reply($reply_id) : $this->report_reply($reply_id);
             $failure = true === $is_reported ? __('<strong>ERROR</strong>: There was a problem unmarking the reply as reported.', 'bbpress-report-content') : __('<strong>ERROR</strong>: There was a problem reporting the reply.', 'bbpress-report-content');
             // $view_all = !$is_reported; // Only need this if we want to hide it, like spam
             break;
     }
     // No errors
     if (false !== $success && !is_wp_error($success)) {
         /** Redirect **********************************************************/
         // Redirect to
         $redirect_to = bbp_get_redirect_to();
         // Get the reply URL
         $reply_url = bbp_get_reply_url($reply_id, $redirect_to);
         // Add view all if needed
         if (!empty($view_all)) {
             $reply_url = bbp_add_view_all($reply_url, true);
         }
         // Redirect back to reply
         wp_safe_redirect($reply_url);
         // For good measure
         exit;
         // Handle errors
     } else {
         bbp_add_error('bbp_rc_toggle_reply', $failure);
     }
 }
Example #13
0
    /**
     * Displays the output, the replies list
     *
     * @since bbPress (r2653)
     *
     * @param mixed $args
     * @param array $instance
     * @uses apply_filters() Calls 'bbp_reply_widget_title' with the title
     * @uses bbp_get_reply_author_link() To get the reply author link
     * @uses bbp_get_reply_author() To get the reply author name
     * @uses bbp_get_reply_id() To get the reply id
     * @uses bbp_get_reply_url() To get the reply url
     * @uses bbp_get_reply_excerpt() To get the reply excerpt
     * @uses bbp_get_reply_topic_title() To get the reply topic title
     * @uses get_the_date() To get the date of the reply
     * @uses get_the_time() To get the time of the reply
     */
    public function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('bbp_replies_widget_title', $instance['title']);
        $max_shown = !empty($instance['max_shown']) ? $instance['max_shown'] : '5';
        $show_date = !empty($instance['show_date']) ? 'on' : false;
        $show_user = !empty($instance['show_user']) ? 'on' : false;
        $post_types = !empty($instance['post_type']) ? array(bbp_get_topic_post_type(), bbp_get_reply_post_type()) : bbp_get_reply_post_type();
        // Note: private and hidden forums will be excluded via the
        // bbp_pre_get_posts_exclude_forums filter and function.
        $widget_query = new WP_Query(array('post_type' => $post_types, 'post_status' => join(',', array(bbp_get_public_status_id(), bbp_get_closed_status_id())), 'posts_per_page' => $max_shown, 'meta_query' => array(bbp_exclude_forum_ids('meta_query'))));
        // Get replies and display them
        if ($widget_query->have_posts()) {
            echo $before_widget;
            echo $before_title . $title . $after_title;
            ?>

			<ul>

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

					<li>

						<?php 
                $reply_id = bbp_get_reply_id($widget_query->post->ID);
                $author_link = bbp_get_reply_author_link(array('post_id' => $reply_id, 'type' => 'both', 'size' => 14));
                $reply_link = '<a class="bbp-reply-topic-title" href="' . esc_url(bbp_get_reply_url($reply_id)) . '" title="' . bbp_get_reply_excerpt($reply_id, 50) . '">' . bbp_get_reply_topic_title($reply_id) . '</a>';
                // Reply author, link, and timestamp
                if ('on' == $show_date && 'on' == $show_user) {
                    // translators: 1: reply author, 2: reply link, 3: reply timestamp
                    printf(_x('%1$s on %2$s %3$s', 'widgets', 'bbpress'), $author_link, $reply_link, '<div>' . bbp_get_time_since(get_the_time('U')) . '</div>');
                    // Reply link and timestamp
                } elseif ($show_date == 'on') {
                    // translators: 1: reply link, 2: reply timestamp
                    printf(_x('%1$s %2$s', 'widgets', 'bbpress'), $reply_link, '<div>' . bbp_get_time_since(get_the_time('U')) . '</div>');
                    // Reply author and title
                } elseif ($show_user == 'on') {
                    // translators: 1: reply author, 2: reply link
                    printf(_x('%1$s on %2$s', 'widgets', 'bbpress'), $author_link, $reply_link);
                    // Only the reply title
                } else {
                    // translators: 1: reply link
                    printf(_x('%1$s', 'widgets', 'bbpress'), $reply_link);
                }
                ?>

					</li>

				<?php 
            }
            ?>

			</ul>

			<?php 
            echo $after_widget;
            // Reset the $post global
            wp_reset_postdata();
        }
    }
/**
 * Gets the items for the breadcrumb item if bbPress is installed.
 *
 * @since 0.4
 *
 * @param array $args Mixed arguments for the menu.
 * @return array List of items to be shown in the item.
 */
function breadcrumbs_plus_get_bbpress_items($args = array())
{
    $item = array();
    $post_type_object = get_post_type_object(bbp_get_forum_post_type());
    if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
        $item[] = '<a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a>';
    }
    if (bbp_is_forum_archive()) {
        $item[] = bbp_get_forum_archive_title();
    } elseif (bbp_is_topic_archive()) {
        $item[] = bbp_get_topic_archive_title();
    } elseif (bbp_is_single_view()) {
        $item[] = bbp_get_view_title();
    } elseif (bbp_is_single_topic()) {
        $topic_id = get_queried_object_id();
        $item = array_merge($item, breadcrumbs_plus_get_parents(bbp_get_topic_forum_id($topic_id)));
        if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
            $item[] = '<a href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
        } else {
            $item[] = bbp_get_topic_title($topic_id);
        }
        if (bbp_is_topic_split()) {
            $item[] = __('Split', 'theme_front');
        } elseif (bbp_is_topic_merge()) {
            $item[] = __('Merge', 'theme_front');
        } elseif (bbp_is_topic_edit()) {
            $item[] = __('Edit', 'theme_front');
        }
    } elseif (bbp_is_single_reply()) {
        $reply_id = get_queried_object_id();
        $item = array_merge($item, breadcrumbs_plus_get_parents(bbp_get_reply_topic_id($reply_id)));
        if (!bbp_is_reply_edit()) {
            $item[] = bbp_get_reply_title($reply_id);
        } else {
            $item[] = '<a href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a>';
            $item[] = __('Edit', 'theme_front');
        }
    } elseif (bbp_is_single_forum()) {
        $forum_id = get_queried_object_id();
        $forum_parent_id = bbp_get_forum_parent($forum_id);
        if (0 !== $forum_parent_id) {
            $item = array_merge($item, breadcrumbs_plus_get_parents($forum_parent_id));
        }
        $item[] = bbp_get_forum_title($forum_id);
    } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
        if (bbp_is_single_user_edit()) {
            $item[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a>';
            $item[] = __('Edit');
        } else {
            $item[] = bbp_get_displayed_user_field('display_name');
        }
    }
    return apply_filters('breadcrumbs_plus_get_bbpress_items', $item, $args);
}
Example #15
0
 /**
  * Record an activity stream entry when a reply is created
  *
  * @since bbPress (r3395)
  * @param int $topic_id
  * @param int $forum_id
  * @param array $anonymous_data
  * @param int $topic_author_id
  * @uses bbp_get_reply_id()
  * @uses bbp_get_topic_id()
  * @uses bbp_get_forum_id()
  * @uses bbp_get_user_profile_link()
  * @uses bbp_get_reply_url()
  * @uses bbp_get_reply_content()
  * @uses bbp_get_topic_permalink()
  * @uses bbp_get_topic_title()
  * @uses bbp_get_forum_permalink()
  * @uses bbp_get_forum_title()
  * @uses bp_create_excerpt()
  * @uses apply_filters()
  * @return Bail early if topic is by anonywous user
  */
 public function reply_create($reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author_id)
 {
     // Do not log activity of anonymous users
     if (!empty($anonymous_data)) {
         return;
     }
     // Bail if site is private
     if (!bbp_is_site_public()) {
         return;
     }
     // Validate activity data
     $user_id = $reply_author_id;
     $reply_id = bbp_get_reply_id($reply_id);
     $topic_id = bbp_get_topic_id($topic_id);
     $forum_id = bbp_get_forum_id($forum_id);
     // Bail if user is not active
     if (bbp_is_user_inactive($user_id)) {
         return;
     }
     // Bail if reply is not published
     if (!bbp_is_reply_published($reply_id)) {
         return;
     }
     // Setup links for activity stream
     $user_link = bbp_get_user_profile_link($user_id);
     // Reply
     $reply_url = bbp_get_reply_url($reply_id);
     $reply_content = get_post_field('post_content', $reply_id, 'raw');
     // Topic
     $topic_permalink = bbp_get_topic_permalink($topic_id);
     $topic_title = get_post_field('post_title', $topic_id, 'raw');
     $topic_link = '<a href="' . $topic_permalink . '" title="' . $topic_title . '">' . $topic_title . '</a>';
     // Forum
     $forum_permalink = bbp_get_forum_permalink($forum_id);
     $forum_title = get_post_field('post_title', $forum_id, 'raw');
     $forum_link = '<a href="' . $forum_permalink . '" title="' . $forum_title . '">' . $forum_title . '</a>';
     // Activity action & text
     $activity_text = sprintf(__('%1$s replied to the topic %2$s in the forum %3$s', 'bbpress'), $user_link, $topic_link, $forum_link);
     $activity_action = apply_filters('bbp_activity_reply_create', $activity_text, $user_id, $reply_id, $topic_id);
     $activity_content = apply_filters('bbp_activity_reply_create_excerpt', bp_create_excerpt($reply_content), $reply_content);
     // Compile the activity stream results
     $activity = array('id' => $this->get_activity_id($reply_id), 'user_id' => $user_id, 'action' => $activity_action, 'content' => $activity_content, 'primary_link' => $reply_url, 'type' => $this->reply_create, 'item_id' => $reply_id, 'secondary_item_id' => $topic_id, 'recorded_time' => get_post_time('Y-m-d H:i:s', true, $reply_id), 'hide_sitewide' => !bbp_is_forum_public($forum_id, false));
     // Record the activity
     $activity_id = $this->record_activity($activity);
     // Add the activity entry ID as a meta value to the reply
     if (!empty($activity_id)) {
         update_post_meta($reply_id, '_bbp_activity_id', $activity_id);
     }
 }
Example #16
0
/**
 * 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;
}
Example #17
0
<div class="bboss_ajax_search_item bboss_ajax_search_item_reply">
	<a href="<?php 
echo esc_url(add_query_arg(array('no_frame' => '1'), bbp_get_reply_url(get_the_ID())));
?>
">
		<div class="item">
			<?php 
$forum_title = bbp_forum_title(get_the_ID());
?>
			<div class="item-title">
				<?php 
if ($forum_title) {
    echo $forum_title . '<br />';
}
?>
				<?php 
echo buddyboss_global_search_reply_intro(10);
?>
			</div>
		</div>
	</a>
</div>
Example #18
0
function apoc_report_post()
{
    /* Get the needed data */
    $userid = get_current_user_id();
    $from = bp_core_get_user_displayname($userid);
    /* Get AJAX data */
    $type = $_POST['type'];
    $postid = $_POST['id'];
    $number = $_POST['num'];
    $user = $_POST['user'];
    $reason = $_POST['reason'];
    /* Get the post URL */
    if ('reply' == $type) {
        $link = bbp_get_reply_url($postid);
    } elseif ('comment' == $type) {
        $link = get_comment_link($postid);
    } elseif ('message' == $type) {
        $link = bp_core_get_user_domain($user) . 'messages/view/' . trailingslashit($postid);
        $user = bp_core_get_user_displayname($user);
    }
    /* Set the email headers */
    $subject = "Reported Post From {$from}";
    $headers = "From: Post Report Bot <*****@*****.**>\r\n";
    $headers .= "Content-Type: text/html; charset=UTF-8";
    /* Construct the message */
    $body = '<h3>' . $from . ' has reported a post violating the Code of Conduct.</h3>';
    $body .= '<ul><li>Report URL: <a href="' . $link . '" title="View Post" target="_blank">' . $link . '</a></li>';
    $body .= '<li>Post Number: ' . $number . '</li>';
    $body .= '<li>User Reported: ' . $user . '</li>';
    $body .= '<li>Reason: ' . $reason . '</li></ul>';
    /* Send the email */
    $emailto = get_moderator_emails();
    wp_mail($emailto, $subject, $body, $headers);
    echo "1";
    exit(0);
}
Example #19
0
function my_reply_edit_handler()
{
    //error_log("og reply id:".$_POST['bbp_reply_id']);
    //error_log("og redirect:".bbp_get_redirect_to());
    //error_log("page uri:".$_SERVER['REQUEST_URI']);
    // Edit replies do not have the url that we don't want to cache (unlike new posts).
    // In order to disable the cache for the editing user for this topic, we need to obtain
    // its url
    // Get the post id
    $myreplyid = (int) $_POST['bbp_reply_id'];
    // Get the full redirect url
    $myredirect = bbp_get_redirect_to();
    $myreplyurl = bbp_get_reply_url($myreplyid, $myredirect);
    // Get rid of the extras (such as the domain name and the #post123)
    $myreplyurlpart = trim(preg_replace("/([^\\/]+\$)/", "", preg_replace("/^https?:\\/\\/[^\\/]+(\\/*.+\\/).*/", " \$1 ", $myreplyurl)));
    //error_log("og reply url:".home_url());
    error_log("og reply uri:" . $myreplyurlpart);
    my_disable_page_cache($myreplyurlpart);
    error_log("og reply uri:" . $myreplyurlpart);
}
Example #20
0
 function cupid_breadcrumb_get_bbpress_items()
 {
     $item = array();
     $post_type_object = get_post_type_object(bbp_get_forum_post_type());
     if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
         $item[] = '<li typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a></li>';
     }
     if (bbp_is_forum_archive()) {
         $item['last'] = bbp_get_forum_archive_title();
     } elseif (bbp_is_topic_archive()) {
         $item['last'] = bbp_get_topic_archive_title();
     } elseif (bbp_is_single_view()) {
         $item['last'] = bbp_get_view_title();
     } elseif (bbp_is_single_topic()) {
         $topic_id = get_queried_object_id();
         $item = array_merge($item, cupid_breadcrumb_get_parents(bbp_get_topic_forum_id($topic_id)));
         if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
             $item[] = '<li typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a></li>';
         } else {
             $item['last'] = bbp_get_topic_title($topic_id);
         }
         if (bbp_is_topic_split()) {
             $item['last'] = __('Split', 'cupid');
         } elseif (bbp_is_topic_merge()) {
             $item['last'] = __('Merge', 'cupid');
         } elseif (bbp_is_topic_edit()) {
             $item['last'] = __('Edit', 'cupid');
         }
     } elseif (bbp_is_single_reply()) {
         $reply_id = get_queried_object_id();
         $item = array_merge($item, cupid_breadcrumb_get_parents(bbp_get_reply_topic_id($reply_id)));
         if (!bbp_is_reply_edit()) {
             $item['last'] = bbp_get_reply_title($reply_id);
         } else {
             $item[] = '<li typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a></li>';
             $item['last'] = __('Edit', 'cupid');
         }
     } elseif (bbp_is_single_forum()) {
         $forum_id = get_queried_object_id();
         $forum_parent_id = bbp_get_forum_parent_id($forum_id);
         if (0 !== $forum_parent_id) {
             $item = array_merge($item, cupid_breadcrumb_get_parents($forum_parent_id));
         }
         $item['last'] = bbp_get_forum_title($forum_id);
     } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
         if (bbp_is_single_user_edit()) {
             $item[] = '<li typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a></li>';
             $item['last'] = __('Edit', 'cupid');
         } else {
             $item['last'] = bbp_get_displayed_user_field('display_name');
         }
     }
     return apply_filters('cupid_breadcrumb_get_bbpress_items', $item);
 }
Example #21
0
    /**
     * Displays the output, the replies list
     *
     * @since bbPress (r2653)
     *
     * @param mixed $args
     * @param array $instance
     * @uses apply_filters() Calls 'bbp_reply_widget_title' with the title
     * @uses bbp_get_reply_author_link() To get the reply author link
     * @uses bbp_get_reply_id() To get the reply id
     * @uses bbp_get_reply_url() To get the reply url
     * @uses bbp_get_reply_excerpt() To get the reply excerpt
     * @uses bbp_get_reply_topic_title() To get the reply topic title
     * @uses get_the_date() To get the date of the reply
     * @uses get_the_time() To get the time of the reply
     */
    public function widget($args, $instance)
    {
        // Get widget settings
        $settings = $this->parse_settings($instance);
        // Typical WordPress filter
        $settings['title'] = apply_filters('widget_title', $settings['title'], $instance, $this->id_base);
        // bbPress filter
        $settings['title'] = apply_filters('bbp_replies_widget_title', $settings['title'], $instance, $this->id_base);
        // Note: private and hidden forums will be excluded via the
        // bbp_pre_get_posts_normalize_forum_visibility action and function.
        $widget_query = new WP_Query(array('post_type' => bbp_get_reply_post_type(), 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'posts_per_page' => (int) $settings['max_shown'], 'ignore_sticky_posts' => true, 'no_found_rows' => true));
        // Bail if no replies
        if (!$widget_query->have_posts()) {
            return;
        }
        echo $args['before_widget'];
        if (!empty($settings['title'])) {
            echo $args['before_title'] . $settings['title'] . $args['after_title'];
        }
        ?>

		<ul>

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

				<li>

					<?php 
            // Verify the reply ID
            $reply_id = bbp_get_reply_id($widget_query->post->ID);
            $reply_link = '<a class="bbp-reply-topic-title" href="' . esc_url(bbp_get_reply_url($reply_id)) . '" title="' . esc_attr(bbp_get_reply_excerpt($reply_id, 50)) . '">' . bbp_get_reply_topic_title($reply_id) . '</a>';
            // Only query user if showing them
            if (!empty($settings['show_user'])) {
                $author_link = bbp_get_reply_author_link(array('post_id' => $reply_id, 'type' => 'both', 'size' => 14));
            } else {
                $author_link = false;
            }
            // Reply author, link, and timestamp
            if (!empty($settings['show_date']) && !empty($author_link)) {
                // translators: 1: reply author, 2: reply link, 3: reply timestamp
                printf(_x('%1$s on %2$s %3$s', 'widgets', 'bbpress'), $author_link, $reply_link, '<div>' . bbp_get_time_since(get_the_time('U')) . '</div>');
                // Reply link and timestamp
            } elseif (!empty($settings['show_date'])) {
                // translators: 1: reply link, 2: reply timestamp
                printf(_x('%1$s %2$s', 'widgets', 'bbpress'), $reply_link, '<div>' . bbp_get_time_since(get_the_time('U')) . '</div>');
                // Reply author and title
            } elseif (!empty($author_link)) {
                // translators: 1: reply author, 2: reply link
                printf(_x('%1$s on %2$s', 'widgets', 'bbpress'), $author_link, $reply_link);
                // Only the reply title
            } else {
                // translators: 1: reply link
                printf(_x('%1$s', 'widgets', 'bbpress'), $reply_link);
            }
            ?>

				</li>

			<?php 
        }
        ?>

		</ul>

		<?php 
        echo $args['after_widget'];
        // Reset the $post global
        wp_reset_postdata();
    }
Example #22
0
 /**
  * Runs through the various bbPress conditional tags to check the current page being viewed.  Once
  * a condition is met, add items to the $items array.
  *
  * @since  0.6.0
  * @access public
  * @return void
  */
 public function do_trail_items()
 {
     /* Add the network and site home links. */
     $this->do_network_home_link();
     $this->do_site_home_link();
     /* Get the forum post type object. */
     $post_type_object = get_post_type_object(bbp_get_forum_post_type());
     /* If not viewing the forum root/archive page and a forum archive exists, add it. */
     if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
         $this->items[] = '<a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a>';
     }
     /* If viewing the forum root/archive. */
     if (bbp_is_forum_archive()) {
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_forum_archive_title();
         }
     } elseif (bbp_is_topic_archive()) {
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_topic_archive_title();
         }
     } elseif (bbp_is_topic_tag()) {
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_topic_tag_name();
         }
     } elseif (bbp_is_topic_tag_edit()) {
         $this->items[] = '<a href="' . bbp_get_topic_tag_link() . '">' . bbp_get_topic_tag_name() . '</a>';
         if (true === $this->args['show_title']) {
             $this->items[] = __('Edit', 'breadcrumb-trail');
         }
     } elseif (bbp_is_single_view()) {
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_view_title();
         }
     } elseif (bbp_is_single_topic()) {
         /* Get the queried topic. */
         $topic_id = get_queried_object_id();
         /* Get the parent items for the topic, which would be its forum (and possibly forum grandparents). */
         $this->do_post_parents(bbp_get_topic_forum_id($topic_id));
         /* If viewing a split, merge, or edit topic page, show the link back to the topic.  Else, display topic title. */
         if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
             $this->items[] = '<a href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
         } elseif (true === $this->args['show_title']) {
             $this->items[] = bbp_get_topic_title($topic_id);
         }
         /* If viewing a topic split page. */
         if (bbp_is_topic_split() && true === $this->args['show_title']) {
             $this->items[] = __('Split', 'breadcrumb-trail');
         } elseif (bbp_is_topic_merge() && true === $this->args['show_title']) {
             $this->items[] = __('Merge', 'breadcrumb-trail');
         } elseif (bbp_is_topic_edit() && true === $this->args['show_title']) {
             $this->items[] = __('Edit', 'breadcrumb-trail');
         }
     } elseif (bbp_is_single_reply()) {
         /* Get the queried reply object ID. */
         $reply_id = get_queried_object_id();
         /* Get the parent items for the reply, which should be its topic. */
         $this->do_post_parents(bbp_get_reply_topic_id($reply_id));
         /* If viewing a reply edit page, link back to the reply. Else, display the reply title. */
         if (bbp_is_reply_edit()) {
             $this->items[] = '<a href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a>';
             if (true === $this->args['show_title']) {
                 $this->items[] = __('Edit', 'breadcrumb-trail');
             }
         } elseif (true === $this->args['show_title']) {
             $this->items[] = bbp_get_reply_title($reply_id);
         }
     } elseif (bbp_is_single_forum()) {
         /* Get the queried forum ID and its parent forum ID. */
         $forum_id = get_queried_object_id();
         $forum_parent_id = bbp_get_forum_parent_id($forum_id);
         /* If the forum has a parent forum, get its parent(s). */
         if (0 !== $forum_parent_id) {
             $this->do_post_parents($forum_parent_id);
         }
         /* Add the forum title to the end of the trail. */
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_forum_title($forum_id);
         }
     } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
         if (bbp_is_single_user_edit()) {
             $this->items[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a>';
             if (true === $this->args['show_title']) {
                 $this->items[] = __('Edit', 'breadcrumb-trail');
             }
         } elseif (true === $this->args['show_title']) {
             $this->items[] = bbp_get_displayed_user_field('display_name');
         }
     }
     /* Return the bbPress breadcrumb trail items. */
     $this->items = apply_filters('breadcrumb_trail_get_bbpress_items', $this->items, $this->args);
 }
Example #23
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;
 }
Example #24
0
/**
 * Return the link to the last reply in a topic
 *
 * @since 2.0.0 bbPress (r2683)
 *
 * @param int $topic_id Optional. Topic id
 * @uses bbp_get_topic_id() To get the topic id
 * @uses bbp_get_topic_last_reply_id() To get the topic last reply id
 * @uses bbp_get_reply_url() To get the reply url
 * @uses bbp_get_topic_permalink() To get the topic permalink
 * @uses apply_filters() Calls 'bbp_get_topic_last_topic_url' with
 *                        the reply url and topic id
 * @return string Topic last reply url
 */
function bbp_get_topic_last_reply_url($topic_id = 0)
{
    $topic_id = bbp_get_topic_id($topic_id);
    $reply_id = bbp_get_topic_last_reply_id($topic_id);
    if (!empty($reply_id) && $reply_id !== $topic_id) {
        $reply_url = bbp_get_reply_url($reply_id);
    } else {
        $reply_url = bbp_get_topic_permalink($topic_id);
    }
    return apply_filters('bbp_get_topic_last_reply_url', $reply_url, $topic_id, $reply_id);
}
Example #25
0
 /**
  * Reply Row actions
  *
  * Remove the quick-edit action link under the reply title and add the
  * content and spam link
  *
  * @since 2.0.0 bbPress (r2577)
  *
  * @param array $actions Actions
  * @param array $reply Reply object
  * @uses bbp_get_reply_post_type() To get the reply post type
  * @uses bbp_reply_content() To output reply content
  * @uses bbp_get_reply_url() To get the reply link
  * @uses bbp_get_reply_title() To get the reply title
  * @uses current_user_can() To check if the current user can edit or
  *                           delete the reply
  * @uses bbp_is_reply_spam() To check if the reply is marked as spam
  * @uses get_post_type_object() To get the reply post type object
  * @uses add_query_arg() To add custom args to the url
  * @uses remove_query_arg() To remove custom args from the url
  * @uses wp_nonce_url() To nonce the url
  * @uses get_delete_post_link() To get the delete post link of the reply
  * @return array $actions Actions
  */
 public function row_actions($actions, $reply)
 {
     if ($this->bail()) {
         return $actions;
     }
     unset($actions['inline hide-if-no-js']);
     // Reply view links to topic
     $actions['view'] = '<a href="' . esc_url(bbp_get_reply_url($reply->ID)) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;', 'bbpress'), bbp_get_reply_title($reply->ID))) . '" rel="permalink">' . esc_html__('View', 'bbpress') . '</a>';
     // User cannot view replies in trash
     if (bbp_get_trash_status_id() === $reply->post_status && !current_user_can('view_trash')) {
         unset($actions['view']);
     }
     // Only show the actions if the user is capable of viewing them
     if (current_user_can('moderate', $reply->ID)) {
         // Show the 'approve' link on pending posts only and 'unapprove' on published posts only
         $approve_uri = wp_nonce_url(add_query_arg(array('reply_id' => $reply->ID, 'action' => 'bbp_toggle_reply_approve'), remove_query_arg(array('bbp_reply_toggle_notice', 'reply_id', 'failed', 'super'))), 'approve-reply_' . $reply->ID);
         if (bbp_is_reply_published($reply->ID)) {
             $actions['unapproved'] = '<a href="' . esc_url($approve_uri) . '" title="' . esc_attr__('Unapprove this reply', 'bbpress') . '">' . _x('Unapprove', 'Unapprove reply', 'bbpress') . '</a>';
         } elseif (!bbp_is_reply_private($reply->ID)) {
             $actions['approved'] = '<a href="' . esc_url($approve_uri) . '" title="' . esc_attr__('Approve this reply', 'bbpress') . '">' . _x('Approve', 'Approve reply', 'bbpress') . '</a>';
         }
         // Show the 'spam' link on published and pending replies and 'not spam' on spammed replies
         if (in_array($reply->post_status, array(bbp_get_public_status_id(), bbp_get_pending_status_id(), bbp_get_spam_status_id()))) {
             $spam_uri = wp_nonce_url(add_query_arg(array('reply_id' => $reply->ID, 'action' => 'bbp_toggle_reply_spam'), remove_query_arg(array('bbp_reply_toggle_notice', 'reply_id', 'failed', 'super'))), 'spam-reply_' . $reply->ID);
             if (bbp_is_reply_spam($reply->ID)) {
                 $actions['spam'] = '<a href="' . esc_url($spam_uri) . '" title="' . esc_attr__('Mark the reply as not spam', 'bbpress') . '">' . esc_html__('Not spam', 'bbpress') . '</a>';
             } else {
                 $actions['spam'] = '<a href="' . esc_url($spam_uri) . '" title="' . esc_attr__('Mark this reply as spam', 'bbpress') . '">' . esc_html__('Spam', 'bbpress') . '</a>';
             }
         }
     }
     // Trash
     if (current_user_can('delete_reply', $reply->ID)) {
         if (bbp_get_trash_status_id() === $reply->post_status) {
             $post_type_object = get_post_type_object(bbp_get_reply_post_type());
             $actions['untrash'] = "<a title='" . esc_attr__('Restore this item from the Trash', 'bbpress') . "' href='" . esc_url(add_query_arg(array('_wp_http_referer' => add_query_arg(array('post_type' => bbp_get_reply_post_type()), admin_url('edit.php'))), wp_nonce_url(admin_url(sprintf($post_type_object->_edit_link . '&amp;action=untrash', $reply->ID)), 'untrash-' . $reply->post_type . '_' . $reply->ID))) . "'>" . esc_html__('Restore', 'bbpress') . "</a>";
         } elseif (EMPTY_TRASH_DAYS) {
             $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__('Move this item to the Trash', 'bbpress') . "' href='" . esc_url(add_query_arg(array('_wp_http_referer' => add_query_arg(array('post_type' => bbp_get_reply_post_type()), admin_url('edit.php'))), get_delete_post_link($reply->ID))) . "'>" . esc_html__('Trash', 'bbpress') . "</a>";
         }
         if (bbp_get_trash_status_id() === $reply->post_status || !EMPTY_TRASH_DAYS) {
             $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__('Delete this item permanently', 'bbpress') . "' href='" . esc_url(add_query_arg(array('_wp_http_referer' => add_query_arg(array('post_type' => bbp_get_reply_post_type()), admin_url('edit.php'))), get_delete_post_link($reply->ID, '', true))) . "'>" . esc_html__('Delete Permanently', 'bbpress') . "</a>";
         } elseif (bbp_get_spam_status_id() === $reply->post_status) {
             unset($actions['trash']);
         }
     }
     return $actions;
 }
Example #26
0
/**
 * Output the paginated url to the reply in the reply loop
 *
 * @since bbPress (r2679)
 *
 * @param int $reply_id Optional. Reply id
 * @uses bbp_get_reply_url() To get the reply url
 */
function bbp_reply_url($reply_id = 0)
{
    echo esc_url(bbp_get_reply_url($reply_id));
}
Example #27
0
/**
 * Mark notifications as read when reading a topic
 *
 * @since 2.5.0 bbPress (r5155)
 *
 * @return If not trying to mark a notification as read
 */
function bbp_buddypress_mark_notifications($action = '')
{
    // Bail if no topic ID is passed
    if (empty($_GET['topic_id'])) {
        return;
    }
    // Bail if action is not for this function
    if ('bbp_mark_read' !== $action) {
        return;
    }
    // Get required data
    $user_id = bp_loggedin_user_id();
    $topic_id = intval($_GET['topic_id']);
    // Check nonce
    if (!bbp_verify_nonce_request('bbp_mark_topic_' . $topic_id)) {
        bbp_add_error('bbp_notification_topic_id', __('<strong>ERROR</strong>: Are you sure you wanted to do that?', 'bbpress'));
        // Check current user's ability to edit the user
    } elseif (!current_user_can('edit_user', $user_id)) {
        bbp_add_error('bbp_notification_permissions', __('<strong>ERROR</strong>: You do not have permission to mark notifications for that user.', 'bbpress'));
    }
    // Bail if we have errors
    if (!bbp_has_errors()) {
        // Attempt to clear notifications for the current user from this topic
        $success = bp_notifications_mark_notifications_by_item_id($user_id, $topic_id, bbp_get_component_name(), 'bbp_new_reply');
        // Do additional subscriptions actions
        do_action('bbp_notifications_handler', $success, $user_id, $topic_id, $action);
    }
    // Redirect to the topic
    $redirect = bbp_get_reply_url($topic_id);
    // Redirect
    bbp_redirect($redirect);
}
Example #28
0
 protected function _bbpress_items()
 {
     $item = array();
     $post_type_object = get_post_type_object(bbp_get_forum_post_type());
     if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
         $item[] = '<span typeof="v:Breadcrumb"><a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '"  property="v:title" rel="v:url"><span>' . bbp_get_forum_archive_title() . '</span></a></span>';
     }
     if (bbp_is_forum_archive()) {
         $item[] = bbp_get_forum_archive_title();
     } elseif (bbp_is_topic_archive()) {
         $item[] = bbp_get_topic_archive_title();
     } elseif (bbp_is_single_view()) {
         $item[] = bbp_get_view_title();
     } elseif (bbp_is_single_topic()) {
         $topic_id = get_queried_object_id();
         $item = array_merge($item, $this->_get_parents(bbp_get_topic_forum_id($topic_id)));
         if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
             $item[] = '<span typeof="v:Breadcrumb"><a href="' . bbp_get_topic_permalink($topic_id) . '"  property="v:title" rel="v:url"><span>' . bbp_get_topic_title($topic_id) . '</span></a></span>';
         } else {
             $item[] = bbp_get_topic_title($topic_id);
         }
         if (bbp_is_topic_split()) {
             $item[] = __('Split', DH_DOMAIN);
         } elseif (bbp_is_topic_merge()) {
             $item[] = __('Merge', DH_DOMAIN);
         } elseif (bbp_is_topic_edit()) {
             $item[] = __('Edit', DH_DOMAIN);
         }
     } elseif (bbp_is_single_reply()) {
         $reply_id = get_queried_object_id();
         $item = array_merge($item, $this->_get_parents(bbp_get_reply_topic_id($reply_id)));
         if (!bbp_is_reply_edit()) {
             $item[] = bbp_get_reply_title($reply_id);
         } else {
             $item[] = '<span typeof="v:Breadcrumb"><a href="' . bbp_get_reply_url($reply_id) . '"  property="v:title" rel="v:url"><span>' . bbp_get_reply_title($reply_id) . '</span></a></span>';
             $item[] = __('Edit', DH_DOMAIN);
         }
     } elseif (bbp_is_single_forum()) {
         $forum_id = get_queried_object_id();
         $forum_parent_id = bbp_get_forum_parent_id($forum_id);
         if (0 !== $forum_parent_id) {
             $item = array_merge($item, $this->_get_parents($forum_parent_id));
         }
         $item[] = bbp_get_forum_title($forum_id);
     } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
         if (bbp_is_single_user_edit()) {
             $item[] = '<span typeof="v:Breadcrumb"><a href="' . bbp_get_user_profile_url() . '"  property="v:title" rel="v:url" ><span>' . bbp_get_displayed_user_field('display_name') . '</span></a></span>';
             $item[] = __('Edit', DH_DOMAIN);
         } else {
             $item[] = bbp_get_displayed_user_field('display_name');
         }
     }
     return $item;
 }
/**
 * Redirect if unathorized user is attempting to edit a reply
 *
 * @since bbPress (r3605)
 *
 * @uses bbp_is_reply_edit()
 * @uses current_user_can()
 * @uses bbp_get_topic_id()
 * @uses wp_safe_redirect()
 * @uses bbp_get_topic_permalink()
 */
function bbp_check_reply_edit()
{
    // Bail if not editing a topic
    if (!bbp_is_reply_edit()) {
        return;
    }
    // User cannot edit topic, so redirect back to reply
    if (!current_user_can('edit_reply', bbp_get_reply_id())) {
        wp_safe_redirect(bbp_get_reply_url());
        exit;
    }
}
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);
}