• 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 / Twenty_Twenty_One_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

$string = Twenty_Twenty_One_SVG_Icons::get_svg( $group, $icon, $size );

Parameters

$group
( string ) required – The icon group.
$icon
( string ) required – The icon.
$size
( int ) required – The icon-size in pixels.

Returns

string

Source

File name: twentytwentyone/classes/class-twenty-twenty-one-svg-icons.php
Lines:

1 to 32 of 32
  public static function get_svg( $group, $icon, $size ) {

    if ( 'ui' === $group ) {
      $arr = self::$icons;
    } elseif ( 'social' === $group ) {
      $arr = self::$social_icons;
    } else {
      $arr = array();
    }

    
/**
 * Filters Twenty Twenty-Ones's array of icons.
 *
 * The dynamic portion of the hook name, `$group`, refers to
 * the name of the group of icons, either "ui" or "social".
 *
 * @since Twenty Twenty-One 1.0
 *
 * @param array $arr Array of icons.
 */
    $arr = apply_filters( "twenty_twenty_one_svg_icons_{$group}", $arr );

    $svg = '';
    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.
    }

    // @phpstan-ignore-next-line.
    return $svg;
  }
 

 View on GitHub View on Trac

Published: 9th December 2020 | Last updated: 23rd February 2021

Primary Sidebar

Information

Function name: Twenty_Twenty_One_SVG_Icons::get_svg
Class ref: Twenty_Twenty_One_SVG_Icons
Plugin ref: Twenty Twenty-One
Version: 1.7
Sourcefile: classes/class-twenty-twenty-one-svg-icons.php
File ref: classes/class-twenty-twenty-one-svg-icons.php
Deprecated?: No
API Letters: I,O,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