wp_site_icon

Display site icon meta tags.

Description

wp_site_icon(); 

Usage

  1. if ( !function_exists( 'wp_site_icon' ) ) { 
  2. require_once ABSPATH . WPINC . '/general-template.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_site_icon(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/general-template.php  
  1. functionwp_site_icon) { 
  2. if ( ! has_site_icon() && ! is_customize_preview() ) { 
  3. return; 
  4.  
  5. $meta_tags = array(); 
  6. $icon_32 = get_site_icon_url( 32 ); 
  7. if ( empty( $icon_32 ) && is_customize_preview() ) { 
  8. $icon_32 = '/favicon.ico'; // Serve default favicon URL in customizer so element can be updated for preview. 
  9. if ( $icon_32 ) { 
  10. $meta_tags[] = sprintf( '<link rel="icon" href="%s" sizes="32x32" />', esc_url( $icon_32 ) ); 
  11. $icon_192 = get_site_icon_url( 192 ); 
  12. if ( $icon_192 ) { 
  13. $meta_tags[] = sprintf( '<link rel="icon" href="%s" sizes="192x192" />', esc_url( $icon_192 ) ); 
  14. $icon_180 = get_site_icon_url( 180 ); 
  15. if ( $icon_180 ) { 
  16. $meta_tags[] = sprintf( '<link rel="apple-touch-icon-precomposed" href="%s" />', esc_url( $icon_180 ) ); 
  17. $icon_270 = get_site_icon_url( 270 ); 
  18. if ( $icon_270 ) { 
  19. $meta_tags[] = sprintf( '<meta name="msapplication-TileImage" content="%s" />', esc_url( $icon_270 ) ); 
  20.  
  21. /** 
  22. * Filters the site icon meta tags, so Plugins can add their own. 
  23. * @since 4.3.0 
  24. * @param array $meta_tags Site Icon meta elements. 
  25. */ 
  26. $meta_tags = apply_filters( 'site_icon_meta_tags', $meta_tags ); 
  27. $meta_tags = array_filter( $meta_tags ); 
  28.  
  29. foreach ( $meta_tags as $meta_tag ) { 
  30. echo "$meta_tag\n";