Make WordPress Core

Changeset 23792


Ignore:
Timestamp:
03/22/2013 10:42:37 PM (14 years ago)
Author:
lancewillett
Message:

Twenty Eleven: use new URL extraction function, get_the_url() for link post formats in the Ephemera widget. Props obenland, fixes #23618.

Location:
trunk/wp-content/themes/twentyeleven
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/twentyeleven/functions.php

    r23778 r23792  
    459459endif; // twentyeleven_content_nav
    460460
    461 if ( ! function_exists( 'twentyeleven_url_grabber' ) ) :
     461/**
     462 * Return the first link from the post content. If none found, the
     463 * post permalink is used as a fallback.
     464 *
     465 * @return string
     466 */
     467function twentyeleven_get_first_url() {
     468        $has_url = function_exists( 'get_the_url' ) ? get_the_url() : false;
     469
     470        if ( ! $has_url )
     471                $has_url = twentyeleven_url_grabber();
     472
     473        return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() );
     474}
     475
    462476/**
    463477 * Return the URL for the first link found in the post content.
    … …  
    472486        return esc_url_raw( $matches[1] );
    473487}
    474 endif;
    475488
    476489/**
  • trunk/wp-content/themes/twentyeleven/inc/widgets.php

    r23191 r23792  
    9696
    9797                                <li class="widget-entry-title">
    98                                         <?php
    99                                                 // Grab first link from the post content. If none found, use the post permalink as fallback.
    100                                                 $link_url = twentyeleven_url_grabber();
    101 
    102                                                 if ( empty( $link_url ) )
    103                                                         $link_url = get_permalink();
    104                                         ?>
    105                                         <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>
     98                                        <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>
    10699                                        <span class="comments-link">
    107100                                                <?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' ) ); ?>
Note: See TracChangeset for help on using the changeset viewer.