Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin: Deprecate gutenberg_get_script_polyfill #13536

Merged
merged 1 commit into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.