• 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_social_link_svg() – Detects the social network from a URL and returns the SVG code for its icon.

You appear to be a bot. Output may be restricted

Description

Detects the social network from a URL and returns the SVG code for its icon.

Usage

TwentyNineteen_SVG_Icons::get_social_link_svg( $uri, $size );

Parameters

$uri
( mixed ) required –
$size
( mixed ) required –

Returns

void

Source

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

1 to 19 of 19
  public static function get_social_link_svg( $uri, $size ) {
    static $regex_map; // Only compute regex map once, for performance.
    if ( ! isset( $regex_map ) ) {
      $regex_map = array();
      $map       = &self::$social_icons_map; // Use reference instead of copy, to save memory.
      foreach ( array_keys( self::$social_icons ) as $icon ) {
        $domains            = array_key_exists( $icon, $map ) ? $map[ $icon ] : array( sprintf( '%s.com', $icon ) );
        $domains            = array_map( 'trim', $domains ); // Remove leading/trailing spaces, to prevent regex from failing to match.
        $domains            = array_map( 'preg_quote', $domains );
        $regex_map[ $icon ] = sprintf( '/(%s)/i', implode( '|', $domains ) );
      }
    }
    foreach ( $regex_map as $icon => $regex ) {
      if ( preg_match( $regex, $uri ) ) {
        return self::get_svg( 'social', $icon, $size );
      }
    }
    return null;
  }
 

 View on GitHub View on Trac

Published: 25th November 2019 | Last updated: 25th November 2019

Primary Sidebar

Information

Function name: TwentyNineteen_SVG_Icons::get_social_link_svg
Class ref: TwentyNineteen_SVG_Icons
Plugin ref: Twenty Nineteen
Version: 1.9
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 5.6.2. PHP: 7.3.27
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-2021. All rights reserved.


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

  • Home
  • Blog
  • Sitemap
  • Sites