Skip to content

Commit

Permalink
General: remove backwards-compatibility WP 6.0 code
Browse files Browse the repository at this point in the history
See #27795
  • Loading branch information
jeherve committed Apr 17, 2023
1 parent c12a8e2 commit 9a2d501
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 42 deletions.
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/changelog/update-backwards-compat-61
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: compat

General: remove WordPress 6.0 backwards-compatibility code, now that Jetpack requires WordPress 6.1
9 changes: 0 additions & 9 deletions projects/plugins/jetpack/modules/shortcodes/others.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,5 @@ function jetpack_oembed_timeout_override( $timeout, $url ) {
// TODO: Remove this. This should hopefully be a temporary hack since Apple's oEmbed often seems to take more than 5 seconds to respond. 10 is an arbitrary number of seconds that seems to work better.
add_filter( 'http_request_timeout', 'jetpack_oembed_timeout_override', 10, 2 );

/**
* Conditionally add PocketCasts as an oEmbed provider in advanced of its inclusion in WP 6.1.
*
* @todo Remove when WordPress 6.1 is the minimum supported version.
*/
global $wp_version;
if ( version_compare( $wp_version, '6.1-alpha-53744', '<' ) ) {
wp_oembed_add_provider( '#https?://pca\.st/.+#i', 'https://pca.st/oembed.json', true );
}
// WordPress core only registers pca.st, not pcast.pocketcasts.net.
wp_oembed_add_provider( '#https?://pcast\.pocketcasts\.net/.+#i', 'https://pcast.pocketcasts.net/oembed.json', true );
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
<?php
/**
* Tests PocketCasts oEmbed.
*
* @todo Remove when WordPress 6.1 is the minimum version.
*/

require_once __DIR__ . '/trait.http-request-cache.php';

class WP_Test_Jetpack_Shortcodes_PocketCasts extends WP_UnitTestCase {
use Automattic\Jetpack\Tests\HttpRequestCacheTrait;

const POCKETCASTS_TEST_URL = 'https://pca.st/6934i7iw';
const POCKETCASTS_BETA_TEST_URL = 'https://pcast.pocketcasts.net/drtlaf9s';

/**
Expand Down Expand Up @@ -48,40 +45,16 @@ public function pre_http_request( $response, $args, $url ) {
$api_query_args = null;
wp_parse_str( $api_query, $api_query_args );

// phpcs:disable WordPress.WP.EnqueuedResources.NonEnqueuedScript
switch ( $api_query_args['url'] ) {
case self::POCKETCASTS_TEST_URL:
$response['body'] = '{"type":"rich","version":"1.0","provider_name":"Pocket Casts","provider_url":"https://pocketcasts.com/","title":"Episode 29: Dylan Field, Figma Co-founder, Talks Design, Digital Economy, and Remote Culture with Host Connie Yang - Distributed, with Matt Mullenweg","author_name":"Distributed, with Matt Mullenweg","author_url":"https://distributed.blog","html":"\u003cdiv style=\"width: 100%; max-width: 1200px; max-height: 100%; position: relative;\"\u003e\n \u003cdiv style=\"padding-bottom: 42.857142857142854%;\"\u003e\u003c/div\u003e\n \u003ciframe src=\"https://pca.st/embed/6934i7iw\" width=\"1200\" height=\"514.2857142857142\" style=\"border: 0; border-radius: 8px; position: absolute; top: 0; left: 0; width: 100%; height: 100%;\"\u003e\u003c/iframe\u003e\n\u003c/div\u003e","width":1200,"height":514.2857142857142}';
break;

case self::POCKETCASTS_BETA_TEST_URL:
$response['body'] = '{"type":"rich","version":"1.0","provider_name":"Pocket Casts","provider_url":"https://pocketcasts.com/","title":"Tom - Dead Eyes","author_name":"Dead Eyes","author_url":"https://art19.com/shows/dead-eyes","html":"\u003cdiv style=\"width: 100%; max-width: 1200px; max-height: 100%; position: relative;\"\u003e\n \u003cdiv style=\"padding-bottom: 42.857142857142854%;\"\u003e\u003c/div\u003e\n \u003ciframe src=\"https://pcast.pocketcasts.net/embed/drtlaf9s\" width=\"1200\" height=\"514.2857142857142\" style=\"border: 0; border-radius: 8px; position: absolute; top: 0; left: 0; width: 100%; height: 100%;\" allowfullscreen=\"true\" frameborder=\"0\" sandbox=\"allow-scripts allow-same-origin allow-presentation\"\u003e\u003c/iframe\u003e\n\u003c/div\u003e\n","width":1200,"height":514.2857142857142}';
break;
default:
if (
! isset( $api_query_args['url'] )
|| self::POCKETCASTS_BETA_TEST_URL !== $api_query_args['url']
) {
return new WP_Error( 'unexpected-http-request', 'Test is making an unexpected HTTP request.' );
}
// phpcs:enable

return $response;
}

/**
* Test Pocket Casts oEmbed endpoint.
*/
public function test_pocketcasts_oembed_fetch_url() {

$wp_embed = new WP_Embed();
$actual = $wp_embed->autoembed( self::POCKETCASTS_TEST_URL );

/*
$actual contains this:
<div style="width: 100%; max-width: 1200px; max-height: 100%; position: relative;"> <div style="padding-bottom: 42.857142857142854%;"></div> <iframe title="Episode 29: Dylan Field, Figma Co-founder, Talks Design, Digital Economy, and Remote Culture with Host Connie Yang - Distributed, with Matt Mullenweg" src="https://pca.st/embed/6934i7iw" width="1200" height="514.2857142857142" style="border: 0; border-radius: 8px; position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></iframe></div>
*/
$response['body'] = '{"type":"rich","version":"1.0","provider_name":"Pocket Casts","provider_url":"https://pocketcasts.com/","title":"Tom - Dead Eyes","author_name":"Dead Eyes","author_url":"https://art19.com/shows/dead-eyes","html":"\u003cdiv style=\"width: 100%; max-width: 1200px; max-height: 100%; position: relative;\"\u003e\n \u003cdiv style=\"padding-bottom: 42.857142857142854%;\"\u003e\u003c/div\u003e\n \u003ciframe src=\"https://pcast.pocketcasts.net/embed/drtlaf9s\" width=\"1200\" height=\"514.2857142857142\" style=\"border: 0; border-radius: 8px; position: absolute; top: 0; left: 0; width: 100%; height: 100%;\" allowfullscreen=\"true\" frameborder=\"0\" sandbox=\"allow-scripts allow-same-origin allow-presentation\"\u003e\u003c/iframe\u003e\n\u003c/div\u003e\n","width":1200,"height":514.2857142857142}';

$this->assertStringContainsString(
'src="https://pca.st/embed/6934i7iw"',
$actual
);
return $response;
}

/**
Expand Down

0 comments on commit 9a2d501

Please sign in to comment.