From afb960a4809fce8dae9d5b867d157dd5beb1499e Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Thu, 19 May 2011 08:31:01 +0000 Subject: [PATCH] Fix twentyeleven_url_grabber(). props duck_, see #17267. git-svn-id: https://develop.svn.wordpress.org/trunk@17968 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-content/themes/twentyeleven/functions.php | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/wp-content/themes/twentyeleven/functions.php b/wp-content/themes/twentyeleven/functions.php index e032635cfe..da1a11605e 100644 --- a/wp-content/themes/twentyeleven/functions.php +++ b/wp-content/themes/twentyeleven/functions.php @@ -449,24 +449,16 @@ function twentyeleven_content_nav( $nav_id ) { } /** - * Grab the first URL from a Link post + * Return the URL for the first link found in the post content. + * + * @since Twenty Eleven 1.0 + * @return string|bool URL or false when no link is present. */ function twentyeleven_url_grabber() { - global $post, $posts; - - $first_url = ''; - - ob_start(); - ob_end_clean(); - - $output = preg_match_all('//i', $post->post_content, $matches); - - $first_url = $matches [1] [0]; - - if ( empty( $first_url ) ) + if ( ! preg_match( '/]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) ) return false; - return $first_url; + return esc_url_raw( $matches[1] ); } /**