Changeset 17968 for trunk/wp-content/themes/twentyeleven/functions.php
- Timestamp:
- 05/19/2011 08:31:01 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-content/themes/twentyeleven/functions.php
r17959 r17968 450 450 451 451 /** 452 * Grab the first URL from a Link post 452 * Return the URL for the first link found in the post content. 453 * 454 * @since Twenty Eleven 1.0 455 * @return string|bool URL or false when no link is present. 453 456 */ 454 457 function twentyeleven_url_grabber() { 455 global $post, $posts; 456 457 $first_url = ''; 458 459 ob_start(); 460 ob_end_clean(); 461 462 $output = preg_match_all('/<a.+href=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); 463 464 $first_url = $matches [1] [0]; 465 466 if ( empty( $first_url ) ) 458 if ( ! preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) ) 467 459 return false; 468 460 469 return $first_url;461 return esc_url_raw( $matches[1] ); 470 462 } 471 463
Note: See TracChangeset
for help on using the changeset viewer.