File "embed.php"
Full Path: /home/ycoalition/public_html/blog/wp-includes/blocks/latest-comments/embed.php
File size: 4 KB
MIME-type: text/x-php
Charset: utf-8
<?php
/**
* oEmbed API: Top-level oEmbed functionality
*
* @package WordPress
* @subpackage oEmbed
* @since 4.4.0
*/
/**
* Registers an embed handler.
*
* Should probably only be used for sites that do not support oEmbed.
*
* @since 2.9.0
*
* @global WP_Embed $wp_embed WordPress Embed object.
*
* @param string $id An internal ID/name for the handler. Needs to be unique.
* @param string $regex The regex that will be used to see if this handler should be used for a URL.
* @param callable $callback The callback function that will be called if the regex is matched.
* @param int $priority Optional. Used to specify the order in which the registered handlers will
* be tested. Default 10.
*/
function wp_embed_register_handler( $id, $regex, $callback, $priority = 10 ) {
global $wp_embed;
$wp_embed->register_handler( $id, $regex, $callback, $priority );
}
/**
* Unregisters a previously-registered embed handler.
*
* @since 2.9.0
*
* @global WP_Embed $wp_embed WordPress Embed object.
*
* @param string $id The handler ID that should be removed.
* @param int $priority Optional. The priority of the handler to be removed. Default 10.
*/
function wp_embed_unregister_handler( $id, $priority = 10 ) {
global $wp_embed;
$wp_embed->unregister_handler( $id, $priority );
}
/**
* Creates default array of embed parameters.
*
* The width defaults to the content width as specified by the theme. If the
* theme does not specify a content width, then 500px is used.
*
* The default height is 1.5 times the width, or 1000px, whichever is smaller.
*
* The {@see 'embed_defaults'} filter can be used to adjust either of these values.
*
* @since 2.9.0
*
* @global int $content_width
*
* @param string $url Optional. The URL that should be embedded. Default empty.
* @return int[] {
* Indexed array of the embed width and height in pixels.
*
* @type int $0 The embed width.
* @type int $1 The embed height.
* }
*/
function wp_embed_defaults( $url = '' ) {
if ( ! empty( $GLOBALS['content_width'] ) ) {
$width = (int) $GLOBALS['content_width'];
}
if ( empty( $width ) ) {
$width = 500;
}
$height = min( (int) ceil( $width * 1.5 ), 1000 );
/**
* Filters the default array of embed dimensions.
*
* @since 2.9.0
*
* @param int[] $size {
* Indexed array of the embed width and height in pixels.
*
* @type int $0 The embed width.
* @type int $1 The embed height.
* }
* @param string $url The URL that should be embedded.
*/
return apply_filters( 'embed_defaults', compact( 'width', 'height' ), $url );
}
/**
* Attempts to fetch the embed HTML for a provided URL using oEmbed.
*
* @since 2.9.0
*
* @see WP_oEmbed
*
* @param string $url The URL that should be embedded.
* @param array|string $args {
* Optional. Additional arguments for retrieving embed HTML. Default empty.
*
* @type int|string $width Optional. The `maxwidth` value passed to the provider URL.
* @type int|string $height Optional. The `maxheight` value passed to the provider URL.
* @type bool $discover Optional. Determines whether to attempt to discover link tags
* at the given URL for an oEmbed provider when the provider URL
* is not found in the built-in providers list. Default true.
* }
* @return string|false The embed HTML on success, false on failure.
*/
function wp_oembed_get( $url, $args = '' ) {
$oembed = _wp_oembed_get_object();
return $oembed->get_html( $url, $args );
}
/**
* Returns the initialized WP_oEmbed object.
*
* @since 2.9.0
* @access private
*
* @return WP_oEmbed object.
*/
function _wp_oembed_get_object() {
static $wp_oembed = null;
if ( is_null( $wp_oembed ) ) {
$wp_oembed = new WP_oEmbed();
}
return $wp_oembed;
}
/**
* Adds a URL format and oEmbed provider URL pair.
*
* @since 2.9.0
*
* @see WP_oEmbed
*
* @param string $format The format of URL that this provider can handle. You can use asterisks