_print_emoji_detection_script()WP 4.6.0

Prints inline Emoji detection script.

Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.

Returns

null. Nothing (null).

Usage

_print_emoji_detection_script();

Changelog

Since 4.6.0 Introduced.

_print_emoji_detection_script() code WP 7.0

function _print_emoji_detection_script() {
	$settings = array(
		/**
		 * Filters the URL where emoji png images are hosted.
		 *
		 * @since 4.2.0
		 *
		 * @param string $url The emoji base URL for png images.
		 */
		'baseUrl' => apply_filters( 'emoji_url', 'https://s.w.org/images/core/emoji/17.0.2/72x72/' ),

		/**
		 * Filters the extension of the emoji png files.
		 *
		 * @since 4.2.0
		 *
		 * @param string $extension The emoji extension for png files. Default .png.
		 */
		'ext'     => apply_filters( 'emoji_ext', '.png' ),

		/**
		 * Filters the URL where emoji SVG images are hosted.
		 *
		 * @since 4.6.0
		 *
		 * @param string $url The emoji base URL for svg images.
		 */
		'svgUrl'  => apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/17.0.2/svg/' ),

		/**
		 * Filters the extension of the emoji SVG files.
		 *
		 * @since 4.6.0
		 *
		 * @param string $extension The emoji extension for svg files. Default .svg.
		 */
		'svgExt'  => apply_filters( 'emoji_svg_ext', '.svg' ),
	);

	$version = 'ver=' . get_bloginfo( 'version' );

	if ( SCRIPT_DEBUG ) {
		$settings['source'] = array(
			/** This filter is documented in wp-includes/class-wp-scripts.php */
			'wpemoji' => apply_filters( 'script_loader_src', includes_url( "js/wp-emoji.js?$version" ), 'wpemoji' ),
			/** This filter is documented in wp-includes/class-wp-scripts.php */
			'twemoji' => apply_filters( 'script_loader_src', includes_url( "js/twemoji.js?$version" ), 'twemoji' ),
		);
	} else {
		$settings['source'] = array(
			/** This filter is documented in wp-includes/class-wp-scripts.php */
			'concatemoji' => apply_filters( 'script_loader_src', includes_url( "js/wp-emoji-release.min.js?$version" ), 'concatemoji' ),
		);
	}

	wp_print_inline_script_tag(
		wp_json_encode( $settings, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ),
		array(
			'id'   => 'wp-emoji-settings',
			'type' => 'application/json',
		)
	);

	$emoji_loader_script_path = '/js/wp-emoji-loader' . wp_scripts_get_suffix() . '.js';
	wp_print_inline_script_tag(
		rtrim( file_get_contents( ABSPATH . WPINC . $emoji_loader_script_path ) ) . "\n" .
		'//# sourceURL=' . esc_url_raw( includes_url( $emoji_loader_script_path ) ),
		array(
			'type' => 'module',
		)
	);
}