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 = ' $value ) { if ( ! empty( $value ) ) { $repl .= esc_html( $key ) . '="' . esc_attr( $value ) . '" '; } } } $svg = preg_replace( '/^\s*<', $svg ); // Remove whitespace between SVG tags. // Make sure that only our allowed tags and attributes are included. $svg = wp_kses( $svg, array( 'svg' => array( 'class' => true, 'xmlns' => true, 'width' => true, 'height' => true, 'viewbox' => true, 'aria-hidden' => true, 'aria-label' => true, 'role' => true, 'focusable' => true, 'fill' => true, ), 'path' => array( 'fill' => true, 'fill-rule' => true, 'd' => true, 'transform' => true, 'stroke' => true, 'stroke-linecap' => true, 'stroke-linejoin' => true, 'stroke-miterlimit' => true, 'stroke-width' => true, ), 'polygon' => array( 'fill' => true, 'fill-rule' => true, 'points' => true, 'transform' => true, 'focusable' => true, ), ) ); if ( ! $svg ) { return null; } return $svg; } /** * Get SVG icons array. * * @return array */ public function get() { return apply_filters( 'bloghash_icons_svg', self::$icons ); } /** * Get all available SVG icons * * @return array */ public function get_all_svg_icons() { $arr = self::get(); $return = array(); foreach ( $arr as $icon => $svg ) { $svg = self::get_svg( $icon ); if ( $svg ) { $return[ $icon ] = self::get_svg( $icon ); } } return $return; } /** * Get icon for post entry meta. * * @since 1.0.0 * @param string $slug Icon slug. * @param string $icon Icon HTML markup. * @param string $post_id Current post ID. * @return string Icon HTML markup. */ public function get_meta_icon( $slug = '', $icon = '', $post_id = '' ) { $return = ''; if ( is_single( $post_id ) ) { if ( bloghash_option( 'single_entry_meta_icons' ) ) { $return = $icon; } } elseif ( ! is_single() ) { if ( bloghash_option( 'entry_meta_icons' ) ) { $return = $icon; } } return apply_filters( 'bloghash_' . $slug . '_meta_icon', $return, $post_id ); } /** * Icons. * Store the code for all SVGs in an array. * * @var array */ public static $icons = array( '500px' => '', 'amazon' => '', 'arrow-up' => '', 'arrow-left' => '', 'arrow-right' => '', 'behance' => '', 'bookmark' => '', 'chat' => '', 'chevron-down' => '', 'chevron-up' => '', 'clock' => '', 'calendar' => '', 'deviantart' => '', 'digg' => '', 'dribbble' => '', 'edit-3' => '', 'etsy' => '', 'external-link' => '', 'facebook' => '', 'flipboard' => '', 'flickr' => '', 'foursquare' => '', 'folder-open' => '', 'github' => '', 'google-plus' => '', 'instagram' => '', 'linkedin' => '', 'mail' => '', 'phone' => '', 'medium' => '', 'message-square' => '', 'pinterest' => '', 'play' => '', 'play-2' => '', 'reddit' => '', 'search' => '', 'share-2' => '', 'shopping-bag' => '', 'shopping-empty' => '', 'shopping-cart' => '', 'shopping-cart-2' => '', 'skype' => '', 'snapchat' => '', 'soundcloud' => '', 'spotify' => '', 'star' => '', 'tag' => '', 'tumblr' => '', 'twitch' => '', 'twitter' => '', 'vimeo' => '', 'vkontakte' => '', 'x' => '', 'xing' => '', 'quote' => '', 'yelp' => '', 'youtube' => '', 'whatsapp' => '', 'tiktok' => '', 'stackoverflow' => '', 'rss' => '', 'pin' => '', 'telegram' => '', 'discord' => '', 'bluesky' => '', 'wechat' => '', 'qq' => '', 'bilibili' => '', 'threads' => '', 'linktree' => '', 'rumble' => '', 'mastodon' => '', 'gemspace' => '', 'lifegroupchat' => '' ); } endif;