芝麻web文件管理V1.00
编辑当前文件:/home/mybf1/public_html/pati.bf1.my_bk_2024-03-07/wp-content/themes/sinatra/inc/icon-functions.php
* @since 1.0.0 */ /** * Do not allow direct script access. */ if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Filters the arguments for a single nav menu item to include dropdown indicators. * * @since 1.2.0 * * @param stdClass $args An object of wp_nav_menu() arguments. * @param WP_Post $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. */ function sinatra_nav_menu_item_args( $args, $item, $depth ) { if ( sinatra_option( 'main_nav_sub_indicators' ) ) { $dropdown_indicator = sinatra()->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; } } else { $args->link_after = str_replace( $dropdown_indicator, '', $args->link_after ); } } return $args; } add_filter( 'nav_menu_item_args', 'sinatra_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 sinatra_nav_menu_social_icons( $item_output, $item, $depth, $args ) { // Get supported social icons. $social_icons = sinatra_social_links_icons(); // Change SVG icon inside social links menu if there is supported URL. if ( false !== strpos( $args->menu_class, 'sinatra-socials-menu' ) ) { foreach ( $social_icons as $attr => $value ) { if ( false !== strpos( $item_output, $attr ) ) { $item_output = str_replace( $args->link_after, '' . sinatra()->icons->get_svg( $value, array( 'aria-hidden' => 'true' ) ) . sinatra()->icons->get_svg( $value, array( 'class' => 'bottom-icon', 'aria-hidden' => 'true', ) ), $item_output ); } } } return $item_output; } add_filter( 'walker_nav_menu_start_el', 'sinatra_nav_menu_social_icons', 10, 4 ); /** * Returns an array of supported social links (URL and icon name). * * @return array $social_links_icons */ function sinatra_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', ); /** * Filter Sinatra social links icons. * * @since 1.0.0 * @param array $social_links_icons Array of social links icons. */ return apply_filters( 'sinatra_social_links_icons', $social_links_icons ); } if ( ! class_exists( 'Sinatra_Icons' ) ) : /** * Sinatra Icons class. * * @since 1.2.0 */ class Sinatra_Icons { /** * Primary class constructor. * * @since 1.2.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' => '', ) ); // .si-icon is a required class. if ( false === strpos( $args['class'], 'si-icon' ) ) { $args['class'] = trim( 'si-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, ), 'path' => array( 'fill' => true, 'fill-rule' => true, 'd' => true, 'transform' => 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( 'sinatra_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.1.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 ( sinatra_option( 'single_entry_meta_icons' ) ) { $return = $icon; } } elseif ( ! is_single() ) { if ( sinatra_option( 'entry_meta_icons' ) ) { $return = $icon; } } return apply_filters( 'sinatra_' . $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-left' => '
', 'arrow-right' => '
', 'behance' => '
', 'bookmark' => '
', 'chat' => '
', 'chevron-down' => '
', 'chevron-up' => '
', 'clock' => '
', 'deviantart' => '
', 'digg' => '
', 'dribbble' => '
', 'edit-3' => '
', 'etsy' => '
', 'external-link' => '
', 'facebook' => '
', 'flipboard' => '
', 'flickr' => '
', 'foursquare' => '
', 'github' => '
', 'google-plus' => '
', 'instagram' => '
', 'linkedin' => '
', 'mail' => '
', 'medium' => '
', 'message-square' => '
', 'pinterest' => '
', 'play' => '
', 'reddit' => '
', 'search' => '
', 'share-2' => '
', 'shopping-cart' => '
', 'skype' => '
', 'snapchat' => '
', 'soundcloud' => '
', 'spotify' => '
', 'star' => '
', 'tag' => '
', 'tumblr' => '
', 'twitch' => '
', 'twitter' => '
', 'vimeo' => '
', 'vkontakte' => '
', 'x' => '
', 'xing' => '
', 'quote' => '
', 'yelp' => '
', 'youtube' => '
', 'whatsapp' => '
', ); } endif;