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

---

# WP_Embed::autoembed_callback( array $matches ): string

## In this article

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

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

Callback function for [WP_Embed::autoembed()](https://developer.wordpress.org/reference/classes/wp_embed/autoembed/).

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

 `$matches`arrayrequired

A regex match array.

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

 string The embed HTML on success, otherwise the original URL.

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

    ```php
    public function autoembed_callback( $matches ) {
    	$oldval              = $this->linkifunknown;
    	$this->linkifunknown = false;
    	$return              = $this->shortcode( array(), $matches[2] );
    	$this->linkifunknown = $oldval;

    	return $matches[1] . $return . $matches[3];
    }
    ```

[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#L463)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-embed.php#L463-L470)

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

| Uses | Description | 
| [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%2Fautoembed_callback%2F)
before being able to contribute a note or feedback.