rebase on oct-10-2023
This commit is contained in:
@@ -105,9 +105,11 @@ class WP_oEmbed {
|
||||
'#https?://www\.someecards\.com/usercards/viewcard/.+#i' => array( 'https://www.someecards.com/v2/oembed/', true ),
|
||||
'#https?://some\.ly\/.+#i' => array( 'https://www.someecards.com/v2/oembed/', true ),
|
||||
'#https?://(www\.)?tiktok\.com/.*/video/.*#i' => array( 'https://www.tiktok.com/oembed', true ),
|
||||
'#https?://(www\.)?tiktok\.com/@.*#i' => array( 'https://www.tiktok.com/oembed', true ),
|
||||
'#https?://([a-z]{2}|www)\.pinterest\.com(\.(au|mx))?/.*#i' => array( 'https://www.pinterest.com/oembed.json', true ),
|
||||
'#https?://(www\.)?wolframcloud\.com/obj/.+#i' => array( 'https://www.wolframcloud.com/oembed', true ),
|
||||
'#https?://pca\.st/.+#i' => array( 'https://pca.st/oembed.json', true ),
|
||||
'#https?://((play|www)\.)?anghami\.com/.*#i' => array( 'https://api.anghami.com/rest/v1/oembed.view', true ),
|
||||
);
|
||||
|
||||
if ( ! empty( self::$early_providers['add'] ) ) {
|
||||
@@ -187,6 +189,7 @@ class WP_oEmbed {
|
||||
* | WolframCloud | wolframcloud.com | 5.9.0 |
|
||||
* | Pocket Casts | pocketcasts.com | 6.1.0 |
|
||||
* | Crowdsignal | crowdsignal.net | 6.2.0 |
|
||||
* | Anghami | anghami.com | 6.3.0 |
|
||||
*
|
||||
* No longer supported providers:
|
||||
*
|
||||
@@ -236,6 +239,7 @@ class WP_oEmbed {
|
||||
if ( in_array( $name, $this->compat_methods, true ) ) {
|
||||
return $this->$name( ...$arguments );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -514,7 +518,7 @@ class WP_oEmbed {
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects to a oEmbed provider and returns the result.
|
||||
* Connects to an oEmbed provider and returns the result.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
@@ -550,8 +554,10 @@ class WP_oEmbed {
|
||||
if ( is_wp_error( $result ) && 'not-implemented' === $result->get_error_code() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return ( $result && ! is_wp_error( $result ) ) ? $result : false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -571,14 +577,18 @@ class WP_oEmbed {
|
||||
$args = apply_filters( 'oembed_remote_get_args', array(), $provider_url_with_args );
|
||||
|
||||
$response = wp_safe_remote_get( $provider_url_with_args, $args );
|
||||
if ( 501 == wp_remote_retrieve_response_code( $response ) ) {
|
||||
|
||||
if ( 501 === wp_remote_retrieve_response_code( $response ) ) {
|
||||
return new WP_Error( 'not-implemented' );
|
||||
}
|
||||
|
||||
$body = wp_remote_retrieve_body( $response );
|
||||
if ( ! $body ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$parse_method = "_parse_$format";
|
||||
|
||||
return $this->$parse_method( $body );
|
||||
}
|
||||
|
||||
@@ -592,6 +602,7 @@ class WP_oEmbed {
|
||||
*/
|
||||
private function _parse_json( $response_body ) {
|
||||
$data = json_decode( trim( $response_body ) );
|
||||
|
||||
return ( $data && is_object( $data ) ) ? $data : false;
|
||||
}
|
||||
|
||||
@@ -609,9 +620,10 @@ class WP_oEmbed {
|
||||
}
|
||||
|
||||
if ( PHP_VERSION_ID < 80000 ) {
|
||||
// This function has been deprecated in PHP 8.0 because in libxml 2.9.0, external entity loading
|
||||
// is disabled by default, so this function is no longer needed to protect against XXE attacks.
|
||||
// phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.libxml_disable_entity_loaderDeprecated
|
||||
/*
|
||||
* This function has been deprecated in PHP 8.0 because in libxml 2.9.0, external entity loading
|
||||
* is disabled by default, so this function is no longer needed to protect against XXE attacks.
|
||||
*/
|
||||
$loader = libxml_disable_entity_loader( true );
|
||||
}
|
||||
|
||||
@@ -743,7 +755,7 @@ class WP_oEmbed {
|
||||
* @return string Possibly modified $html
|
||||
*/
|
||||
public function _strip_newlines( $html, $data, $url ) {
|
||||
if ( false === strpos( $html, "\n" ) ) {
|
||||
if ( ! str_contains( $html, "\n" ) ) {
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user