WP_Embed::maybe_run_ajax_cache()publicWP 1.0

If a post/page was saved, then output JavaScript to make an Ajax request that will call WP_Embed::cache_oembed().

Method of the class: WP_Embed{}

No Hooks.

Return

null. Nothing (null).

Usage

global $wp_embed;
$wp_embed->maybe_run_ajax_cache();

WP_Embed::maybe_run_ajax_cache() code WP 6.5.2

<?php
public function maybe_run_ajax_cache() {
	$post = get_post();

	if ( ! $post || empty( $_GET['message'] ) ) {
		return;
	}
	?>
<script type="text/javascript">
jQuery( function($) {
	$.get("<?php echo esc_url( admin_url( 'admin-ajax.php', 'relative' ) ) . '?action=oembed-cache&post=' . $post->ID; ?>");
} );
</script>
	<?php
}