wp_get_script_polyfill( WP_Scripts $scripts, string[] $tests ): string  Returns contents of an inline script used in appending polyfill scripts for browsers which fail the provided tests. The provided array is a mapping from a condition to verify feature support to its polyfill script handle.   Parameters   $scripts WP_Scripts Required    WP_Scripts object.    $tests string[] Required    Features to detect.      Return string Conditional polyfill inline script.   Source  File: wp-includes/script-loader.php. View all references  function wp_get_script_polyfill( $scripts, $tests ) {
	$polyfill = '';
	foreach ( $tests as $test => $handle ) {
		if ( ! array_key_exists( $handle, $scripts->registered ) ) {
			continue;
		}

		$src = $scripts->registered[ $handle ]->src;
		$ver = $scripts->registered[ $handle ]->ver;

		if ( ! preg_match( '|^(https?:)?//|', $src ) && ! ( $scripts->content_url && 0 === strpos( $src, $scripts->content_url ) ) ) {
			$src = $scripts->base_url . $src;
		}

		if ( ! empty( $ver ) ) {
			$src = add_query_arg( 'ver', $ver, $src );
		}

		/** This filter is documented in wp-includes/class-wp-scripts.php */
		$src = esc_url( apply_filters( 'script_loader_src', $src, $handle ) );

		if ( ! $src ) {
			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="' .
			$src .
			'"></scr\' + \'ipt>\' );'
		);
	}

	return $polyfill;
}
   Hooks     apply_filters( 'script_loader_src', string $src, string $handle )   
Filters the script loader source.      Related  Uses    Uses Description      esc_url() wp-includes/formatting.php   Checks and cleans a URL.     add_query_arg() wp-includes/functions.php   Retrieves a modified URL query string.     apply_filters() wp-includes/plugin.php   Calls the callback functions that have been added to a filter hook.   
    Changelog    Version Description     5.0.0 Introduced.    

    
{'path': 'public/docs/wordpress/functions/wp_get_script_polyfill.html', 'source': 'DevDocs.IO'}