twentyeleven_url_grabber

Return the URL for the first link found in the post content.

Description

(string|bool) twentyeleven_url_grabber(); 

Returns (string|bool)

URL or false when no link is present.


Usage

  1. if ( !function_exists( 'twentyeleven_url_grabber' ) ) { 
  2. require_once '/functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = twentyeleven_url_grabber(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/functions.php  
  1. function twentyeleven_url_grabber() { 
  2. if ( ! preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) ) 
  3. return false; 
  4.  
  5. return esc_url_raw( $matches[1] );