Make WordPress Core


Ignore:
Timestamp:
05/19/2011 08:31:01 AM (13 years ago)
Author:
nacin
Message:

Fix twentyeleven_url_grabber(). props duck_, see #17267.

File:
1 edited

Legend:

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

    r17959 r17968  
    450450
    451451/**
    452  * Grab the first URL from a Link post
     452 * Return the URL for the first link found in the post content.
     453 *
     454 * @since Twenty Eleven 1.0
     455 * @return string|bool URL or false when no link is present.
    453456 */
    454457function twentyeleven_url_grabber() {
    455     global $post, $posts;
    456 
    457     $first_url = '';
    458 
    459     ob_start();
    460     ob_end_clean();
    461 
    462     $output = preg_match_all('/<a.+href=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
    463 
    464     $first_url = $matches [1] [0];
    465 
    466     if ( empty( $first_url ) )
     458    if ( ! preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) )
    467459        return false;
    468460
    469     return $first_url;
     461    return esc_url_raw( $matches[1] );
    470462}
    471463
Note: See TracChangeset for help on using the changeset viewer.