|
@@ 97-106 (lines=10) @@
|
| 94 |
|
|
| 95 |
|
// ----------------------------------- MENTIONS ------------------------------ |
| 96 |
|
|
| 97 |
|
if ( self::MENTIONS & $what_to_extract ) { |
| 98 |
|
if ( preg_match_all( '/(^|\s)@(\w+)/u', $stripped_content, $matches ) ) { |
| 99 |
|
$mentions = array_values( array_unique( $matches[2] ) ); //array_unique() retains the keys! |
| 100 |
|
$mentions = array_map( 'strtolower', $mentions ); |
| 101 |
|
$extracted['mention'] = array( 'name' => $mentions ); |
| 102 |
|
if ( !isset( $extracted['has'] ) ) |
| 103 |
|
$extracted['has'] = array(); |
| 104 |
|
$extracted['has']['mention'] = count( $mentions ); |
| 105 |
|
} |
| 106 |
|
} |
| 107 |
|
|
| 108 |
|
// ----------------------------------- HASHTAGS ------------------------------ |
| 109 |
|
/** Some hosts may not compile with --enable-unicode-properties and kick a warning: |
|
@@ 117-124 (lines=8) @@
|
| 114 |
|
//This regex does not exactly match Twitter's |
| 115 |
|
// if there are problems/complaints we should implement this: |
| 116 |
|
// https://github.com/twitter/twitter-text/blob/master/java/src/com/twitter/Regex.java |
| 117 |
|
if ( preg_match_all( '/(?:^|\s)#(\w*\p{L}+\w*)/u', $stripped_content, $matches ) ) { |
| 118 |
|
$hashtags = array_values( array_unique( $matches[1] ) ); //array_unique() retains the keys! |
| 119 |
|
$hashtags = array_map( 'strtolower', $hashtags ); |
| 120 |
|
$extracted['hashtag'] = array( 'name' => $hashtags ); |
| 121 |
|
if ( !isset( $extracted['has'] ) ) |
| 122 |
|
$extracted['has'] = array(); |
| 123 |
|
$extracted['has']['hashtag'] = count( $hashtags ); |
| 124 |
|
} |
| 125 |
|
} |
| 126 |
|
|
| 127 |
|
// ----------------------------------- SHORTCODES ------------------------------ |