WordPress.org

Make WordPress Core

Ticket #17267: 17267.diff

File 17267.diff, 951 bytes (added by duck_, 7 years ago)
  • wp-content/themes/twentyeleven/functions.php

     
    433433 * Grab the first URL from a Link post
    434434 */
    435435function twentyeleven_url_grabber() {
    436         global $post, $posts;
    437 
    438         $first_url = '';
    439 
    440         ob_start();
    441         ob_end_clean();
    442 
    443         $output = preg_match_all('/<a.+href=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
    444 
    445         $first_url = $matches [1] [0];
    446 
    447         if ( empty( $first_url ) )
     436        if ( ! preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) )
    448437                return false;
    449438
    450         return $first_url;
     439        return esc_url_raw( $matches[1] );
    451440}
    452441
    453442/**
     
    547536                        break;
    548537        endswitch;
    549538}
    550 endif; // ends check for twentyeleven_comment()
    551  No newline at end of file
     539endif; // ends check for twentyeleven_comment()