CoreFiles by mySites.guru
svg-icons.php68 lines, 1,681 bytes, from wordpress-5.3-beta2.zip
Raw History Compare with 5.3-beta1
md5
57cc34ec4b6613092106bfa38c2f82a2
sha1
8ca2a7c011b477b0cff8781d1be516f7477a9975
sha256
7c756bfa543d512be11a37806b0e4d2186e2e7633cf17211345fe7ab6c808644
<?php
/**
 * Twenty Twenty SVG Icon helper functions
 *
 * @package WordPress
 * @subpackage Twenty_Twenty
 * @since 1.0.0
 */

if ( ! function_exists( 'twentytwenty_the_theme_svg' ) ) {
	/**
	 * Output and Get Theme SVG.
	 * Output and get the SVG markup for an icon in the TwentyTwenty_SVG_Icons class.
	 *
	 * @param string $svg_name The name of the icon.
	 * @param string $color Color code.
	 */
	function twentytwenty_the_theme_svg( $svg_name, $color = '' ) {
		echo twentytwenty_get_theme_svg( $svg_name, $color ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in twentytwenty_get_theme_svg();.
	}
}

if ( ! function_exists( 'twentytwenty_get_theme_svg' ) ) {

	/**
	 * Get information about the SVG icon.
	 *
	 * @param string $svg_name The name of the icon.
	 * @param string $color Color code.
	 */
	function twentytwenty_get_theme_svg( $svg_name, $color = '' ) {

		// Make sure that only our allowed tags and attributes are included.
		$svg = wp_kses(
			TwentyTwenty_SVG_Icons::get_svg( $svg_name, $color ),
			array(
				'svg'     => array(
					'class'       => true,
					'xmlns'       => true,
					'width'       => true,
					'height'      => true,
					'viewbox'     => true,
					'aria-hidden' => true,
					'role'        => true,
					'focusable'   => true,
				),
				'path'    => array(
					'fill'      => true,
					'fill-rule' => true,
					'd'         => true,
					'transform' => true,
				),
				'polygon' => array(
					'fill'      => true,
					'fill-rule' => true,
					'points'    => true,
					'transform' => true,
					'focusable' => true,
				),
			)
		);

		if ( ! $svg ) {
			return false;
		}
		return $svg;
	}
}

The same content is in 2 releases, WordPress 5.3-beta1 to 5.3-beta2. See them all, or every version of this file.