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
This commit is contained in:
Lance Willett 2013-03-22 22:42:37 +00:00
parent 16632826c9
commit 4f8d3b5b61
2 changed files with 16 additions and 10 deletions

View File

@ -458,7 +458,21 @@ function twentyeleven_content_nav( $html_id ) {
} }
endif; // twentyeleven_content_nav 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. * 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] ); return esc_url_raw( $matches[1] );
} }
endif;
/** /**
* Count the number of footer sidebars to enable dynamic classes for the footer * Count the number of footer sidebars to enable dynamic classes for the footer

View File

@ -95,14 +95,7 @@ class Twenty_Eleven_Ephemera_Widget extends WP_Widget {
<?php else : ?> <?php else : ?>
<li class="widget-entry-title"> <li class="widget-entry-title">
<?php <a href="<?php echo esc_url( twentyeleven_get_first_url() ); ?>" title="<?php echo esc_attr( sprintf( __( 'Link to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?>&nbsp;<span>&rarr;</span></a>
// Grab first link from the post content. If none found, use the post permalink as fallback.
$link_url = twentyeleven_url_grabber();
if ( empty( $link_url ) )
$link_url = get_permalink();
?>
<a href="<?php echo esc_url( $link_url ); ?>" title="<?php echo esc_attr( sprintf( __( 'Link to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?>&nbsp;<span>&rarr;</span></a>
<span class="comments-link"> <span class="comments-link">
<?php comments_popup_link( __( '0 <span class="reply">comments &rarr;</span>', 'twentyeleven' ), __( '1 <span class="reply">comment &rarr;</span>', 'twentyeleven' ), __( '% <span class="reply">comments &rarr;</span>', 'twentyeleven' ) ); ?> <?php comments_popup_link( __( '0 <span class="reply">comments &rarr;</span>', 'twentyeleven' ), __( '1 <span class="reply">comment &rarr;</span>', 'twentyeleven' ), __( '% <span class="reply">comments &rarr;</span>', 'twentyeleven' ) ); ?>
</span> </span>