From ca74e47950030f1bff35e90e8f862b6ccfeed257 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Fri, 22 Mar 2013 18:57:50 +0000 Subject: [PATCH] Twenty Thirteen: use new `get_the_url()` function to find first link in a "Link" post format post. See #23619, props Frank Klein for the original patch. git-svn-id: https://develop.svn.wordpress.org/trunk@23787 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-content/themes/twentythirteen/functions.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/wp-content/themes/twentythirteen/functions.php b/wp-content/themes/twentythirteen/functions.php index ca73ced328..fe47f51d6d 100644 --- a/wp-content/themes/twentythirteen/functions.php +++ b/wp-content/themes/twentythirteen/functions.php @@ -421,17 +421,20 @@ endif; if ( ! function_exists( 'twentythirteen_get_first_url' ) ) : /** - * Return the URL for the first link in the post content or the permalink if no - * URL is found. + * Returns the URL from the post. + * + * @uses get_the_link() to get the URL in the post meta (if it exists) or + * the first link found in the post content. + * + * Falls back to the post permalink if no URL is found in the post. * * @since Twenty Thirteen 1.0 * @return string URL */ function twentythirteen_get_first_url() { - $has_url = preg_match( '/]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $match ); - $link = ( $has_url ) ? $match[1] : apply_filters( 'the_permalink', get_permalink() ); + $has_url = get_the_url(); - return esc_url_raw( $link ); + return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() ); } endif;