|i', 'bp_forums_make_nofollow_filter_callback', $text ); } /** * Callback for preg_replace_callback() in bp_forums_make_nofollow_filter(). * * @param array $matches Regex matches from {@link bp_forums_make_nofollow_filter()}. * @return string Text with nofollow links. */ function bp_forums_make_nofollow_filter_callback( $matches ) { $text = $matches[1]; $text = str_replace( array( ' rel="nofollow"', " rel='nofollow'"), '', $text ); return ""; } /** * Append forum topic to page title. * * @see bp_modify_page_title() * * @param string $title New page title; see {@link bp_modify_page_title()}. * @param string $original_title Original page title. * @param string $sep How to separate the various items within the page title. * @param string $seplocation Direction to display title. * @return string Page title with forum topic title appended. */ function bp_forums_add_forum_topic_to_page_title( $title, $original_title, $sep, $seplocation ) { if ( bp_is_current_action( 'forum' ) && bp_is_action_variable( 'topic', 0 ) ) if ( bp_has_forum_topic_posts() ) $title .= bp_get_the_topic_title() . " $sep "; return $title; } add_filter( 'bp_modify_page_title', 'bp_forums_add_forum_topic_to_page_title', 9, 4 ); /** * Remove the anchor tag autogenerated for at-mentions when forum topics and posts are edited. * * Prevents embedded anchor tags. * * @param string $content Edited post content. * @return string $content Sanitized post content. */ function bp_forums_strip_mentions_on_post_edit( $content ) { $content = htmlspecialchars_decode( $content ); $directory = bp_get_members_directory_permalink(); $pattern = "|(@[A-Za-z0-9-_\.@]+)|"; $content = preg_replace( $pattern, "$1", $content ); return $content; } add_filter( 'bp_get_the_topic_post_edit_text', 'bp_forums_strip_mentions_on_post_edit' ); add_filter( 'bp_get_the_topic_text', 'bp_forums_strip_mentions_on_post_edit' ); /** "Replied to" SQL filters *************************************************/ /** * Filter the get_topics_distinct portion of the Forums SQL when on a user's Replied To page. * * This filter is added in bp_has_forum_topics(). * * @since 1.5.0 * * @param string $sql SQL fragment. * @return string $sql SQL fragment of the form "DISTINCT t.topic_id, ". */ function bp_forums_add_replied_distinct_sql( $sql ) { $sql = "DISTINCT t.topic_id, "; return $sql; } /** * Filter the get_topics_join portion of the Forums sql when on a user's Replied To page. * * This filter is added in bp_has_forum_topics(). * * @since 1.5.0 * * @global object $bbdb The bbPress database global. * * @param string $sql SQL statement. * @return string $sql SQL statement. */ function bp_forums_add_replied_join_sql( $sql ) { global $bbdb; $sql .= " LEFT JOIN {$bbdb->posts} p ON p.topic_id = t.topic_id "; return $sql; } /** * Filter the get_topics_where portion of the Forums sql when on a user's Replied To page. * * This filter is added in bp_has_forum_topics(). * * @since 1.5.0 * * @global object $wpdb The WordPress database global. * * @param string $sql SQL fragment. * @return string $sql SQL fragment. */ function bp_forums_add_replied_where_sql( $sql ) { global $wpdb; $sql .= $wpdb->prepare( " AND p.poster_id = %s ", bp_displayed_user_id() ); // Remove any topic_author information. $sql = str_replace( " AND t.topic_poster = '" . bp_displayed_user_id() . "'", '', $sql ); return $sql; }