[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-content/themes/twentytwenty/inc/ -> svg-icons.php (source)

   1  <?php
   2  /**
   3   * Twenty Twenty SVG Icon helper functions
   4   *
   5   * @package WordPress
   6   * @subpackage Twenty_Twenty
   7   * @since Twenty Twenty 1.0
   8   */
   9  
  10  if ( ! function_exists( 'twentytwenty_the_theme_svg' ) ) {
  11      /**
  12       * Output and Get Theme SVG.
  13       * Output and get the SVG markup for an icon in the TwentyTwenty_SVG_Icons class.
  14       *
  15       * @since Twenty Twenty 1.0
  16       *
  17       * @param string $svg_name The name of the icon.
  18       * @param string $group    The group the icon belongs to.
  19       * @param string $color    Color code.
  20       */
  21  	function twentytwenty_the_theme_svg( $svg_name, $group = 'ui', $color = '' ) {
  22          echo twentytwenty_get_theme_svg( $svg_name, $group, $color ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in twentytwenty_get_theme_svg().
  23      }
  24  }
  25  
  26  if ( ! function_exists( 'twentytwenty_get_theme_svg' ) ) {
  27  
  28      /**
  29       * Get information about the SVG icon.
  30       *
  31       * @since Twenty Twenty 1.0
  32       *
  33       * @param string $svg_name The name of the icon.
  34       * @param string $group    The group the icon belongs to.
  35       * @param string $color    Color code.
  36       */
  37  	function twentytwenty_get_theme_svg( $svg_name, $group = 'ui', $color = '' ) {
  38  
  39          // Make sure that only our allowed tags and attributes are included.
  40          $svg = wp_kses(
  41              TwentyTwenty_SVG_Icons::get_svg( $svg_name, $group, $color ),
  42              array(
  43                  'svg'     => array(
  44                      'class'       => true,
  45                      'xmlns'       => true,
  46                      'width'       => true,
  47                      'height'      => true,
  48                      'viewbox'     => true,
  49                      'aria-hidden' => true,
  50                      'role'        => true,
  51                      'focusable'   => true,
  52                  ),
  53                  'path'    => array(
  54                      'fill'      => true,
  55                      'fill-rule' => true,
  56                      'd'         => true,
  57                      'transform' => true,
  58                  ),
  59                  'polygon' => array(
  60                      'fill'      => true,
  61                      'fill-rule' => true,
  62                      'points'    => true,
  63                      'transform' => true,
  64                      'focusable' => true,
  65                  ),
  66              )
  67          );
  68  
  69          if ( ! $svg ) {
  70              return false;
  71          }
  72          return $svg;
  73      }
  74  }


Generated : Wed Dec 18 08:20:01 2024 Cross-referenced by PHPXref