Skip to content

Commit

Permalink
Plugin: Deprecate gutenberg_get_script_polyfill (#13536)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Jan 29, 2019
1 parent a6f7f9d commit 797df63
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ The Gutenberg project's deprecation policy is intended to support backward compa
- The PHP function `gutenberg_toggle_custom_fields` has been removed.
- The PHP function `gutenberg_collect_meta_box_data` has been removed. Use [`register_and_do_post_meta_boxes`](https://developer.wordpress.org/reference/functions/register_and_do_post_meta_boxes/) instead.
- `window._wpLoadGutenbergEditor` has been removed. Use `window._wpLoadBlockEditor` instead. Note: This is a private API, not intended for public use. It may be removed in the future.
- The PHP function `gutenberg_get_script_polyfill` has been removed. Use [`wp_get_script_polyfill`](https://developer.wordpress.org/reference/functions/wp_get_script_polyfill/) instead.

## 4.5.0
- `Dropdown.refresh()` has been deprecated as the contained `Popover` is now automatically refreshed.
Expand Down
28 changes: 7 additions & 21 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,10 @@ function gutenberg_url( $path ) {
* @return string Conditional polyfill inline script.
*/
function gutenberg_get_script_polyfill( $tests ) {
global $wp_scripts;

$polyfill = '';
foreach ( $tests as $test => $handle ) {
if ( ! array_key_exists( $handle, $wp_scripts->registered ) ) {
continue;
}

$polyfill .= (
// Test presence of feature...
'( ' . $test . ' ) || ' .
// ...appending polyfill on any failures. Cautious viewers may balk
// at the `document.write`. Its caveat of synchronous mid-stream
// blocking write is exactly the behavior we need though.
'document.write( \'<script src="' .
esc_url( $wp_scripts->registered[ $handle ]->src ) .
'"></scr\' + \'ipt>\' );'
);
}
_deprecated_function( __FUNCTION__, '5.0.0', 'wp_get_script_polyfill' );

return $polyfill;
global $wp_scripts;
return wp_get_script_polyfill( $wp_scripts, $tests );
}

if ( ! function_exists( 'register_tinymce_scripts' ) ) {
Expand Down Expand Up @@ -153,11 +136,14 @@ function gutenberg_register_packages_scripts() {
* @since 0.1.0
*/
function gutenberg_register_scripts_and_styles() {
global $wp_scripts;

gutenberg_register_vendor_scripts();

wp_add_inline_script(
'wp-polyfill',
gutenberg_get_script_polyfill(
wp_get_script_polyfill(
$wp_scripts,
array(
'\'fetch\' in window' => 'wp-polyfill-fetch',
'document.contains' => 'wp-polyfill-node-contains',
Expand Down
54 changes: 0 additions & 54 deletions phpunit/class-polyfill-test.php

This file was deleted.

0 comments on commit 797df63

Please sign in to comment.