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', 'bloghash_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 bloghash_nav_menu_social_icons( $item_output, $item, $depth, $args ) {
// Get supported social icons.
$social_icons = bloghash_social_links_icons();
// Change SVG icon inside social links menu if there is supported URL.
if ( false !== strpos( $args->menu_class, 'bloghash-socials-menu' ) ) {
foreach ( $social_icons as $attr => $value ) {
if ( false !== strpos( $item_output, $attr ) ) {
$item_output = str_replace(
$args->link_after,
'' . bloghash()->icons->get_svg( $value, array( 'aria-hidden' => 'true' ) ) . bloghash()->icons->get_svg(
$value,
array(
'class' => 'bottom-icon',
'aria-hidden' => 'true',
)
),
$item_output
);
}
}
}
return $item_output;
}
add_filter( 'walker_nav_menu_start_el', 'bloghash_nav_menu_social_icons', 10, 4 );
/**
* Returns an array of supported social links (URL and icon name).
*
* @return array $social_links_icons
*/
function bloghash_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',
'tel:' => 'phone',
'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',
'x.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',
't.me' => 'telegram',
'discord.com' => 'discord',
'wechat.com' => 'wechat',
'qq.com' => 'qq',
'bilibili.tv' => 'bilibili',
'threads.net' => 'threads',
'linktr.ee' => 'linktree',
'rumble.com' => 'rumble',
'mastodon.social' => 'mastodon',
'bsky.app' => 'bluesky',
'bluesky.app' => 'bluesky',
'bsky.social' => 'bluesky',
'gemspace.com' => 'gemspace',
'lifegroupchat.com' => 'lifegroupchat',
);
/**
* Filter Bloghash social links icons.
*
* @since 1.0.0
* @param array $social_links_icons Array of social links icons.
*/
return apply_filters( 'bloghash_social_links_icons', $social_links_icons );
}
if ( ! class_exists( 'Bloghash_Icons' ) ) :
/**
* Bloghash Icons class.
*
* @since 1.0.0
*/
class Bloghash_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' => '',
)
);
// .bloghash-icon is a required class.
if ( false === strpos( $args['class'], 'bloghash-icon' ) ) {
$args['class'] = trim( 'bloghash-icon ' . $args['class'] );
}
$repl = '