Importing Twenty Seventeen, our new default theme for 2017, set for 4.7.
With a focus on business sites, it will let you get down to business in style. Initial development occurred on GitHub. See: https://github.com/WordPress/twentyseventeen
Props melchoyce, laurelfulford, davidakennedy, grapplerulrich, manishsongirkar36, joefusco, smyoon315, b-07, rabmalin, mrahmadawais, hardeepasrani, implenton, acmethemes, claudiosanches, valeriutihai, pressionate, sgr33n, doughamlin, zodiac1978, tsl143, nikschavan, joshcummingsdesign, enodekciw, jordesign, patilvikasj, ryelle, mahesh901122, williampatton, juanfra, imnok, littlebigthing, mor10, samikeijonen, celloexpressions, akshayvinchurkar, davidmosterd, hiddenpearls, netweb, pratikchaskar, taggon, nukaga, ranh, yoavf, karmatosed, sandesh055, adammacias, noplanman, yogasukma, binarymoon, swapnilld, swissspidy, joyously, allancole, rianrietveld, sixhours, alex27, themeshaper, mapk, leobaiano.
See #38372.
Built from https://develop.svn.wordpress.org/trunk@38833
git-svn-id: http://core.svn.wordpress.org/trunk@38776 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-20 06:12:31 +02:00
< ? php
/**
* SVG icons related functions and filters
*
* @ package WordPress
* @ subpackage Twenty_Seventeen
* @ since 1.0
*/
/**
* Add SVG definitions to the footer .
*/
function twentyseventeen_include_svg_icons () {
// Define SVG sprite file.
$svg_icons = get_parent_theme_file_path ( '/assets/images/svg-icons.svg' );
// If it exists, include it.
if ( file_exists ( $svg_icons ) ) {
require_once ( $svg_icons );
}
}
add_action ( 'wp_footer' , 'twentyseventeen_include_svg_icons' , 9999 );
/**
* Return SVG markup .
*
* @ param array $args {
* Parameters needed to display an SVG .
*
* @ type string $icon Required SVG icon filename .
* @ type string $title Optional SVG title .
* @ type string $desc Optional SVG description .
* }
* @ return string SVG markup .
*/
function twentyseventeen_get_svg ( $args = array () ) {
// Make sure $args are an array.
if ( empty ( $args ) ) {
return __ ( 'Please define default parameters in the form of an array.' , 'twentyseventeen' );
}
// Define an icon.
if ( false === array_key_exists ( 'icon' , $args ) ) {
return __ ( 'Please define an SVG icon filename.' , 'twentyseventeen' );
}
// Set defaults.
$defaults = array (
'icon' => '' ,
'title' => '' ,
'desc' => '' ,
'fallback' => false ,
);
// Parse args.
$args = wp_parse_args ( $args , $defaults );
// Set aria hidden.
2016-11-08 19:01:33 +01:00
$aria_hidden = ' aria-hidden="true"' ;
Importing Twenty Seventeen, our new default theme for 2017, set for 4.7.
With a focus on business sites, it will let you get down to business in style. Initial development occurred on GitHub. See: https://github.com/WordPress/twentyseventeen
Props melchoyce, laurelfulford, davidakennedy, grapplerulrich, manishsongirkar36, joefusco, smyoon315, b-07, rabmalin, mrahmadawais, hardeepasrani, implenton, acmethemes, claudiosanches, valeriutihai, pressionate, sgr33n, doughamlin, zodiac1978, tsl143, nikschavan, joshcummingsdesign, enodekciw, jordesign, patilvikasj, ryelle, mahesh901122, williampatton, juanfra, imnok, littlebigthing, mor10, samikeijonen, celloexpressions, akshayvinchurkar, davidmosterd, hiddenpearls, netweb, pratikchaskar, taggon, nukaga, ranh, yoavf, karmatosed, sandesh055, adammacias, noplanman, yogasukma, binarymoon, swapnilld, swissspidy, joyously, allancole, rianrietveld, sixhours, alex27, themeshaper, mapk, leobaiano.
See #38372.
Built from https://develop.svn.wordpress.org/trunk@38833
git-svn-id: http://core.svn.wordpress.org/trunk@38776 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-20 06:12:31 +02:00
// Set ARIA.
$aria_labelledby = '' ;
2016-11-08 19:01:33 +01:00
/*
* Twenty Seventeen doesn ' t use the SVG title or description attributes ; non - decorative icons are described with . screen - reader - text .
*
* However , child themes can use the title and description to add information to non - decorative SVG icons to improve accessibility .
*
* Example 1 with title : < ? php echo twentyseventeen_get_svg ( array ( 'icon' => 'arrow-right' , 'title' => __ ( 'This is the title' , 'textdomain' ) ) ); ?>
*
* Example 2 with title and description : < ? php echo twentyseventeen_get_svg ( array ( 'icon' => 'arrow-right' , 'title' => __ ( 'This is the title' , 'textdomain' ), 'desc' => __ ( 'This is the description' , 'textdomain' ) ) ); ?>
*
* See https :// www . paciellogroup . com / blog / 2013 / 12 / using - aria - enhance - svg - accessibility /.
*/
if ( $args [ 'title' ] ) {
$aria_hidden = '' ;
$unique_id = uniqid ();
$aria_labelledby = ' aria-labelledby="title-' . $unique_id . '"' ;
if ( $args [ 'desc' ] ) {
$aria_labelledby = ' aria-labelledby="title-' . $unique_id . ' desc-' . $unique_id . '"' ;
}
Importing Twenty Seventeen, our new default theme for 2017, set for 4.7.
With a focus on business sites, it will let you get down to business in style. Initial development occurred on GitHub. See: https://github.com/WordPress/twentyseventeen
Props melchoyce, laurelfulford, davidakennedy, grapplerulrich, manishsongirkar36, joefusco, smyoon315, b-07, rabmalin, mrahmadawais, hardeepasrani, implenton, acmethemes, claudiosanches, valeriutihai, pressionate, sgr33n, doughamlin, zodiac1978, tsl143, nikschavan, joshcummingsdesign, enodekciw, jordesign, patilvikasj, ryelle, mahesh901122, williampatton, juanfra, imnok, littlebigthing, mor10, samikeijonen, celloexpressions, akshayvinchurkar, davidmosterd, hiddenpearls, netweb, pratikchaskar, taggon, nukaga, ranh, yoavf, karmatosed, sandesh055, adammacias, noplanman, yogasukma, binarymoon, swapnilld, swissspidy, joyously, allancole, rianrietveld, sixhours, alex27, themeshaper, mapk, leobaiano.
See #38372.
Built from https://develop.svn.wordpress.org/trunk@38833
git-svn-id: http://core.svn.wordpress.org/trunk@38776 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-20 06:12:31 +02:00
}
// Begin SVG markup.
$svg = '<svg class="icon icon-' . esc_attr ( $args [ 'icon' ] ) . '"' . $aria_hidden . $aria_labelledby . ' role="img">' ;
2016-11-08 19:01:33 +01:00
// Display the title.
Importing Twenty Seventeen, our new default theme for 2017, set for 4.7.
With a focus on business sites, it will let you get down to business in style. Initial development occurred on GitHub. See: https://github.com/WordPress/twentyseventeen
Props melchoyce, laurelfulford, davidakennedy, grapplerulrich, manishsongirkar36, joefusco, smyoon315, b-07, rabmalin, mrahmadawais, hardeepasrani, implenton, acmethemes, claudiosanches, valeriutihai, pressionate, sgr33n, doughamlin, zodiac1978, tsl143, nikschavan, joshcummingsdesign, enodekciw, jordesign, patilvikasj, ryelle, mahesh901122, williampatton, juanfra, imnok, littlebigthing, mor10, samikeijonen, celloexpressions, akshayvinchurkar, davidmosterd, hiddenpearls, netweb, pratikchaskar, taggon, nukaga, ranh, yoavf, karmatosed, sandesh055, adammacias, noplanman, yogasukma, binarymoon, swapnilld, swissspidy, joyously, allancole, rianrietveld, sixhours, alex27, themeshaper, mapk, leobaiano.
See #38372.
Built from https://develop.svn.wordpress.org/trunk@38833
git-svn-id: http://core.svn.wordpress.org/trunk@38776 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-20 06:12:31 +02:00
if ( $args [ 'title' ] ) {
2016-11-08 19:01:33 +01:00
$svg .= '<title id="title-' . $unique_id . '">' . esc_html ( $args [ 'title' ] ) . '</title>' ;
Importing Twenty Seventeen, our new default theme for 2017, set for 4.7.
With a focus on business sites, it will let you get down to business in style. Initial development occurred on GitHub. See: https://github.com/WordPress/twentyseventeen
Props melchoyce, laurelfulford, davidakennedy, grapplerulrich, manishsongirkar36, joefusco, smyoon315, b-07, rabmalin, mrahmadawais, hardeepasrani, implenton, acmethemes, claudiosanches, valeriutihai, pressionate, sgr33n, doughamlin, zodiac1978, tsl143, nikschavan, joshcummingsdesign, enodekciw, jordesign, patilvikasj, ryelle, mahesh901122, williampatton, juanfra, imnok, littlebigthing, mor10, samikeijonen, celloexpressions, akshayvinchurkar, davidmosterd, hiddenpearls, netweb, pratikchaskar, taggon, nukaga, ranh, yoavf, karmatosed, sandesh055, adammacias, noplanman, yogasukma, binarymoon, swapnilld, swissspidy, joyously, allancole, rianrietveld, sixhours, alex27, themeshaper, mapk, leobaiano.
See #38372.
Built from https://develop.svn.wordpress.org/trunk@38833
git-svn-id: http://core.svn.wordpress.org/trunk@38776 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-20 06:12:31 +02:00
2016-11-08 19:01:33 +01:00
// Display the desc only if the title is already set.
if ( $args [ 'desc' ] ) {
$svg .= '<desc id="desc-' . $unique_id . '">' . esc_html ( $args [ 'desc' ] ) . '</desc>' ;
}
Importing Twenty Seventeen, our new default theme for 2017, set for 4.7.
With a focus on business sites, it will let you get down to business in style. Initial development occurred on GitHub. See: https://github.com/WordPress/twentyseventeen
Props melchoyce, laurelfulford, davidakennedy, grapplerulrich, manishsongirkar36, joefusco, smyoon315, b-07, rabmalin, mrahmadawais, hardeepasrani, implenton, acmethemes, claudiosanches, valeriutihai, pressionate, sgr33n, doughamlin, zodiac1978, tsl143, nikschavan, joshcummingsdesign, enodekciw, jordesign, patilvikasj, ryelle, mahesh901122, williampatton, juanfra, imnok, littlebigthing, mor10, samikeijonen, celloexpressions, akshayvinchurkar, davidmosterd, hiddenpearls, netweb, pratikchaskar, taggon, nukaga, ranh, yoavf, karmatosed, sandesh055, adammacias, noplanman, yogasukma, binarymoon, swapnilld, swissspidy, joyously, allancole, rianrietveld, sixhours, alex27, themeshaper, mapk, leobaiano.
See #38372.
Built from https://develop.svn.wordpress.org/trunk@38833
git-svn-id: http://core.svn.wordpress.org/trunk@38776 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-20 06:12:31 +02:00
}
2016-11-08 19:01:33 +01:00
/*
* Display the icon .
*
* The whitespace around `<use>` is intentional - it is a work around to a keyboard navigation bug in Safari 10.
*
* See https :// core . trac . wordpress . org / ticket / 38387.
*/
2016-11-13 00:39:34 +01:00
$svg .= ' <use href="#icon-' . esc_html ( $args [ 'icon' ] ) . '" xlink:href="#icon-' . esc_html ( $args [ 'icon' ] ) . '"></use> ' ;
Importing Twenty Seventeen, our new default theme for 2017, set for 4.7.
With a focus on business sites, it will let you get down to business in style. Initial development occurred on GitHub. See: https://github.com/WordPress/twentyseventeen
Props melchoyce, laurelfulford, davidakennedy, grapplerulrich, manishsongirkar36, joefusco, smyoon315, b-07, rabmalin, mrahmadawais, hardeepasrani, implenton, acmethemes, claudiosanches, valeriutihai, pressionate, sgr33n, doughamlin, zodiac1978, tsl143, nikschavan, joshcummingsdesign, enodekciw, jordesign, patilvikasj, ryelle, mahesh901122, williampatton, juanfra, imnok, littlebigthing, mor10, samikeijonen, celloexpressions, akshayvinchurkar, davidmosterd, hiddenpearls, netweb, pratikchaskar, taggon, nukaga, ranh, yoavf, karmatosed, sandesh055, adammacias, noplanman, yogasukma, binarymoon, swapnilld, swissspidy, joyously, allancole, rianrietveld, sixhours, alex27, themeshaper, mapk, leobaiano.
See #38372.
Built from https://develop.svn.wordpress.org/trunk@38833
git-svn-id: http://core.svn.wordpress.org/trunk@38776 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-20 06:12:31 +02:00
// Add some markup to use as a fallback for browsers that do not support SVGs.
if ( $args [ 'fallback' ] ) {
$svg .= '<span class="svg-fallback icon-' . esc_attr ( $args [ 'icon' ] ) . '"></span>' ;
}
$svg .= '</svg>' ;
return $svg ;
}
/**
* Display SVG icons in social links menu .
*
* @ param string $item_output The menu item output .
* @ param WP_Post $item Menu item object .
* @ param int $depth Depth of the menu .
* @ param array $args wp_nav_menu () arguments .
* @ return string $item_output The menu item output with social icon .
*/
function twentyseventeen_nav_menu_social_icons ( $item_output , $item , $depth , $args ) {
// Get supported social icons.
$social_icons = twentyseventeen_social_links_icons ();
// Change SVG icon inside social links menu if there is supported URL.
if ( 'social' === $args -> theme_location ) {
foreach ( $social_icons as $attr => $value ) {
if ( false !== strpos ( $item_output , $attr ) ) {
$item_output = str_replace ( $args -> link_after , '</span>' . twentyseventeen_get_svg ( array ( 'icon' => esc_attr ( $value ) ) ), $item_output );
}
}
}
return $item_output ;
}
add_filter ( 'walker_nav_menu_start_el' , 'twentyseventeen_nav_menu_social_icons' , 10 , 4 );
/**
* Add dropdown icon if menu item has children .
*
2017-09-20 20:15:46 +02:00
* @ param string $title The menu item ' s title .
* @ param WP_Post $item The current menu item .
* @ param array $args An array of wp_nav_menu () arguments .
* @ param int $depth Depth of menu item . Used for padding .
* @ return string $title The menu item ' s title with dropdown icon .
Importing Twenty Seventeen, our new default theme for 2017, set for 4.7.
With a focus on business sites, it will let you get down to business in style. Initial development occurred on GitHub. See: https://github.com/WordPress/twentyseventeen
Props melchoyce, laurelfulford, davidakennedy, grapplerulrich, manishsongirkar36, joefusco, smyoon315, b-07, rabmalin, mrahmadawais, hardeepasrani, implenton, acmethemes, claudiosanches, valeriutihai, pressionate, sgr33n, doughamlin, zodiac1978, tsl143, nikschavan, joshcummingsdesign, enodekciw, jordesign, patilvikasj, ryelle, mahesh901122, williampatton, juanfra, imnok, littlebigthing, mor10, samikeijonen, celloexpressions, akshayvinchurkar, davidmosterd, hiddenpearls, netweb, pratikchaskar, taggon, nukaga, ranh, yoavf, karmatosed, sandesh055, adammacias, noplanman, yogasukma, binarymoon, swapnilld, swissspidy, joyously, allancole, rianrietveld, sixhours, alex27, themeshaper, mapk, leobaiano.
See #38372.
Built from https://develop.svn.wordpress.org/trunk@38833
git-svn-id: http://core.svn.wordpress.org/trunk@38776 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-20 06:12:31 +02:00
*/
function twentyseventeen_dropdown_icon_to_menu_link ( $title , $item , $args , $depth ) {
if ( 'top' === $args -> theme_location ) {
foreach ( $item -> classes as $value ) {
if ( 'menu-item-has-children' === $value || 'page_item_has_children' === $value ) {
2016-11-01 18:26:32 +01:00
$title = $title . twentyseventeen_get_svg ( array ( 'icon' => 'angle-down' ) );
Importing Twenty Seventeen, our new default theme for 2017, set for 4.7.
With a focus on business sites, it will let you get down to business in style. Initial development occurred on GitHub. See: https://github.com/WordPress/twentyseventeen
Props melchoyce, laurelfulford, davidakennedy, grapplerulrich, manishsongirkar36, joefusco, smyoon315, b-07, rabmalin, mrahmadawais, hardeepasrani, implenton, acmethemes, claudiosanches, valeriutihai, pressionate, sgr33n, doughamlin, zodiac1978, tsl143, nikschavan, joshcummingsdesign, enodekciw, jordesign, patilvikasj, ryelle, mahesh901122, williampatton, juanfra, imnok, littlebigthing, mor10, samikeijonen, celloexpressions, akshayvinchurkar, davidmosterd, hiddenpearls, netweb, pratikchaskar, taggon, nukaga, ranh, yoavf, karmatosed, sandesh055, adammacias, noplanman, yogasukma, binarymoon, swapnilld, swissspidy, joyously, allancole, rianrietveld, sixhours, alex27, themeshaper, mapk, leobaiano.
See #38372.
Built from https://develop.svn.wordpress.org/trunk@38833
git-svn-id: http://core.svn.wordpress.org/trunk@38776 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-20 06:12:31 +02:00
}
}
}
return $title ;
}
add_filter ( 'nav_menu_item_title' , 'twentyseventeen_dropdown_icon_to_menu_link' , 10 , 4 );
/**
* Returns an array of supported social links ( URL and icon name ) .
*
* @ return array $social_links_icons
*/
function twentyseventeen_social_links_icons () {
// Supported social links icons.
$social_links_icons = array (
'behance.net' => 'behance' ,
'codepen.io' => 'codepen' ,
'deviantart.com' => 'deviantart' ,
'digg.com' => 'digg' ,
2017-09-25 15:49:43 +02:00
'docker.com' => 'dockerhub' ,
Importing Twenty Seventeen, our new default theme for 2017, set for 4.7.
With a focus on business sites, it will let you get down to business in style. Initial development occurred on GitHub. See: https://github.com/WordPress/twentyseventeen
Props melchoyce, laurelfulford, davidakennedy, grapplerulrich, manishsongirkar36, joefusco, smyoon315, b-07, rabmalin, mrahmadawais, hardeepasrani, implenton, acmethemes, claudiosanches, valeriutihai, pressionate, sgr33n, doughamlin, zodiac1978, tsl143, nikschavan, joshcummingsdesign, enodekciw, jordesign, patilvikasj, ryelle, mahesh901122, williampatton, juanfra, imnok, littlebigthing, mor10, samikeijonen, celloexpressions, akshayvinchurkar, davidmosterd, hiddenpearls, netweb, pratikchaskar, taggon, nukaga, ranh, yoavf, karmatosed, sandesh055, adammacias, noplanman, yogasukma, binarymoon, swapnilld, swissspidy, joyously, allancole, rianrietveld, sixhours, alex27, themeshaper, mapk, leobaiano.
See #38372.
Built from https://develop.svn.wordpress.org/trunk@38833
git-svn-id: http://core.svn.wordpress.org/trunk@38776 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-20 06:12:31 +02:00
'dribbble.com' => 'dribbble' ,
'dropbox.com' => 'dropbox' ,
'facebook.com' => 'facebook' ,
'flickr.com' => 'flickr' ,
'foursquare.com' => 'foursquare' ,
'plus.google.com' => 'google-plus' ,
'github.com' => 'github' ,
'instagram.com' => 'instagram' ,
'linkedin.com' => 'linkedin' ,
'mailto:' => 'envelope-o' ,
'medium.com' => 'medium' ,
'pinterest.com' => 'pinterest-p' ,
2017-09-25 15:14:45 +02:00
'pscp.tv' => 'periscope' ,
Importing Twenty Seventeen, our new default theme for 2017, set for 4.7.
With a focus on business sites, it will let you get down to business in style. Initial development occurred on GitHub. See: https://github.com/WordPress/twentyseventeen
Props melchoyce, laurelfulford, davidakennedy, grapplerulrich, manishsongirkar36, joefusco, smyoon315, b-07, rabmalin, mrahmadawais, hardeepasrani, implenton, acmethemes, claudiosanches, valeriutihai, pressionate, sgr33n, doughamlin, zodiac1978, tsl143, nikschavan, joshcummingsdesign, enodekciw, jordesign, patilvikasj, ryelle, mahesh901122, williampatton, juanfra, imnok, littlebigthing, mor10, samikeijonen, celloexpressions, akshayvinchurkar, davidmosterd, hiddenpearls, netweb, pratikchaskar, taggon, nukaga, ranh, yoavf, karmatosed, sandesh055, adammacias, noplanman, yogasukma, binarymoon, swapnilld, swissspidy, joyously, allancole, rianrietveld, sixhours, alex27, themeshaper, mapk, leobaiano.
See #38372.
Built from https://develop.svn.wordpress.org/trunk@38833
git-svn-id: http://core.svn.wordpress.org/trunk@38776 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-20 06:12:31 +02:00
'getpocket.com' => 'get-pocket' ,
'reddit.com' => 'reddit-alien' ,
'skype.com' => 'skype' ,
'skype:' => 'skype' ,
'slideshare.net' => 'slideshare' ,
'snapchat.com' => 'snapchat-ghost' ,
'soundcloud.com' => 'soundcloud' ,
'spotify.com' => 'spotify' ,
'stumbleupon.com' => 'stumbleupon' ,
'tumblr.com' => 'tumblr' ,
'twitch.tv' => 'twitch' ,
'twitter.com' => 'twitter' ,
'vimeo.com' => 'vimeo' ,
'vine.co' => 'vine' ,
'vk.com' => 'vk' ,
'wordpress.org' => 'wordpress' ,
'wordpress.com' => 'wordpress' ,
'yelp.com' => 'yelp' ,
'youtube.com' => 'youtube' ,
);
2016-10-20 22:34:31 +02:00
/**
* Filter Twenty Seventeen social links icons .
*
* @ since Twenty Seventeen 1.0
*
2017-01-06 23:08:33 +01:00
* @ param array $social_links_icons Array of social links icons .
2016-10-20 22:34:31 +02:00
*/
Importing Twenty Seventeen, our new default theme for 2017, set for 4.7.
With a focus on business sites, it will let you get down to business in style. Initial development occurred on GitHub. See: https://github.com/WordPress/twentyseventeen
Props melchoyce, laurelfulford, davidakennedy, grapplerulrich, manishsongirkar36, joefusco, smyoon315, b-07, rabmalin, mrahmadawais, hardeepasrani, implenton, acmethemes, claudiosanches, valeriutihai, pressionate, sgr33n, doughamlin, zodiac1978, tsl143, nikschavan, joshcummingsdesign, enodekciw, jordesign, patilvikasj, ryelle, mahesh901122, williampatton, juanfra, imnok, littlebigthing, mor10, samikeijonen, celloexpressions, akshayvinchurkar, davidmosterd, hiddenpearls, netweb, pratikchaskar, taggon, nukaga, ranh, yoavf, karmatosed, sandesh055, adammacias, noplanman, yogasukma, binarymoon, swapnilld, swissspidy, joyously, allancole, rianrietveld, sixhours, alex27, themeshaper, mapk, leobaiano.
See #38372.
Built from https://develop.svn.wordpress.org/trunk@38833
git-svn-id: http://core.svn.wordpress.org/trunk@38776 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-20 06:12:31 +02:00
return apply_filters ( 'twentyseventeen_social_links_icons' , $social_links_icons );
}