wp/wp-includes/class-wp-embed.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
    45 		add_action( 'edit_form_advanced', array( $this, 'maybe_run_ajax_cache' ) );
    45 		add_action( 'edit_form_advanced', array( $this, 'maybe_run_ajax_cache' ) );
    46 		add_action( 'edit_page_form', array( $this, 'maybe_run_ajax_cache' ) );
    46 		add_action( 'edit_page_form', array( $this, 'maybe_run_ajax_cache' ) );
    47 	}
    47 	}
    48 
    48 
    49 	/**
    49 	/**
    50 	 * Process the [embed] shortcode.
    50 	 * Processes the [embed] shortcode.
    51 	 *
    51 	 *
    52 	 * Since the [embed] shortcode needs to be run earlier than other shortcodes,
    52 	 * Since the [embed] shortcode needs to be run earlier than other shortcodes,
    53 	 * this function removes all existing shortcodes, registers the [embed] shortcode,
    53 	 * this function removes all existing shortcodes, registers the [embed] shortcode,
    54 	 * calls do_shortcode(), and then re-registers the old shortcodes.
    54 	 * calls do_shortcode(), and then re-registers the old shortcodes.
    55 	 *
    55 	 *
    56 	 * @global array $shortcode_tags
    56 	 * @global array $shortcode_tags
    57 	 *
    57 	 *
    58 	 * @param string $content Content to parse
    58 	 * @param string $content Content to parse.
    59 	 * @return string Content with shortcode parsed
    59 	 * @return string Content with shortcode parsed.
    60 	 */
    60 	 */
    61 	public function run_shortcode( $content ) {
    61 	public function run_shortcode( $content ) {
    62 		global $shortcode_tags;
    62 		global $shortcode_tags;
    63 
    63 
    64 		// Back up current registered shortcodes and clear them all out.
    64 		// Back up current registered shortcodes and clear them all out.
    86 		if ( ! $post || empty( $_GET['message'] ) ) {
    86 		if ( ! $post || empty( $_GET['message'] ) ) {
    87 			return;
    87 			return;
    88 		}
    88 		}
    89 		?>
    89 		?>
    90 <script type="text/javascript">
    90 <script type="text/javascript">
    91 	jQuery(document).ready(function($){
    91 	jQuery( function($) {
    92 		$.get("<?php echo esc_url( admin_url( 'admin-ajax.php', 'relative' ) ) . '?action=oembed-cache&post=' . $post->ID; ?>");
    92 		$.get("<?php echo esc_url( admin_url( 'admin-ajax.php', 'relative' ) ) . '?action=oembed-cache&post=' . $post->ID; ?>");
    93 	});
    93 	} );
    94 </script>
    94 </script>
    95 		<?php
    95 		<?php
    96 	}
    96 	}
    97 
    97 
    98 	/**
    98 	/**
   374 		// Still unknown.
   374 		// Still unknown.
   375 		return $this->maybe_make_link( $url );
   375 		return $this->maybe_make_link( $url );
   376 	}
   376 	}
   377 
   377 
   378 	/**
   378 	/**
   379 	 * Delete all oEmbed caches. Unused by core as of 4.0.0.
   379 	 * Deletes all oEmbed caches. Unused by core as of 4.0.0.
   380 	 *
   380 	 *
   381 	 * @param int $post_ID Post ID to delete the caches for.
   381 	 * @param int $post_ID Post ID to delete the caches for.
   382 	 */
   382 	 */
   383 	public function delete_oembed_caches( $post_ID ) {
   383 	public function delete_oembed_caches( $post_ID ) {
   384 		$post_metas = get_post_custom_keys( $post_ID );
   384 		$post_metas = get_post_custom_keys( $post_ID );
   452 	}
   452 	}
   453 
   453 
   454 	/**
   454 	/**
   455 	 * Callback function for WP_Embed::autoembed().
   455 	 * Callback function for WP_Embed::autoembed().
   456 	 *
   456 	 *
   457 	 * @param array $match A regex match array.
   457 	 * @param array $matches A regex match array.
   458 	 * @return string The embed HTML on success, otherwise the original URL.
   458 	 * @return string The embed HTML on success, otherwise the original URL.
   459 	 */
   459 	 */
   460 	public function autoembed_callback( $match ) {
   460 	public function autoembed_callback( $matches ) {
   461 		$oldval              = $this->linkifunknown;
   461 		$oldval              = $this->linkifunknown;
   462 		$this->linkifunknown = false;
   462 		$this->linkifunknown = false;
   463 		$return              = $this->shortcode( array(), $match[2] );
   463 		$return              = $this->shortcode( array(), $matches[2] );
   464 		$this->linkifunknown = $oldval;
   464 		$this->linkifunknown = $oldval;
   465 
   465 
   466 		return $match[1] . $return . $match[3];
   466 		return $matches[1] . $return . $matches[3];
   467 	}
   467 	}
   468 
   468 
   469 	/**
   469 	/**
   470 	 * Conditionally makes a hyperlink based on an internal class variable.
   470 	 * Conditionally makes a hyperlink based on an internal class variable.
   471 	 *
   471 	 *
   489 		 */
   489 		 */
   490 		return apply_filters( 'embed_maybe_make_link', $output, $url );
   490 		return apply_filters( 'embed_maybe_make_link', $output, $url );
   491 	}
   491 	}
   492 
   492 
   493 	/**
   493 	/**
   494 	 * Find the oEmbed cache post ID for a given cache key.
   494 	 * Finds the oEmbed cache post ID for a given cache key.
   495 	 *
   495 	 *
   496 	 * @since 4.9.0
   496 	 * @since 4.9.0
   497 	 *
   497 	 *
   498 	 * @param string $cache_key oEmbed cache key.
   498 	 * @param string $cache_key oEmbed cache key.
   499 	 * @return int|null Post ID on success, null on failure.
   499 	 * @return int|null Post ID on success, null on failure.