You are here

function twitter_filter_message in Twitter 7.5

Same name and namespace in other branches
  1. 6.5 twitter.module \twitter_filter_message()
  2. 7.6 twitter.module \twitter_filter_message()

Convert embedded URLs, hashtags and usernames in a tweet to links.

Parameters

string $message: The tweet's text.

bool $usernames: Whether or not to convert usernames to links. Defaults to TRUE.

bool $hashtags: Whether or not to convert hashtags to links. Defaults to TRUE.

bool $attributes: Whether or not to add extra attributes to links. Defaults to TRUE.

bool $urls: Whether or not to convert other URLs to links. Defaults to TRUE.

Return value

string The filtered tweet text.

2 calls to twitter_filter_message()
template_preprocess_twitter_status in ./twitter.module
Initialize variables for theme twitter_status.
twitter_views_handler_field_xss::render in ./twitter_views_field_handlers.inc
Processes the message through the selected options.

File

./twitter.module, line 428
Provides API integration with the Twitter microblogging service.

Code

function twitter_filter_message($message, $usernames = TRUE, $hashtags = TRUE, $attributes = TRUE, $urls = TRUE) {

  // Link usernames with their profiles.
  if ($usernames) {
    $message = _twitter_filter_username($message);
  }

  // Link hashtags.
  if ($hashtags) {
    $message = _twitter_filter_hashtag($message);
  }

  // Add extra attributes to links.
  if ($attributes) {
    $message = _twitter_filter_link($message);
  }

  // Standard URLs.
  if ($urls) {
    $filter = new stdClass();
    $filter->settings = array(
      'filter_url_length' => 496,
    );
    $message = _filter_url($message, $filter);
  }

  // Add twitter message filter alter.
  drupal_alter('twitter_filter_message', $message);

  // Avoid XSS within the message.
  return filter_xss($message);
}