WP_Embed::maybe_run_ajax_cache() WordPress Method

The WP_Embed::maybe_run_ajax_cache() method is used to check if a cached version of the embed code exists for a given URL. If a cached version exists, it is returned. If not, the method attempts to fetch the embed code from the remote site.

WP_Embed::maybe_run_ajax_cache() #

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


Source

File: wp-includes/class-wp-embed.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
	}

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.