icons->get_svg( 'chevron-down' );
if ( in_array( 'menu-item-has-children', $item->classes, true ) ) {
if ( false === strpos( $args->link_after, $dropdown_indicator ) ) {
$args->link_after .= $dropdown_indicator;
$args->after = '';
}
} else {
$args->link_after = str_replace( $dropdown_indicator, '', $args->link_after );
$args->after = '';
}
}
return $args;
}
add_filter( 'nav_menu_item_args', 'bloglo_nav_menu_item_args', 10, 3 );
/**
* Display social 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 bloglo_nav_menu_social_icons( $item_output, $item, $depth, $args ) {
// Get supported social icons.
$social_icons = bloglo_social_links_icons();
// Change SVG icon inside social links menu if there is supported URL.
if ( false !== strpos( $args->menu_class, 'bloglo-socials-menu' ) ) {
foreach ( $social_icons as $attr => $value ) {
if ( false !== strpos( $item_output, $attr ) ) {
$item_output = str_replace(
$args->link_after,
'' . bloglo()->icons->get_svg( $value, array( 'aria-hidden' => 'true' ) ) . bloglo()->icons->get_svg(
$value,
array(
'class' => 'bottom-icon',
'aria-hidden' => 'true',
)
),
$item_output
);
}
}
}
return $item_output;
}
add_filter( 'walker_nav_menu_start_el', 'bloglo_nav_menu_social_icons', 10, 4 );
/**
* Returns an array of supported social links (URL and icon name).
*
* @return array $social_links_icons
*/
function bloglo_social_links_icons() {
// Supported social links icons.
$social_links_icons = array(
'500px.com' => '500px',
'amazon.com' => 'amazon',
'behance.net' => 'behance',
'digg.com' => 'digg',
'dribbble.com' => 'dribbble',
'deviantart' => 'deviantart',
'etsy.com' => 'etsy',
'facebook.com' => 'facebook',
'flipboard.com' => 'flipboard',
'flickr.com' => 'flickr',
'foursquare.com' => 'foursquare',
'github.com' => 'github',
'plus.google.com' => 'google-plus',
'instagram.com' => 'instagram',
'linkedin.com' => 'linkedin',
'mailto:' => 'mail',
'medium.com' => 'medium',
'pinterest.com' => 'pinterest',
'reddit.com' => 'reddit',
'skype.com' => 'skype',
'skype:' => 'skype',
'snapchat.com' => 'snapchat',
'soundcloud.com' => 'soundcloud',
'spotify.com' => 'spotify',
'tumblr.com' => 'tumblr',
'twitch.tv' => 'twitch',
'twitter.com' => 'twitter',
'vimeo.com' => 'vimeo',
'xing.com' => 'xing',
'vk.com' => 'vkontakte',
'youtube.com' => 'youtube',
'yelp.com' => 'yelp',
'wa.me' => 'whatsapp',
'tiktok.com' => 'tiktok',
'stackoverflow.com' => 'stackoverflow',
'rss.com' => 'rss',
);
/**
* Filter Bloglo social links icons.
*
* @since 1.0.0
* @param array $social_links_icons Array of social links icons.
*/
return apply_filters( 'bloglo_social_links_icons', $social_links_icons );
}
if ( ! class_exists( 'Bloglo_Icons' ) ) :
/**
* Bloglo Icons class.
*
* @since 1.0.0
*/
class Bloglo_Icons {
/**
* Primary class constructor.
*
* @since 1.0.0
*/
public function __construct() {
}
/**
* GET SVG CODE
* Get the SVG code for the specified icon
*
* @param string $icon Icon name.
* @param array $args Parameters needed to display an SVG.
*/
public function get_svg( $icon = '', $args = array() ) {
$arr = self::get();
if ( ! array_key_exists( $icon, $arr ) ) {
return null;
}
$args = wp_parse_args(
$args,
array(
'class' => '',
)
);
// .bloglo-icon is a required class.
if ( false === strpos( $args['class'], 'bloglo-icon' ) ) {
$args['class'] = trim( 'bloglo-icon ' . $args['class'] );
}
$repl = '