Changeset 24682 for trunk/wp-includes/post-formats.php
- Timestamp:
- 07/12/2013 07:34:59 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post-formats.php
r24554 r24682 236 236 237 237 /** 238 * Extract a URL from passed content, if possible 239 * Checks for a URL on the first line of the content or the first encountered href attribute. 238 * Extract and return the first URL from passed content. 240 239 * 241 240 * @since 3.6.0 … … 244 243 * @return string The found URL. 245 244 */ 246 function get_ content_url( $content ) {245 function get_url_in_content( $content ) { 247 246 if ( empty( $content ) ) 248 247 return ''; 249 248 250 // the content is a URL 251 $trimmed = trim( $content ); 252 if ( 0 === stripos( $trimmed, 'http' ) && ! preg_match( '#\s#', $trimmed ) ) { 253 return $trimmed; 254 255 // the content is HTML so we grab the first href 256 } elseif ( preg_match( '/<a\s[^>]*?href=([\'"])(.+?)\1/is', $content, $matches ) ) { 249 if ( preg_match( '/<a\s[^>]*?href=([\'"])(.+?)\1/is', $content, $matches ) ) 257 250 return esc_url_raw( $matches[2] ); 258 } 259 260 $lines = explode( "\n", $trimmed ); 261 $line = trim( array_shift( $lines ) ); 262 263 // the content is a URL followed by content 264 if ( 0 === stripos( $line, 'http' ) ) 265 return esc_url_raw( $line ); 266 267 return ''; 251 252 return false; 268 253 } 269 254
Note: See TracChangeset
for help on using the changeset viewer.