WordPress.org

Make WordPress Core

Changeset 23787


Ignore:
Timestamp:
03/22/2013 06:57:50 PM (8 years ago)
Author:
lancewillett
Message:

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.

File:
1 edited

Legend:

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

    r23786 r23787  
    422422if ( ! function_exists( 'twentythirteen_get_first_url' ) ) :
    423423/**
    424  * Return the URL for the first link in the post content or the permalink if no
    425  * URL is found.
     424 * Returns the URL from the post.
     425 *
     426 * @uses get_the_link() to get the URL in the post meta (if it exists) or
     427 * the first link found in the post content.
     428 *
     429 * Falls back to the post permalink if no URL is found in the post.
    426430 *
    427431 * @since Twenty Thirteen 1.0
     
    429433 */
    430434function twentythirteen_get_first_url() {
    431     $has_url = preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $match );
    432     $link    = ( $has_url ) ? $match[1] : apply_filters( 'the_permalink', get_permalink() );
    433 
    434     return esc_url_raw( $link );
     435    $has_url = get_the_url();
     436
     437    return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() );
    435438}
    436439endif;
Note: See TracChangeset for help on using the changeset viewer.