Embeds: Modernize wp-embed script with removal of obsolete IE10/IE11 code and support for WP<4.4.

* Remove obsolete `load` event handler in `wp-embed` since IE10+ support `DOMContentLoaded`.
* Replace obsolete use of `document.createElement('a')` in favor of the newer `URL` class (supported in all browsers but obsolete IE11).
* Remove obsolete IE10/IE11 code.
* Combine conditionals.
* Use `substring()` instead of deprecated `substr()` method.
* Eliminate the stipulation that `wp-embed.js` not include ampersands, considering this was put in place for WP<4.3 which now accounts for only 1.43% of sites. This includes the elimination of the `verify:wp-embed` grunt task.

Props westonruter, swissspidy.
Fixes #58974.


git-svn-id: https://develop.svn.wordpress.org/trunk@56383 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Weston Ruter
2023-08-10 19:47:08 +00:00
parent bb6de6b8c0
commit 415c9f6bb4
3 changed files with 30 additions and 116 deletions

View File

@@ -343,15 +343,4 @@ class Tests_Embed_Template extends WP_UnitTestCase {
wp_maybe_enqueue_oembed_host_js( $post_embed );
$this->assertFalse( $scripts->query( 'wp-embed', 'enqueued' ) );
}
/**
* Confirms that no ampersands exist in src/wp-includes/js/wp-embed.js.
*
* See also the `verify:wp-embed` Grunt task for verifying the built file.
*
* @ticket 34698
*/
public function test_js_no_ampersands() {
$this->assertStringNotContainsString( '&', file_get_contents( ABSPATH . WPINC . '/js/wp-embed.js' ) );
}
}