mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Code is Poetry.
WordPress' code just... wasn't. This is now dealt with. Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS. Fixes #41057. git-svn-id: https://develop.svn.wordpress.org/trunk@42343 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -31,67 +31,71 @@ final class WP_oEmbed_Controller {
|
||||
*/
|
||||
$maxwidth = apply_filters( 'oembed_default_width', 600 );
|
||||
|
||||
register_rest_route( 'oembed/1.0', '/embed', array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_item' ),
|
||||
'args' => array(
|
||||
'url' => array(
|
||||
'required' => true,
|
||||
'sanitize_callback' => 'esc_url_raw',
|
||||
),
|
||||
'format' => array(
|
||||
'default' => 'json',
|
||||
'sanitize_callback' => 'wp_oembed_ensure_format',
|
||||
),
|
||||
'maxwidth' => array(
|
||||
'default' => $maxwidth,
|
||||
'sanitize_callback' => 'absint',
|
||||
),
|
||||
),
|
||||
),
|
||||
) );
|
||||
|
||||
register_rest_route( 'oembed/1.0', '/proxy', array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_proxy_item' ),
|
||||
'permission_callback' => array( $this, 'get_proxy_item_permissions_check' ),
|
||||
'args' => array(
|
||||
'url' => array(
|
||||
'description' => __( 'The URL of the resource for which to fetch oEmbed data.' ),
|
||||
'type' => 'string',
|
||||
'required' => true,
|
||||
'sanitize_callback' => 'esc_url_raw',
|
||||
),
|
||||
'format' => array(
|
||||
'description' => __( 'The oEmbed format to use.' ),
|
||||
'type' => 'string',
|
||||
'default' => 'json',
|
||||
'enum' => array(
|
||||
'json',
|
||||
'xml',
|
||||
register_rest_route(
|
||||
'oembed/1.0', '/embed', array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_item' ),
|
||||
'args' => array(
|
||||
'url' => array(
|
||||
'required' => true,
|
||||
'sanitize_callback' => 'esc_url_raw',
|
||||
),
|
||||
'format' => array(
|
||||
'default' => 'json',
|
||||
'sanitize_callback' => 'wp_oembed_ensure_format',
|
||||
),
|
||||
'maxwidth' => array(
|
||||
'default' => $maxwidth,
|
||||
'sanitize_callback' => 'absint',
|
||||
),
|
||||
),
|
||||
'maxwidth' => array(
|
||||
'description' => __( 'The maximum width of the embed frame in pixels.' ),
|
||||
'type' => 'integer',
|
||||
'default' => $maxwidth,
|
||||
'sanitize_callback' => 'absint',
|
||||
),
|
||||
'maxheight' => array(
|
||||
'description' => __( 'The maximum height of the embed frame in pixels.' ),
|
||||
'type' => 'integer',
|
||||
'sanitize_callback' => 'absint',
|
||||
),
|
||||
'discover' => array(
|
||||
'description' => __( 'Whether to perform an oEmbed discovery request for non-whitelisted providers.' ),
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
'oembed/1.0', '/proxy', array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_proxy_item' ),
|
||||
'permission_callback' => array( $this, 'get_proxy_item_permissions_check' ),
|
||||
'args' => array(
|
||||
'url' => array(
|
||||
'description' => __( 'The URL of the resource for which to fetch oEmbed data.' ),
|
||||
'type' => 'string',
|
||||
'required' => true,
|
||||
'sanitize_callback' => 'esc_url_raw',
|
||||
),
|
||||
'format' => array(
|
||||
'description' => __( 'The oEmbed format to use.' ),
|
||||
'type' => 'string',
|
||||
'default' => 'json',
|
||||
'enum' => array(
|
||||
'json',
|
||||
'xml',
|
||||
),
|
||||
),
|
||||
'maxwidth' => array(
|
||||
'description' => __( 'The maximum width of the embed frame in pixels.' ),
|
||||
'type' => 'integer',
|
||||
'default' => $maxwidth,
|
||||
'sanitize_callback' => 'absint',
|
||||
),
|
||||
'maxheight' => array(
|
||||
'description' => __( 'The maximum height of the embed frame in pixels.' ),
|
||||
'type' => 'integer',
|
||||
'sanitize_callback' => 'absint',
|
||||
),
|
||||
'discover' => array(
|
||||
'description' => __( 'Whether to perform an oEmbed discovery request for non-whitelisted providers.' ),
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
) );
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,7 +161,7 @@ final class WP_oEmbed_Controller {
|
||||
// Serve oEmbed data from cache if set.
|
||||
unset( $args['_wpnonce'] );
|
||||
$cache_key = 'oembed_' . md5( serialize( $args ) );
|
||||
$data = get_transient( $cache_key );
|
||||
$data = get_transient( $cache_key );
|
||||
if ( ! empty( $data ) ) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user