Skip to:
Content

BuddyPress.org

Changeset 3474


Ignore:
Timestamp:
11/22/2010 12:17:43 AM (14 years ago)
Author:
boonebgorges
Message:

Adds filter that prevents embedded anchor tags for at-mentions in forum topic/post edit mode. References #2145

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-forums/bp-forums-filters.php

    r3300 r3474  
    111111add_filter( 'bp_page_title', 'bp_forums_add_forum_topic_to_page_title' );
    112112
     113/**
     114 * bp_forums_strip_mentions_on_post_edit( $title )
     115 *
     116 * Removes the anchor tag autogenerated for at-mentions when forum topics and posts are edited.
     117 * Prevents embedded anchor tags.
     118 *
     119 * @global object $bp
     120 * @param string $content
     121 * @return string $content
     122 */
     123function bp_forums_strip_mentions_on_post_edit( $content ) {
     124    global $bp;
     125   
     126    $content = htmlspecialchars_decode( $content );
     127   
     128    $pattern = "|<a href=&#039;" . $bp->root_domain . "/" . $bp->members->slug . "/[A-Za-z0-9-_\.]+/&#039; rel=&#039;nofollow&#039;>(@[A-Za-z0-9-_\.]+)</a>|";
     129   
     130    $content = preg_replace( $pattern, "$1", $content );
     131   
     132    return $content;
     133}
     134add_filter( 'bp_get_the_topic_post_edit_text', 'bp_forums_strip_mentions_on_post_edit' );
     135add_filter( 'bp_get_the_topic_text', 'bp_forums_strip_mentions_on_post_edit' );
     136
    113137?>
Note: See TracChangeset for help on using the changeset viewer.