Custom Social Icons in WordPress Twentynineteen

A small code snippet for functions.php in your Child Theme to add custom social icons to WordPress Twentynineteen Theme.

/**
* Add own Social SVG Icons to WordPress Twentynineteen Theme
*/
function twentynineteen_custom_social_icons( $item_output, $item, $depth, $args ) {
	if ( 'social' === $args->theme_location ) {
		$svg = twentynineteen_get_social_link_svg( $item->url, 26 );
		if ( empty( $svg ) ) {
			switch (true) {
			    case preg_match('/(xing)/i', $item->url):
			        $svg = '<svg height="26" viewBox="0 0 1792 1792" width="26" xmlns="http://www.w3.org/2000/svg"><path d="M813 765q0-1-126-222-21-34-52-34h-184q-18 0-26 11-7 12 1 29l125 216v1l-196 346q-9 14 0 28 8 13 24 13h185q31 0 50-36zm624-497q-7-12-24-12h-187q-30 0-49 35l-411 729q1 2 262 481 20 35 52 35h184q18 0 25-12 8-13-1-28l-260-476v-1l409-723q8-16 0-28zm227 148v960q0 119-84.5 203.5t-203.5 84.5h-960q-119 0-203.5-84.5t-84.5-203.5v-960q0-119 84.5-203.5t203.5-84.5h960q119 0 203.5 84.5t84.5 203.5z"/></svg>';
			        break;
			    default:
			    	$svg = twentynineteen_get_icon_svg( 'link' );
			}
		}
		$item_output = str_replace( $args->link_after, '</span>' . $svg, $item_output );
	}
	return $item_output;
}
add_filter( 'walker_nav_menu_start_el', 'twentynineteen_custom_social_icons', 20, 4 );