mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 07:40:07 +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:
@@ -61,11 +61,13 @@ function wp_embed_unregister_handler( $id, $priority = 10 ) {
|
||||
* @return array Default embed parameters.
|
||||
*/
|
||||
function wp_embed_defaults( $url = '' ) {
|
||||
if ( ! empty( $GLOBALS['content_width'] ) )
|
||||
if ( ! empty( $GLOBALS['content_width'] ) ) {
|
||||
$width = (int) $GLOBALS['content_width'];
|
||||
}
|
||||
|
||||
if ( empty( $width ) )
|
||||
if ( empty( $width ) ) {
|
||||
$width = 500;
|
||||
}
|
||||
|
||||
$height = min( ceil( $width * 1.5 ), 1000 );
|
||||
|
||||
@@ -131,8 +133,8 @@ function _wp_oembed_get_object() {
|
||||
*/
|
||||
function wp_oembed_add_provider( $format, $provider, $regex = false ) {
|
||||
if ( did_action( 'plugins_loaded' ) ) {
|
||||
$oembed = _wp_oembed_get_object();
|
||||
$oembed->providers[$format] = array( $provider, $regex );
|
||||
$oembed = _wp_oembed_get_object();
|
||||
$oembed->providers[ $format ] = array( $provider, $regex );
|
||||
} else {
|
||||
WP_oEmbed::_add_provider_early( $format, $provider, $regex );
|
||||
}
|
||||
@@ -226,7 +228,7 @@ function wp_maybe_load_embeds() {
|
||||
*/
|
||||
function wp_embed_handler_youtube( $matches, $attr, $url, $rawattr ) {
|
||||
global $wp_embed;
|
||||
$embed = $wp_embed->autoembed( sprintf( "https://youtube.com/watch?v=%s", urlencode( $matches[2] ) ) );
|
||||
$embed = $wp_embed->autoembed( sprintf( 'https://youtube.com/watch?v=%s', urlencode( $matches[2] ) ) );
|
||||
|
||||
/**
|
||||
* Filters the YoutTube embed output.
|
||||
@@ -395,10 +397,12 @@ function get_oembed_endpoint_url( $permalink = '', $format = 'json' ) {
|
||||
$url = rest_url( 'oembed/1.0/embed' );
|
||||
|
||||
if ( '' !== $permalink ) {
|
||||
$url = add_query_arg( array(
|
||||
'url' => urlencode( $permalink ),
|
||||
'format' => ( 'json' !== $format ) ? $format : false,
|
||||
), $url );
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
'url' => urlencode( $permalink ),
|
||||
'format' => ( 'json' !== $format ) ? $format : false,
|
||||
), $url
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -449,7 +453,7 @@ function get_post_embed_html( $width, $height, $post = null ) {
|
||||
* minified JavaScript. If you need to debug it, please turn on SCRIPT_DEBUG
|
||||
* and edit wp-embed.js directly.
|
||||
*/
|
||||
$output .=<<<JS
|
||||
$output .= <<<JS
|
||||
include "js/wp-embed.min.js"
|
||||
JS;
|
||||
}
|
||||
@@ -517,10 +521,12 @@ function get_oembed_response_data( $post, $width ) {
|
||||
* @type int $max Maximum width. Default 600.
|
||||
* }
|
||||
*/
|
||||
$min_max_width = apply_filters( 'oembed_min_max_width', array(
|
||||
'min' => 200,
|
||||
'max' => 600
|
||||
) );
|
||||
$min_max_width = apply_filters(
|
||||
'oembed_min_max_width', array(
|
||||
'min' => 200,
|
||||
'max' => 600,
|
||||
)
|
||||
);
|
||||
|
||||
$width = min( max( $min_max_width['min'], $width ), $min_max_width['max'] );
|
||||
$height = max( ceil( $width / 16 * 9 ), 200 );
|
||||
@@ -582,7 +588,7 @@ function get_oembed_response_data_rich( $data, $post, $width, $height ) {
|
||||
if ( 'attachment' === get_post_type( $post ) ) {
|
||||
if ( wp_attachment_is_image( $post ) ) {
|
||||
$thumbnail_id = $post->ID;
|
||||
} else if ( wp_attachment_is( 'video', $post ) ) {
|
||||
} elseif ( wp_attachment_is( 'video', $post ) ) {
|
||||
$thumbnail_id = get_post_thumbnail_id( $post );
|
||||
$data['type'] = 'video';
|
||||
}
|
||||
@@ -590,9 +596,9 @@ function get_oembed_response_data_rich( $data, $post, $width, $height ) {
|
||||
|
||||
if ( $thumbnail_id ) {
|
||||
list( $thumbnail_url, $thumbnail_width, $thumbnail_height ) = wp_get_attachment_image_src( $thumbnail_id, array( $width, 99999 ) );
|
||||
$data['thumbnail_url'] = $thumbnail_url;
|
||||
$data['thumbnail_width'] = $thumbnail_width;
|
||||
$data['thumbnail_height'] = $thumbnail_height;
|
||||
$data['thumbnail_url'] = $thumbnail_url;
|
||||
$data['thumbnail_width'] = $thumbnail_width;
|
||||
$data['thumbnail_height'] = $thumbnail_height;
|
||||
}
|
||||
|
||||
return $data;
|
||||
@@ -729,7 +735,7 @@ function wp_filter_oembed_result( $result, $data, $url ) {
|
||||
|
||||
$allowed_html = array(
|
||||
'a' => array(
|
||||
'href' => true,
|
||||
'href' => true,
|
||||
),
|
||||
'blockquote' => array(),
|
||||
'iframe' => array(
|
||||
@@ -759,14 +765,14 @@ function wp_filter_oembed_result( $result, $data, $url ) {
|
||||
$secret = wp_generate_password( 10, false );
|
||||
|
||||
$url = esc_url( "{$results[2]}#?secret=$secret" );
|
||||
$q = $results[1];
|
||||
$q = $results[1];
|
||||
|
||||
$html = str_replace( $results[0], ' src=' . $q . $url . $q . ' data-secret=' . $q . $secret . $q, $html );
|
||||
$html = str_replace( '<blockquote', "<blockquote data-secret=\"$secret\"", $html );
|
||||
}
|
||||
|
||||
$allowed_html['blockquote']['data-secret'] = true;
|
||||
$allowed_html['iframe']['data-secret'] = true;
|
||||
$allowed_html['iframe']['data-secret'] = true;
|
||||
|
||||
$html = wp_kses( $html, $allowed_html );
|
||||
|
||||
@@ -797,7 +803,8 @@ function wp_embed_excerpt_more( $more_string ) {
|
||||
return $more_string;
|
||||
}
|
||||
|
||||
$link = sprintf( '<a href="%1$s" class="wp-embed-more" target="_top">%2$s</a>',
|
||||
$link = sprintf(
|
||||
'<a href="%1$s" class="wp-embed-more" target="_top">%2$s</a>',
|
||||
esc_url( get_permalink() ),
|
||||
/* translators: %s: Name of current post */
|
||||
sprintf( __( 'Continue reading %s' ), '<span class="screen-reader-text">' . get_the_title() . '</span>' )
|
||||
@@ -873,23 +880,23 @@ function print_embed_styles() {
|
||||
?>
|
||||
<style type="text/css">
|
||||
<?php
|
||||
if ( SCRIPT_DEBUG ) {
|
||||
readfile( ABSPATH . WPINC . "/css/wp-embed-template.css" );
|
||||
} else {
|
||||
/*
|
||||
* If you're looking at a src version of this file, you'll see an "include"
|
||||
* statement below. This is used by the `grunt build` process to directly
|
||||
* include a minified version of wp-oembed-embed.css, instead of using the
|
||||
* readfile() method from above.
|
||||
*
|
||||
* If you're looking at a build version of this file, you'll see a string of
|
||||
* minified CSS. If you need to debug it, please turn on SCRIPT_DEBUG
|
||||
* and edit wp-embed-template.css directly.
|
||||
*/
|
||||
?>
|
||||
include "css/wp-embed-template.min.css"
|
||||
<?php
|
||||
}
|
||||
if ( SCRIPT_DEBUG ) {
|
||||
readfile( ABSPATH . WPINC . '/css/wp-embed-template.css' );
|
||||
} else {
|
||||
/*
|
||||
* If you're looking at a src version of this file, you'll see an "include"
|
||||
* statement below. This is used by the `grunt build` process to directly
|
||||
* include a minified version of wp-oembed-embed.css, instead of using the
|
||||
* readfile() method from above.
|
||||
*
|
||||
* If you're looking at a build version of this file, you'll see a string of
|
||||
* minified CSS. If you need to debug it, please turn on SCRIPT_DEBUG
|
||||
* and edit wp-embed-template.css directly.
|
||||
*/
|
||||
?>
|
||||
include "css/wp-embed-template.min.css"
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</style>
|
||||
<?php
|
||||
@@ -904,23 +911,23 @@ function print_embed_scripts() {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
<?php
|
||||
if ( SCRIPT_DEBUG ) {
|
||||
readfile( ABSPATH . WPINC . "/js/wp-embed-template.js" );
|
||||
} else {
|
||||
/*
|
||||
* If you're looking at a src version of this file, you'll see an "include"
|
||||
* statement below. This is used by the `grunt build` process to directly
|
||||
* include a minified version of wp-embed-template.js, instead of using the
|
||||
* readfile() method from above.
|
||||
*
|
||||
* If you're looking at a build version of this file, you'll see a string of
|
||||
* minified JavaScript. If you need to debug it, please turn on SCRIPT_DEBUG
|
||||
* and edit wp-embed-template.js directly.
|
||||
*/
|
||||
?>
|
||||
include "js/wp-embed-template.min.js"
|
||||
<?php
|
||||
}
|
||||
if ( SCRIPT_DEBUG ) {
|
||||
readfile( ABSPATH . WPINC . '/js/wp-embed-template.js' );
|
||||
} else {
|
||||
/*
|
||||
* If you're looking at a src version of this file, you'll see an "include"
|
||||
* statement below. This is used by the `grunt build` process to directly
|
||||
* include a minified version of wp-embed-template.js, instead of using the
|
||||
* readfile() method from above.
|
||||
*
|
||||
* If you're looking at a build version of this file, you'll see a string of
|
||||
* minified JavaScript. If you need to debug it, please turn on SCRIPT_DEBUG
|
||||
* and edit wp-embed-template.js directly.
|
||||
*/
|
||||
?>
|
||||
include "js/wp-embed-template.min.js"
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</script>
|
||||
<?php
|
||||
@@ -1074,12 +1081,17 @@ function wp_filter_pre_oembed_result( $result, $url, $args ) {
|
||||
$switched_blog = false;
|
||||
|
||||
if ( is_multisite() ) {
|
||||
$url_parts = wp_parse_args( wp_parse_url( $url ), array(
|
||||
'host' => '',
|
||||
'path' => '/',
|
||||
) );
|
||||
$url_parts = wp_parse_args(
|
||||
wp_parse_url( $url ), array(
|
||||
'host' => '',
|
||||
'path' => '/',
|
||||
)
|
||||
);
|
||||
|
||||
$qv = array( 'domain' => $url_parts['host'], 'path' => '/' );
|
||||
$qv = array(
|
||||
'domain' => $url_parts['host'],
|
||||
'path' => '/',
|
||||
);
|
||||
|
||||
// In case of subdirectory configs, set the path.
|
||||
if ( ! is_subdomain_install() ) {
|
||||
|
||||
Reference in New Issue
Block a user