[ Index ]

WordPress 5.4.1

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

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       * @param string $svg_name The name of the icon.
  16       * @param string $group The group the icon belongs to.
  17       * @param string $color Color code.
  18       */
  19  	function twentytwenty_the_theme_svg( $svg_name, $group = 'ui', $color = '' ) {
  20          echo twentytwenty_get_theme_svg( $svg_name, $group, $color ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in twentytwenty_get_theme_svg().
  21      }
  22  }
  23  
  24  if ( ! function_exists( 'twentytwenty_get_theme_svg' ) ) {
  25  
  26      /**
  27       * Get information about the SVG icon.
  28       *
  29       * @param string $svg_name The name of the icon.
  30       * @param string $group The group the icon belongs to.
  31       * @param string $color Color code.
  32       */
  33  	function twentytwenty_get_theme_svg( $svg_name, $group = 'ui', $color = '' ) {
  34  
  35          // Make sure that only our allowed tags and attributes are included.
  36          $svg = wp_kses(
  37              TwentyTwenty_SVG_Icons::get_svg( $svg_name, $group, $color ),
  38              array(
  39                  'svg'     => array(
  40                      'class'       => true,
  41                      'xmlns'       => true,
  42                      'width'       => true,
  43                      'height'      => true,
  44                      'viewbox'     => true,
  45                      'aria-hidden' => true,
  46                      'role'        => true,
  47                      'focusable'   => true,
  48                  ),
  49                  'path'    => array(
  50                      'fill'      => true,
  51                      'fill-rule' => true,
  52                      'd'         => true,
  53                      'transform' => true,
  54                  ),
  55                  'polygon' => array(
  56                      'fill'      => true,
  57                      'fill-rule' => true,
  58                      'points'    => true,
  59                      'transform' => true,
  60                      'focusable' => true,
  61                  ),
  62              )
  63          );
  64  
  65          if ( ! $svg ) {
  66              return false;
  67          }
  68          return $svg;
  69      }
  70  }


Generated: Tue May 19 15:51:04 2020 Cross-referenced by PHPXref 0.7.1