Summery Summery

Conditionally makes a hyperlink based on an internal class variable.

Syntax Syntax

WP_Embed::maybe_make_link( string $url )

Parameters Parameters


(string) (Required) URL to potentially be linked.

Return Return

(string|false) Linked URL or the original URL. False if 'return_false_on_fail' is true.

Source Source

File: wp-includes/class-wp-embed.php

		$content = wp_replace_in_html_tags( $content, array( "\n" => '<!-- wp-line-break -->' ) );

		if ( preg_match( '#(^|\s|>)https?://#i', $content ) ) {
			// Find URLs on their own line.
			$content = preg_replace_callback( '|^(\s*)(https?://[^\s<>"]+)(\s*)$|im', array( $this, 'autoembed_callback' ), $content );
			// Find URLs in their own paragraph.
			$content = preg_replace_callback( '|(<p(?: [^>]*)?>\s*)(https?://[^\s<>"]+)(\s*<\/p>)|i', array( $this, 'autoembed_callback' ), $content );

		// Put the line breaks back.
		return str_replace( '<!-- wp-line-break -->', "\n", $content );

	 * Callback function for WP_Embed::autoembed().
	 * @param array $match A regex match array.



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.