Title: WP_Embed::maybe_make_link
Published: April 25, 2014
Last modified: April 28, 2025

---

# WP_Embed::maybe_make_link( string $url ): string|false

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_embed/maybe_make_link/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_embed/maybe_make_link/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_embed/maybe_make_link/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/classes/wp_embed/maybe_make_link/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/classes/wp_embed/maybe_make_link/?output_format=md#related)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_embed/maybe_make_link/?output_format=md#wp--skip-link--target)

Conditionally makes a hyperlink based on an internal class variable.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_embed/maybe_make_link/?output_format=md#parameters)󠁿

 `$url`stringrequired

URL to potentially be linked.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_embed/maybe_make_link/?output_format=md#return)󠁿

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

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_embed/maybe_make_link/?output_format=md#source)󠁿

    ```php
    public function maybe_make_link( $url ) {
    	if ( $this->return_false_on_fail ) {
    		return false;
    	}

    	$output = ( $this->linkifunknown ) ? '<a href="' . esc_url( $url ) . '">' . esc_html( $url ) . '</a>' : $url;

    	/**
    	 * Filters the returned, maybe-linked embed URL.
    	 *
    	 * @since 2.9.0
    	 *
    	 * @param string $output The linked or original URL.
    	 * @param string $url    The original URL.
    	 */
    	return apply_filters( 'embed_maybe_make_link', $output, $url );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-embed.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-embed.php#L478)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-embed.php#L478-L494)

## 󠀁[Hooks](https://developer.wordpress.org/reference/classes/wp_embed/maybe_make_link/?output_format=md#hooks)󠁿

 [apply_filters( ’embed_maybe_make_link’, string $output, string $url )](https://developer.wordpress.org/reference/hooks/embed_maybe_make_link/)

Filters the returned, maybe-linked embed URL.

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_embed/maybe_make_link/?output_format=md#related)󠁿

| Uses | Description | 
| [esc_url()](https://developer.wordpress.org/reference/functions/esc_url/)`wp-includes/formatting.php` |

Checks and cleans a URL.

  | 
| [esc_html()](https://developer.wordpress.org/reference/functions/esc_html/)`wp-includes/formatting.php` |

Escaping for HTML blocks.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

[Show 1 more](https://developer.wordpress.org/reference/classes/wp_embed/maybe_make_link/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_embed/maybe_make_link/?output_format=md#)

| Used by | Description | 
| [wp_ajax_send_link_to_editor()](https://developer.wordpress.org/reference/functions/wp_ajax_send_link_to_editor/)`wp-admin/includes/ajax-actions.php` |

Handles sending a link to the editor via AJAX.

  | 
| [WP_Embed::shortcode()](https://developer.wordpress.org/reference/classes/wp_embed/shortcode/)`wp-includes/class-wp-embed.php` |

The [do_shortcode()](https://developer.wordpress.org/reference/functions/do_shortcode/) callback function.

  |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_embed%2Fmaybe_make_link%2F)
before being able to contribute a note or feedback.