[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-content/themes/twentynineteen/inc/ -> icon-functions.php (source)

   1  <?php
   2  /**
   3   * SVG icons related functions
   4   *
   5   * @package WordPress
   6   * @subpackage Twenty_Nineteen
   7   * @since 1.0.0
   8   */
   9  
  10  /**
  11   * Gets the SVG code for a given icon.
  12   */
  13  function twentynineteen_get_icon_svg( $icon, $size = 24 ) {
  14      return TwentyNineteen_SVG_Icons::get_svg( 'ui', $icon, $size );
  15  }
  16  
  17  /**
  18   * Gets the SVG code for a given social icon.
  19   */
  20  function twentynineteen_get_social_icon_svg( $icon, $size = 24 ) {
  21      return TwentyNineteen_SVG_Icons::get_svg( 'social', $icon, $size );
  22  }
  23  
  24  /**
  25   * Detects the social network from a URL and returns the SVG code for its icon.
  26   */
  27  function twentynineteen_get_social_link_svg( $uri, $size = 24 ) {
  28      return TwentyNineteen_SVG_Icons::get_social_link_svg( $uri, $size );
  29  }
  30  
  31  /**
  32   * Display SVG icons in social links menu.
  33   *
  34   * @param  string  $item_output The menu item output.
  35   * @param  WP_Post $item        Menu item object.
  36   * @param  int     $depth       Depth of the menu.
  37   * @param  array   $args        wp_nav_menu() arguments.
  38   * @return string  $item_output The menu item output with social icon.
  39   */
  40  function twentynineteen_nav_menu_social_icons( $item_output, $item, $depth, $args ) {
  41      // Change SVG icon inside social links menu if there is supported URL.
  42      if ( 'social' === $args->theme_location ) {
  43          $svg = twentynineteen_get_social_link_svg( $item->url, 26 );
  44          if ( empty( $svg ) ) {
  45              $svg = twentynineteen_get_icon_svg( 'link' );
  46          }
  47          $item_output = str_replace( $args->link_after, '</span>' . $svg, $item_output );
  48      }
  49  
  50      return $item_output;
  51  }
  52  add_filter( 'walker_nav_menu_start_el', 'twentynineteen_nav_menu_social_icons', 10, 4 );


Generated: Tue Oct 22 08:20:01 2019 Cross-referenced by PHPXref 0.7