From 4f8d3b5b6152d4c9bcd45bd2f1c6a05d06bbc823 Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Fri, 22 Mar 2013 22:42:37 +0000 Subject: [PATCH] Twenty Eleven: use new URL extraction function, `get_the_url()` for link post formats in the Ephemera widget. Props obenland, fixes #23618. git-svn-id: http://core.svn.wordpress.org/trunk@23792 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-content/themes/twentyeleven/functions.php | 17 +++++++++++++++-- wp-content/themes/twentyeleven/inc/widgets.php | 9 +-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/wp-content/themes/twentyeleven/functions.php b/wp-content/themes/twentyeleven/functions.php index 1d8385dd47..aed278bab2 100644 --- a/wp-content/themes/twentyeleven/functions.php +++ b/wp-content/themes/twentyeleven/functions.php @@ -458,7 +458,21 @@ function twentyeleven_content_nav( $html_id ) { } endif; // twentyeleven_content_nav -if ( ! function_exists( 'twentyeleven_url_grabber' ) ) : +/** + * Return the first link from the post content. If none found, the + * post permalink is used as a fallback. + * + * @return string + */ +function twentyeleven_get_first_url() { + $has_url = function_exists( 'get_the_url' ) ? get_the_url() : false; + + if ( ! $has_url ) + $has_url = twentyeleven_url_grabber(); + + return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() ); +} + /** * Return the URL for the first link found in the post content. * @@ -471,7 +485,6 @@ function twentyeleven_url_grabber() { return esc_url_raw( $matches[1] ); } -endif; /** * Count the number of footer sidebars to enable dynamic classes for the footer diff --git a/wp-content/themes/twentyeleven/inc/widgets.php b/wp-content/themes/twentyeleven/inc/widgets.php index c4c8ae0014..859cde1a82 100644 --- a/wp-content/themes/twentyeleven/inc/widgets.php +++ b/wp-content/themes/twentyeleven/inc/widgets.php @@ -95,14 +95,7 @@ class Twenty_Eleven_Ephemera_Widget extends WP_Widget {
  • - -   +   comments →', 'twentyeleven' ), __( '1 comment →', 'twentyeleven' ), __( '% comments →', 'twentyeleven' ) ); ?>