• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress a2z

WordPress a2z

WordPress Dynamic API Reference

  • Home
  • Plugins
  • Themes
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / TwentyNineteen_SVG_Icons::get_svg() – Gets the SVG code for a given icon.

You appear to be a bot. Output may be restricted

Description

Gets the SVG code for a given icon.

Usage

TwentyNineteen_SVG_Icons::get_svg( $group, $icon, $size );

Parameters

$group
( mixed ) required –
$icon
( mixed ) required –
$size
( mixed ) required –

Returns

void

Source

File name: twentynineteen/classes/class-twentynineteen-svg-icons.php
Lines:

1 to 17 of 17
  public static function get_svg( $group, $icon, $size ) {
    if ( 'ui' === $group ) {
      $arr = self::$ui_icons;
    } elseif ( 'social' === $group ) {
      $arr = self::$social_icons;
    } else {
      $arr = array();
    }
    if ( array_key_exists( $icon, $arr ) ) {
      $repl = sprintf( '<svg class="svg-icon" width="%d" height="%d" aria-hidden="true" role="img" focusable="false" ', $size, $size );
      $svg  = preg_replace( '/^<svg /', $repl, trim( $arr[ $icon ] ) ); // Add extra attributes to SVG code.
      $svg  = preg_replace( "/([\n\t]+)/", ' ', $svg ); // Remove newlines & tabs.
      $svg  = preg_replace( '/>\s*</', '><', $svg );    // Remove whitespace between SVG tags.
      return $svg;
    }
    return null;
  }
 

 View on GitHub View on Trac

Published: 25th November 2019 | Last updated: 11th June 2020

Primary Sidebar

Information

Function name: TwentyNineteen_SVG_Icons::get_svg
Class ref: TwentyNineteen_SVG_Icons
Plugin ref: Twenty Nineteen
Version: 2.4
Sourcefile: classes/class-twentynineteen-svg-icons.php
File ref: classes/class-twentynineteen-svg-icons.php
Deprecated?: No
API Letters: G,I,S,T

Footer

WordPress a2z
WordPress a2z
WordPress Dynamic API Reference
WordPress 6.1.1. PHP: 8.0.28
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  wp-a2z.org
© Copyright WordPress a2z 2014-2023. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites