• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress core a2z

WordPress core a2z

WordPress core only

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / get_url_in_content() – Extract and return the first URL from passed content.

You appear to be a bot. Output may be restricted

Description

Extract and return the first URL from passed content.

Usage

$string|false = get_url_in_content( $content );

Parameters

$content
( string ) required – A string which might contain a URL.

Returns

string|false The found URL.

Source

File name: wordpress/wp-includes/formatting.php
Lines:

1 to 11 of 11
function get_url_in_content( $content ) {
  if ( empty( $content ) ) {
    return false;
  }

  if ( preg_match( '/<a\s[^>]*?href=([\'"])(.+?)\1/is', $content, $matches ) ) {
    return esc_url_raw( $matches[2] );
  }

  return false;
}
 

 View on GitHub View on Trac

Published: 25th November 2019 | Last updated: 25th November 2019

Primary Sidebar

Information

Function name: get_url_in_content
Plugin ref: WordPress
Version: 5.6.2
Sourcefile: wp-includes/formatting.php
File ref: wp-includes/formatting.php
Deprecated?: No
API Letters: C,G,I,U

Footer

WP-a2z
WordPress core a2z
WordPress core only
WordPress 5.6.2
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  core.wp-a2z.org
© Copyright WP-a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites