/** * @covers ::bbp_topic_title * @covers ::bbp_get_topic_title */ public function test_bbp_get_topic_title() { $f = $this->factory->forum->create(); $t = $this->factory->topic->create(array('post_title' => 'Topic 1', 'post_parent' => $f, 'topic_meta' => array('forum_id' => $f))); $topic_title = bbp_get_topic_title($t); $this->assertSame('Topic 1', $topic_title); }
/** * @group canonical * @covers ::bbp_insert_topic */ public function test_bbp_insert_topic() { $f = $this->factory->forum->create(); $now = time(); $post_date = date('Y-m-d H:i:s', $now - 60 * 60 * 100); $t = $this->factory->topic->create(array('post_title' => 'Topic 1', 'post_content' => 'Content for Topic 1', 'post_parent' => $f, 'post_date' => $post_date, 'topic_meta' => array('forum_id' => $f))); $r = $this->factory->reply->create(array('post_parent' => $t, 'post_date' => $post_date, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t))); // Get the topic. $topic = bbp_get_topic($t); remove_all_filters('bbp_get_topic_content'); // Topic post. $this->assertSame('Topic 1', bbp_get_topic_title($t)); $this->assertSame('Content for Topic 1', bbp_get_topic_content($t)); $this->assertSame('publish', bbp_get_topic_status($t)); $this->assertSame($f, wp_get_post_parent_id($t)); $this->assertEquals('http://' . WP_TESTS_DOMAIN . '/?topic=' . $topic->post_name, $topic->guid); // Topic meta. $this->assertSame($f, bbp_get_topic_forum_id($t)); $this->assertSame(1, bbp_get_topic_reply_count($t, true)); $this->assertSame(0, bbp_get_topic_reply_count_hidden($t, true)); $this->assertSame(1, bbp_get_topic_voice_count($t, true)); $this->assertSame($r, bbp_get_topic_last_reply_id($t)); $this->assertSame($r, bbp_get_topic_last_active_id($t)); $this->assertSame('4 days, 4 hours ago', bbp_get_topic_last_active_time($t)); }
/** * Format the BuddyBar/Toolbar notifications * * @since 2.5.0 bbPress (r5155) * * @package bbPress * * @param string $action The kind of notification being rendered * @param int $item_id The primary item id * @param int $secondary_item_id The secondary item id * @param int $total_items The total number of messaging-related notifications waiting for the user * @param string $format 'string' for BuddyBar-compatible notifications; 'array' for WP Toolbar */ function bbp_format_buddypress_notifications($action, $item_id, $secondary_item_id, $total_items, $format = 'string') { // Bail if not the notification action we are looking for if ('bbp_new_reply' !== $action) { return $action; } // New reply notifications $topic_id = bbp_get_reply_topic_id($item_id); $topic_title = bbp_get_topic_title($topic_id); $topic_link = wp_nonce_url(add_query_arg(array('action' => 'bbp_mark_read', 'topic_id' => $topic_id), bbp_get_reply_url($item_id)), 'bbp_mark_topic_' . $topic_id); $title_attr = __('Topic Replies', 'bbpress'); if ((int) $total_items > 1) { $text = sprintf(__('You have %d new replies', 'bbpress'), (int) $total_items); $filter = 'bbp_multiple_new_subscription_notification'; } else { if (!empty($secondary_item_id)) { $text = sprintf(__('You have %d new reply to %2$s from %3$s', 'bbpress'), (int) $total_items, $topic_title, bp_core_get_user_displayname($secondary_item_id)); } else { $text = sprintf(__('You have %d new reply to %s', 'bbpress'), (int) $total_items, $topic_title); } $filter = 'bbp_single_new_subscription_notification'; } // WordPress Toolbar if ('string' === $format) { $return = apply_filters($filter, '<a href="' . esc_url($topic_link) . '" title="' . esc_attr($title_attr) . '">' . esc_html($text) . '</a>', (int) $total_items, $text, $topic_link); // Deprecated BuddyBar } else { $return = apply_filters($filter, array('text' => $text, 'link' => $topic_link), $topic_link, (int) $total_items, $text, $topic_title); } do_action('bbp_format_buddypress_notifications', $action, $item_id, $secondary_item_id, $total_items); return $return; }
/** * 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; }
/** * @covers ::bbp_topic_last_reply_title * @covers ::bbp_get_topic_last_reply_title */ public function test_bbp_get_topic_last_reply_title() { $f = $this->factory->forum->create(); $t = $this->factory->topic->create(array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f))); $title = bbp_get_topic_last_reply_title($t); $this->assertSame('', $title); $this->factory->reply->create(array('post_parent' => $t, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t))); $title = bbp_get_topic_last_reply_title($t); $this->assertSame('Reply To: ' . bbp_get_topic_title($t), $title); }
public static function reply_title($title, $reply_id, $topic_id, $user_id) { $subject = get_option('_bbp_reply_notice_title'); // Because we're expecting a string from get_option(), let's use is_string() // to check for a string and then ensure the string is longer than `0`. If it isn't // a string, bail returning the original $title. if (!is_string($subject) && strlen($subject) == 0) { return $title; } // The reply title token to replace. $search = '{title}'; // The topic title that will replace the title token. $replace = strip_tags(bbp_get_topic_title($topic_id)); // Replace the title token if it exists in the custom title. $title = str_replace($search, $replace, $subject); return $title; }
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; }
/** * Custom page title for bbPress pages * * @since bbPress (r2788) * * @param string $title Optional. The title (not used). * @param string $sep Optional, default is '»'. How to separate the * various items within the page title. * @param string $seplocation Optional. Direction to display title, 'right'. * @uses bbp_is_single_user() To check if it's a user profile page * @uses bbp_is_single_user_edit() To check if it's a user profile edit page * @uses bbp_is_user_home() To check if the profile page is of the current user * @uses get_query_var() To get the user id * @uses get_userdata() To get the user data * @uses bbp_is_single_forum() To check if it's a forum * @uses bbp_get_forum_title() To get the forum title * @uses bbp_is_single_topic() To check if it's a topic * @uses bbp_get_topic_title() To get the topic title * @uses bbp_is_single_reply() To check if it's a reply * @uses bbp_get_reply_title() To get the reply title * @uses is_tax() To check if it's the tag page * @uses get_queried_object() To get the queried object * @uses bbp_is_single_view() To check if it's a view * @uses bbp_get_view_title() To get the view title * @uses apply_filters() Calls 'bbp_raw_title' with the title * @uses apply_filters() Calls 'bbp_profile_page_wp_title' with the title, * separator and separator location * @return string The tite */ function bbp_title($title = '', $sep = '»', $seplocation = '') { // Title array $new_title = array(); /** Archives **************************************************************/ // Forum Archive if (bbp_is_forum_archive()) { $new_title['text'] = bbp_get_forum_archive_title(); // Topic Archive } elseif (bbp_is_topic_archive()) { $new_title['text'] = bbp_get_topic_archive_title(); /** Edit ******************************************************************/ // Forum edit page } elseif (bbp_is_forum_edit()) { $new_title['text'] = bbp_get_forum_title(); $new_title['format'] = esc_attr__('Forum Edit: %s', 'bbpress'); // Topic edit page } elseif (bbp_is_topic_edit()) { $new_title['text'] = bbp_get_topic_title(); $new_title['format'] = esc_attr__('Topic Edit: %s', 'bbpress'); // Reply edit page } elseif (bbp_is_reply_edit()) { $new_title['text'] = bbp_get_reply_title(); $new_title['format'] = esc_attr__('Reply Edit: %s', 'bbpress'); // Topic tag edit page } elseif (bbp_is_topic_tag_edit()) { $new_title['text'] = bbp_get_topic_tag_name(); $new_title['format'] = esc_attr__('Topic Tag Edit: %s', 'bbpress'); /** Singles ***************************************************************/ // Forum page } elseif (bbp_is_single_forum()) { $new_title['text'] = bbp_get_forum_title(); $new_title['format'] = esc_attr__('Forum: %s', 'bbpress'); // Topic page } elseif (bbp_is_single_topic()) { $new_title['text'] = bbp_get_topic_title(); $new_title['format'] = esc_attr__('Topic: %s', 'bbpress'); // Replies } elseif (bbp_is_single_reply()) { $new_title['text'] = bbp_get_reply_title(); // Topic tag page } elseif (bbp_is_topic_tag() || get_query_var('bbp_topic_tag')) { $new_title['text'] = bbp_get_topic_tag_name(); $new_title['format'] = esc_attr__('Topic Tag: %s', 'bbpress'); /** Users *****************************************************************/ // Profile page } elseif (bbp_is_single_user()) { // User is viewing their own profile if (bbp_is_user_home()) { $new_title['text'] = esc_attr_x('Your', 'User viewing his/her own profile', 'bbpress'); // User is viewing someone else's profile (so use their display name) } else { $new_title['text'] = sprintf(esc_attr_x("%s's", 'User viewing another users profile', 'bbpress'), get_userdata(bbp_get_user_id())->display_name); } // User topics created if (bbp_is_single_user_topics()) { $new_title['format'] = esc_attr__("%s Topics", 'bbpress'); // User rueplies created } elseif (bbp_is_single_user_replies()) { $new_title['format'] = esc_attr__("%s Replies", 'bbpress'); // User favorites } elseif (bbp_is_favorites()) { $new_title['format'] = esc_attr__("%s Favorites", 'bbpress'); // User subscriptions } elseif (bbp_is_subscriptions()) { $new_title['format'] = esc_attr__("%s Subscriptions", 'bbpress'); // User "home" } else { $new_title['format'] = esc_attr__("%s Profile", 'bbpress'); } // Profile edit page } elseif (bbp_is_single_user_edit()) { // Current user if (bbp_is_user_home_edit()) { $new_title['text'] = esc_attr__('Edit Your Profile', 'bbpress'); // Other user } else { $new_title['text'] = get_userdata(bbp_get_user_id())->display_name; $new_title['format'] = esc_attr__("Edit %s's Profile", 'bbpress'); } /** Views *****************************************************************/ // Views } elseif (bbp_is_single_view()) { $new_title['text'] = bbp_get_view_title(); $new_title['format'] = esc_attr__('View: %s', 'bbpress'); /** Search ****************************************************************/ // Search } elseif (bbp_is_search()) { $new_title['text'] = bbp_get_search_title(); } // This filter is deprecated. Use 'bbp_before_title_parse_args' instead. $new_title = apply_filters('bbp_raw_title_array', $new_title); // Set title array defaults $new_title = bbp_parse_args($new_title, array('text' => $title, 'format' => '%s'), 'title'); // Get the formatted raw title $new_title = sprintf($new_title['format'], $new_title['text']); // Filter the raw title $new_title = apply_filters('bbp_raw_title', $new_title, $sep, $seplocation); // Compare new title with original title if ($new_title === $title) { return $title; } // Temporary separator, for accurate flipping, if necessary $t_sep = '%WP_TITILE_SEP%'; $prefix = ''; if (!empty($new_title)) { $prefix = " {$sep} "; } // sep on right, so reverse the order if ('right' === $seplocation) { $new_title_array = array_reverse(explode($t_sep, $new_title)); $new_title = implode(" {$sep} ", $new_title_array) . $prefix; // sep on left, do not reverse } else { $new_title_array = explode($t_sep, $new_title); $new_title = $prefix . implode(" {$sep} ", $new_title_array); } // Filter and return return apply_filters('bbp_title', $new_title, $sep, $seplocation); }
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); }
/** * Sends notification emails for new topics to subscribed forums * * Gets new post's ID and check if there are subscribed users to that forum, and * if there are, send notifications * * Note: in bbPress 2.6, we've moved away from 1 email per subscriber to 1 email * with everyone BCC'd. This may have negative repercussions for email services * that limit the number of addresses in a BCC field (often to around 500.) In * those cases, we recommend unhooking this function and creating your own * custom emailer script. * * @since 2.5.0 bbPress (r5156) * * @param int $topic_id ID of the newly made reply * @param int $forum_id ID of the forum for the topic * @param mixed $anonymous_data Array of anonymous user data * @param int $topic_author ID of the topic author ID * * @uses bbp_is_subscriptions_active() To check if the subscriptions are active * @uses bbp_get_topic_id() To validate the topic ID * @uses bbp_get_forum_id() To validate the forum ID * @uses bbp_is_topic_published() To make sure the topic is published * @uses bbp_get_forum_subscribers() To get the forum subscribers * @uses bbp_get_topic_author_display_name() To get the topic author's display name * @uses do_action() Calls 'bbp_pre_notify_forum_subscribers' with the topic id, * forum id and user id * @uses apply_filters() Calls 'bbp_forum_subscription_mail_message' with the * message, topic id, forum id and user id * @uses apply_filters() Calls 'bbp_forum_subscription_mail_title' with the * topic title, topic id, forum id and user id * @uses apply_filters() Calls 'bbp_forum_subscription_mail_headers' * @uses get_userdata() To get the user data * @uses wp_mail() To send the mail * @uses do_action() Calls 'bbp_post_notify_forum_subscribers' with the topic, * id, forum id and user id * @return bool True on success, false on failure */ function bbp_notify_forum_subscribers($topic_id = 0, $forum_id = 0, $anonymous_data = false, $topic_author = 0) { // Bail if subscriptions are turned off if (!bbp_is_subscriptions_active()) { return false; } /** Validation ************************************************************/ $topic_id = bbp_get_topic_id($topic_id); $forum_id = bbp_get_forum_id($forum_id); /** * Necessary for backwards compatibility * * @see https://bbpress.trac.wordpress.org/ticket/2620 */ $user_id = 0; /** Topic *****************************************************************/ // Bail if topic is not published if (!bbp_is_topic_published($topic_id)) { return false; } // Poster name $topic_author_name = bbp_get_topic_author_display_name($topic_id); /** Mail ******************************************************************/ // Remove filters from reply content and topic title to prevent content // from being encoded with HTML entities, wrapped in paragraph tags, etc... remove_all_filters('bbp_get_topic_content'); remove_all_filters('bbp_get_topic_title'); // Strip tags from text and setup mail data $topic_title = strip_tags(bbp_get_topic_title($topic_id)); $topic_content = strip_tags(bbp_get_topic_content($topic_id)); $topic_url = get_permalink($topic_id); $blog_name = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); // For plugins to filter messages per reply/topic/user $message = sprintf(__('%1$s wrote: %2$s Topic Link: %3$s ----------- You are receiving this email because you subscribed to a forum. Login and visit the topic to unsubscribe from these emails.', 'bbpress'), $topic_author_name, $topic_content, $topic_url); $message = apply_filters('bbp_forum_subscription_mail_message', $message, $topic_id, $forum_id, $user_id); if (empty($message)) { return; } // For plugins to filter titles per reply/topic/user $subject = apply_filters('bbp_forum_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $topic_id, $forum_id, $user_id); if (empty($subject)) { return; } /** User ******************************************************************/ // Get the noreply@ address $no_reply = bbp_get_do_not_reply_address(); // Setup "From" email address $from_email = apply_filters('bbp_subscription_from_email', $no_reply); // Setup the From header $headers = array('From: ' . get_bloginfo('name') . ' <' . $from_email . '>'); // Get topic subscribers and bail if empty $user_ids = bbp_get_forum_subscribers($forum_id, true); // Dedicated filter to manipulate user ID's to send emails to $user_ids = apply_filters('bbp_forum_subscription_user_ids', $user_ids); if (empty($user_ids)) { return false; } // Loop through users foreach ((array) $user_ids as $user_id) { // Don't send notifications to the person who made the post if (!empty($topic_author) && (int) $user_id === (int) $topic_author) { continue; } // Get email address of subscribed user $headers[] = 'Bcc: ' . get_userdata($user_id)->user_email; } /** Send it ***************************************************************/ // Custom headers $headers = apply_filters('bbp_subscription_mail_headers', $headers); $to_email = apply_filters('bbp_subscription_to_email', $no_reply); do_action('bbp_pre_notify_forum_subscribers', $topic_id, $forum_id, $user_ids); // Send notification email wp_mail($to_email, $subject, $message, $headers); do_action('bbp_post_notify_forum_subscribers', $topic_id, $forum_id, $user_ids); return true; }
/** * Return the title of the last topic inside a forum * * @since bbPress (r2625) * * @param int $forum_id Optional. Forum id * @uses bbp_get_forum_id() To get the forum id * @uses bbp_get_forum_last_topic_id() To get the forum's last topic id * @uses bbp_get_topic_title() To get the topic's title * @uses apply_filters() Calls 'bbp_get_forum_last_topic_title' with the * topic title and forum id * @return string Forum's last topic's title */ function bbp_get_forum_last_topic_title($forum_id = 0) { $forum_id = bbp_get_forum_id($forum_id); return apply_filters('bbp_get_forum_last_topic_title', bbp_get_topic_title(bbp_get_forum_last_topic_id($forum_id)), $forum_id); }
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 = ' / '; 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 “', 'mk_framework') . get_search_query() . '”'; } elseif (is_tag()) { echo __('Tag “', 'mk_framework') . single_tag_title('', false) . '”'; } 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>"; }
/** * Return the title of the last topic inside a forum * * @since bbPress (r2625) * * @param int $forum_id Optional. Forum id * @uses bbp_get_forum_id() To get the forum id * @uses bbp_get_forum_last_topic_id() To get the forum's last topic id * @uses bbp_get_topic_title() To get the topic's title * @uses apply_filters() Calls 'bbp_get_forum_last_topic_title' with the * topic title and forum id * @return string Forum's last topic's title */ function bbp_get_forum_last_topic_title($forum_id = 0) { $forum_id = bbp_get_forum_id($forum_id); $topic_id = bbp_get_forum_last_topic_id($forum_id); $title = !empty($topic_id) ? bbp_get_topic_title($topic_id) : ''; return apply_filters('bbp_get_forum_last_topic_title', $title, $forum_id); }
/** * 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); }
?> </form> </div> <?php } elseif (bbp_is_topic_closed()) { ?> <div id="no-reply-<?php bbp_topic_id(); ?> " class="bbp-no-reply"> <div class="bbp-template-notice"> <p><?php printf(esc_html__('The topic ‘%s’ is closed to new replies.', 'monsoon'), bbp_get_topic_title()); ?> </p> </div> </div> <?php } elseif (bbp_is_forum_closed(bbp_get_topic_forum_id())) { ?> <div id="no-reply-<?php bbp_topic_id(); ?> " class="bbp-no-reply"> <div class="bbp-template-notice"> <p><?php
/** * Ajax action for facilitating the forum auto-suggest * * @since bbPress (r4261) * * @uses get_posts() * @uses bbp_get_topic_post_type() * @uses bbp_get_topic_id() * @uses bbp_get_topic_title() */ public function suggest_topic() { global $wpdb; // Bail early if no request if (empty($_REQUEST['q'])) { wp_die('0'); } // Bail if user cannot moderate - only moderators can change hierarchy if (!current_user_can('moderate')) { wp_die('0'); } // Check the ajax nonce check_ajax_referer('bbp_suggest_topic_nonce'); // Try to get some topics $topics = get_posts(array('s' => $wpdb->esc_like($_REQUEST['q']), 'post_type' => bbp_get_topic_post_type())); // If we found some topics, loop through and display them if (!empty($topics)) { foreach ((array) $topics as $post) { printf(esc_html__('%s - %s', 'bbpress'), bbp_get_topic_id($post->ID), bbp_get_topic_title($post->ID) . "\n"); } } die; }
/** * 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); }
<?php if (is_user_logged_in() && current_user_can('edit_topic', bbp_get_topic_id())) { ?> <div id="merge-topic-<?php bbp_topic_id(); ?> " class="bbp-topic-merge"> <form id="merge_topic" name="merge_topic" method="post" action="<?php the_permalink(); ?> "> <div class="bbp-form"> <h3><?php printf(__('Merge topic "%s"', 'bbpress'), bbp_get_topic_title()); ?> </h3> <div class="alert alert-info"> <p><?php _e('Select the topic to merge this one into. The destination topic will remain the lead topic, and this one will change into a reply.', 'bbpress'); ?> </p> <p><?php _e('To keep this topic as the lead, go to the other topic and use the merge tool from there instead.', 'bbpress'); ?> </p> </div> <div class="alert alert-warning">
<form id="new-post" name="new-post" method="post" action="<?php the_permalink(); ?> "> <?php do_action('bbp_theme_before_topic_form'); ?> <fieldset class="bbp-form"> <legend> <?php if (bbp_is_topic_edit()) { printf(__('Now Editing “%s”', 'bbpress'), bbp_get_topic_title()); } else { bbp_is_single_forum() ? printf(__('Create New Topic in “%s”', 'bbpress'), bbp_get_forum_title()) : _e('Create New Topic', 'bbpress'); } ?> </legend> <?php do_action('bbp_theme_before_topic_form_notices'); ?> <?php if (!bbp_is_topic_edit() && bbp_is_forum_closed()) { ?>
/** * Print extra columns for the replies page * * @since 2.0.0 bbPress (r2577) * * @param string $column Column * @param int $reply_id reply id * @uses bbp_get_reply_topic_id() To get the topic id of the reply * @uses bbp_topic_title() To output the reply's topic title * @uses apply_filters() Calls 'reply_topic_row_actions' with an array * of reply topic actions * @uses bbp_get_topic_permalink() To get the topic permalink * @uses bbp_get_topic_forum_id() To get the forum id of the topic of * the reply * @uses bbp_get_forum_permalink() To get the forum permalink * @uses admin_url() To get the admin url of post.php * @uses apply_filters() Calls 'reply_topic_forum_row_actions' with an * array of reply topic forum actions * @uses bbp_reply_author_display_name() To output the reply author name * @uses get_the_date() Get the reply creation date * @uses get_the_time() Get the reply creation time * @uses esc_attr() To sanitize the reply creation time * @uses bbp_get_reply_last_active_time() To get the time when the reply was * last active * @uses do_action() Calls 'bbp_admin_replies_column_data' with the * column and reply id */ public function column_data($column, $reply_id) { if ($this->bail()) { return; } // Get topic ID $topic_id = bbp_get_reply_topic_id($reply_id); // Populate Column Data switch ($column) { // Topic case 'bbp_reply_topic': // Output forum name if (!empty($topic_id)) { // Topic Title $topic_title = bbp_get_topic_title($topic_id); if (empty($topic_title)) { $topic_title = esc_html__('No Topic', 'bbpress'); } // Output the title echo $topic_title; // Reply has no topic } else { esc_html_e('No Topic', 'bbpress'); } break; // Forum // Forum case 'bbp_reply_forum': // Get Forum ID's $reply_forum_id = bbp_get_reply_forum_id($reply_id); $topic_forum_id = bbp_get_topic_forum_id($topic_id); // Output forum name if (!empty($reply_forum_id)) { // Forum Title $forum_title = bbp_get_forum_title($reply_forum_id); if (empty($forum_title)) { $forum_title = esc_html__('No Forum', 'bbpress'); } // Alert capable users of reply forum mismatch if ($reply_forum_id !== $topic_forum_id) { if (current_user_can('edit_others_replies') || current_user_can('moderate')) { $forum_title .= '<div class="attention">' . esc_html__('(Mismatch)', 'bbpress') . '</div>'; } } // Output the title echo $forum_title; // Reply has no forum } else { _e('No Forum', 'bbpress'); } break; // Author // Author case 'bbp_reply_author': bbp_reply_author_display_name($reply_id); break; // Freshness // Freshness case 'bbp_reply_created': // Output last activity time and date printf('%1$s <br /> %2$s', get_the_date(), esc_attr(get_the_time())); break; // Do action for anything else // Do action for anything else default: do_action('bbp_admin_replies_column_data', $column, $reply_id); break; } }
/** * 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); }
<legend><?php _e('Split Method', 'bbpress'); ?> </legend> <div> <input name="bbp_topic_split_option" id="bbp_topic_split_option_reply" type="radio" checked="checked" value="reply" tabindex="<?php bbp_tab_index(); ?> " /> <label for="bbp_topic_split_option_reply"><?php printf(__('New topic in <strong>%s</strong> titled:', 'bbpress'), bbp_get_forum_title(bbp_get_topic_forum_id(bbp_get_topic_id()))); ?> </label> <input type="text" id="bbp_topic_split_destination_title" value="<?php printf(__('Split: %s', 'bbpress'), bbp_get_topic_title()); ?> " tabindex="<?php bbp_tab_index(); ?> " size="35" name="bbp_topic_split_destination_title" /> </div> <?php if (bbp_has_topics(array('show_stickies' => false, 'post_parent' => bbp_get_topic_forum_id(bbp_get_topic_id()), 'post__not_in' => array(bbp_get_topic_id())))) { ?> <div> <input name="bbp_topic_split_option" id="bbp_topic_split_option_existing" type="radio" value="existing" tabindex="<?php bbp_tab_index(); ?>
/** * Output the title of the topic * * @since 2.0.0 bbPress (r2485) * * @param int $topic_id Optional. Topic id * @uses bbp_get_topic_title() To get the topic title */ function bbp_topic_title($topic_id = 0) { echo bbp_get_topic_title($topic_id); }
/** * Custom page title for bbPress pages * * @since bbPress (r2788) * * @param string $title Optional. The title (not used). * @param string $sep Optional, default is '»'. How to separate the * various items within the page title. * @param string $seplocation Optional. Direction to display title, 'right'. * @uses bbp_is_single_user() To check if it's a user profile page * @uses bbp_is_single_user_edit() To check if it's a user profile edit page * @uses bbp_is_user_home() To check if the profile page is of the current user * @uses get_query_var() To get the user id * @uses get_userdata() To get the user data * @uses bbp_is_single_forum() To check if it's a forum * @uses bbp_get_forum_title() To get the forum title * @uses bbp_is_single_topic() To check if it's a topic * @uses bbp_get_topic_title() To get the topic title * @uses bbp_is_single_reply() To check if it's a reply * @uses bbp_get_reply_title() To get the reply title * @uses is_tax() To check if it's the tag page * @uses get_queried_object() To get the queried object * @uses bbp_is_single_view() To check if it's a view * @uses bbp_get_view_title() To get the view title * @uses apply_filters() Calls 'bbp_raw_title' with the title * @uses apply_filters() Calls 'bbp_profile_page_wp_title' with the title, * separator and separator location * @return string The tite */ function bbp_title($title = '', $sep = '»', $seplocation = '') { // Store original title to compare $_title = $title; /** Archives **************************************************************/ // Forum Archive if (bbp_is_forum_archive()) { $title = bbp_get_forum_archive_title(); // Topic Archive } elseif (bbp_is_topic_archive()) { $title = bbp_get_topic_archive_title(); /** Singles ***************************************************************/ // Forum page } elseif (bbp_is_single_forum()) { $title = sprintf(__('Forum: %s', 'bbpress'), bbp_get_forum_title()); // Topic page } elseif (bbp_is_single_topic()) { $title = sprintf(__('Topic: %s', 'bbpress'), bbp_get_topic_title()); // Replies } elseif (bbp_is_single_reply()) { $title = bbp_get_reply_title(); // Topic tag page (or edit) } elseif (bbp_is_topic_tag() || bbp_is_topic_tag_edit() || get_query_var('bbp_topic_tag')) { $term = get_queried_object(); $title = sprintf(__('Topic Tag: %s', 'bbpress'), $term->name); /** Users *****************************************************************/ // Profile page } elseif (bbp_is_single_user()) { // Current users profile if (bbp_is_user_home()) { $title = __('Your Profile', 'bbpress'); // Other users profile } else { $userdata = get_userdata(bbp_get_user_id()); $title = sprintf(__('%s\'s Profile', 'bbpress'), $userdata->display_name); } // Profile edit page } elseif (bbp_is_single_user_edit()) { // Current users profile if (bbp_is_user_home_edit()) { $title = __('Edit Your Profile', 'bbpress'); // Other users profile } else { $userdata = get_userdata(bbp_get_user_id()); $title = sprintf(__('Edit %s\'s Profile', 'bbpress'), $userdata->display_name); } /** Views *****************************************************************/ // Views } elseif (bbp_is_single_view()) { $title = sprintf(__('View: %s', 'bbpress'), bbp_get_view_title()); } // Filter the raw title $title = apply_filters('bbp_raw_title', $title, $sep, $seplocation); // Compare new title with original title if ($title == $_title) { return $title; } // Temporary separator, for accurate flipping, if necessary $t_sep = '%WP_TITILE_SEP%'; $prefix = ''; if (!empty($title)) { $prefix = " {$sep} "; } // sep on right, so reverse the order if ('right' == $seplocation) { $title_array = explode($t_sep, $title); $title_array = array_reverse($title_array); $title = implode(" {$sep} ", $title_array) . $prefix; // sep on left, do not reverse } else { $title_array = explode($t_sep, $title); $title = $prefix . implode(" {$sep} ", $title_array); } // Filter and return return apply_filters('bbp_title', $title, $sep, $seplocation); }
?> </form> </div> <?php } elseif (bbp_is_topic_closed()) { ?> <div id="no-reply-<?php bbp_topic_id(); ?> " class="bbp-no-reply"> <div class="bbp-template-notice"> <p><?php printf(__('The topic ‘%s’ is closed to new replies.', 'bbpress'), bbp_get_topic_title()); ?> </p> </div> </div> <?php } elseif (bbp_is_forum_closed(bbp_get_topic_forum_id())) { ?> <div id="no-reply-<?php bbp_topic_id(); ?> " class="bbp-no-reply"> <div class="bbp-template-notice"> <p><?php
function build_html() { // Store everything in an output buffer ob_start(); ?> <div class="widget showcase-widget"> <header class="widget-header"> <h3 class="widget-title">Recent Discussion</h3> </header> <ul class="recent-discussion-list"> <?php // Iterate topics while (bp_activities()) { bp_the_activity(); // Get the activity user $user = new Apoc_User(bp_get_activity_user_id(), 'directory', 40); // Get the activity type $type = bp_get_activity_type(); // Format activity based on context switch ($type) { case 'bbp_topic_create': $topic_id = bp_get_activity_item_id(); $link = '<a href="' . bbp_get_topic_permalink($topic_id) . '" title="Read topic" target="_blank">' . bbp_get_topic_title($topic_id) . '</a>'; $verb = 'created topic'; break; case 'bbp_reply_create': $reply_id = bp_get_activity_secondary_item_id(); $link = '<a href="' . bbp_get_topic_last_reply_url($reply_id) . '" title="Read reply" target="_blank">' . bbp_get_topic_title($reply_id) . '</a>'; $verb = 'replied to'; break; case 'new_blog_comment': $comment_id = bp_get_activity_secondary_item_id(); $comment = get_comment($comment_id); $link = '<a href="' . get_comment_link($comment_id) . '" title="Read reply" target="_blank">' . get_the_title($comment->comment_post_ID) . '</a>'; $verb = 'commented on'; break; } // Get the activity time $time = bp_core_time_since(bp_get_activity_date_recorded()); // Output the HTML ?> <li class="recent-discussion double-border"> <?php echo $user->avatar; ?> <div class="recent-discussion-content"> <span class="recent-discussion-title"><?php echo $user->link . ' ' . $verb . ' ' . $link; ?> </span> <span class="recent-discussion-time"><?php echo $time; ?> </div> </li> <?php } ?> </ul> </div><?php // Get the contents of the buffer $html = ob_get_contents(); ob_end_clean(); // Return the html to the class return $html; }
/** * Return the topic title a reply belongs to * * @since bbPress (r2553) * * @param int $reply_id Optional. Reply id * @uses bbp_get_reply_id() To get the reply id * @uses bbp_get_reply_topic_id() To get the reply topic id * @uses bbp_get_topic_title() To get the reply topic title * @uses apply_filters() Calls 'bbp_get_reply_topic_title' with the * topic title and reply id * @return string Reply's topic's title */ function bbp_get_reply_topic_title($reply_id = 0) { $reply_id = bbp_get_reply_id($reply_id); $topic_id = bbp_get_reply_topic_id($reply_id); return apply_filters('bbp_get_reply_topic_title', bbp_get_topic_title($topic_id), $reply_id); }
/** * @covers ::bbp_check_for_blacklist */ public function test_should_return_false_when_html_wrapped_content_matches_blacklist_keys() { $u = $this->factory->user->create(); $t = $this->factory->topic->create(array('post_author' => $u, 'post_title' => 'Sting', 'post_content' => 'Beware, there maybe bees <strong>hiber</strong><em>nating</em>.')); $anonymous_data = false; $author_id = bbp_get_topic_author_id($t); $title = bbp_get_topic_title($t); $content = bbp_get_topic_content($t); update_option('blacklist_keys', "hibernating\nfoo"); $result = bbp_check_for_blacklist($anonymous_data, $author_id, $title, $content); $this->assertFalse($result); }
/** * send_notification() * * Send the notification e-mails to the addresses defined in options */ function send_notification($topic_id = 0, $forum_id = 0, $anonymous_data = false, $topic_author = 0) { // Grab stuff we will be needing for the email $recipients = $this->get_recipients(); $blogname = 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); // Get the template $email_template = get_option('ja_bbp_notification_email_template'); // Swap out the shortcodes with useful information :) $find = array('[topic-title]', '[topic-content]', '[topic-excerpt]', '[topic-author]', '[topic-url]'); $replace = array($topic_title, $topic_content, $topic_excerpt, $topic_author, $topic_url); $email_body = str_replace($find, $replace, $email_template); $email_subject = $blogname . __(' new topic', 'ja_bbp_notifications') . ' - ' . $topic_title; if (!empty($recipients)) { // Send email to each user foreach ($recipients as $recipient) { @wp_mail($recipient, $email_subject, $email_body); } } }
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); }