<?php /** * @package Make */ // Header Options $header_text = get_theme_mod('header-text', false); $social_links = ttfmake_get_social_links(); $show_social = (int) get_theme_mod('header-show-social', ttfmake_get_default('header-show-social')); $show_search = (int) get_theme_mod('header-show-search', ttfmake_get_default('header-show-search')); $subheader_class = 1 === $show_social || 1 === $show_search ? ' right-content' : ''; $hide_site_title = (int) get_theme_mod('hide-site-title', ttfmake_get_default('hide-site-title')); $hide_tagline = (int) get_theme_mod('hide-tagline', ttfmake_get_default('hide-tagline')); $menu_label = get_theme_mod('navigation-mobile-label', ttfmake_get_default('navigation-mobile-label')); $header_bar_menu = wp_nav_menu(array('theme_location' => 'header-bar', 'container_class' => 'header-bar-menu', 'depth' => 1, 'fallback_cb' => false, 'echo' => false)); ?> <header id="site-header" class="<?php echo esc_attr(ttfmake_get_site_header_class()); ?> " role="banner"> <?php // Only show Sub Header if it has content if (!empty($header_text) || 1 === $show_search || !empty($social_links) && 1 === $show_social || !empty($header_bar_menu)) { ?> <div class="header-bar<?php echo esc_attr($subheader_class); ?> "> <div class="container"> <a class="skip-link screen-reader-text" href="#site-content"><?php
/** * Alternative output for wp_nav_menu for the 'social' menu location. * * @since 1.0.0. * * @param string $output Output for the menu. * @param object $args wp_nav_menu arguments. * @return string Modified menu. */ function ttfmake_pre_wp_nav_menu_social($output, $args) { if (!$args->theme_location || 'social' !== $args->theme_location) { return $output; } // Get the menu object $locations = get_nav_menu_locations(); $menu = wp_get_nav_menu_object($locations[$args->theme_location]); if (!$menu || is_wp_error($menu)) { return $output; } $output = ''; // Get the menu items $menu_items = wp_get_nav_menu_items($menu->term_id, array('update_post_term_cache' => false)); // Set up the $menu_item variables _wp_menu_item_classes_by_context($menu_items); // Sort the menu items $sorted_menu_items = array(); foreach ((array) $menu_items as $menu_item) { $sorted_menu_items[$menu_item->menu_order] = $menu_item; } unset($menu_items, $menu_item); /** * Filter the supported social icons. * * This array uses the url pattern for the key and the CSS class (as dictated by Font Awesome) as the array value. * The URL pattern is used to match the URL used by a menu item. * * @since 1.2.3. * * @param array $icons The array of supported social icons. */ $supported_icons = apply_filters('make_supported_social_icons', array('500px.com' => 'fa-500px', 'amazon.com' => 'fa-amazon', 'angel.co' => 'fa-angellist', 'app.net' => 'fa-adn', 'behance.net' => 'fa-behance', 'bitbucket.org' => 'fa-bitbucket', 'codepen.io' => 'fa-codepen', 'delicious.com' => 'fa-delicious', 'deviantart.com' => 'fa-deviantart', 'digg.com' => 'fa-digg', 'dribbble.com' => 'fa-dribbble', 'facebook.com' => 'fa-facebook-official', 'flickr.com' => 'fa-flickr', 'foursquare.com' => 'fa-foursquare', 'github.com' => 'fa-github', 'gittip.com' => 'fa-gittip', 'plus.google.com' => 'fa-google-plus-square', 'houzz.com' => 'fa-houzz', 'instagram.com' => 'fa-instagram', 'jsfiddle.net' => 'fa-jsfiddle', 'last.fm' => 'fa-lastfm', 'leanpub.com' => 'fa-leanpub', 'linkedin.com' => 'fa-linkedin', 'medium.com' => 'fa-medium', 'ok.ru' => 'fa-odnoklassniki', 'pinterest.com' => 'fa-pinterest', 'qzone.qq.com' => 'fa-qq', 'reddit.com' => 'fa-reddit', 'renren.com' => 'fa-renren', 'slideshare.net' => 'fa-slideshare', 'soundcloud.com' => 'fa-soundcloud', 'spotify.com' => 'fa-spotify', 'stackexchange.com' => 'fa-stack-exchange', 'stackoverflow.com' => 'fa-stack-overflow', 'steamcommunity.com' => 'fa-steam', 'stumbleupon.com' => 'fa-stumbleupon', 't.qq.com' => 'fa-tencent-weibo', 'trello.com' => 'fa-trello', 'tumblr.com' => 'fa-tumblr', 'twitch.tv' => 'fa-twitch', 'twitter.com' => 'fa-twitter', 'vimeo.com' => 'fa-vimeo-square', 'vine.co' => 'fa-vine', 'vk.com' => 'fa-vk', 'weibo.com' => 'fa-weibo', 'weixin.qq.com' => 'fa-weixin', 'wordpress.com' => 'fa-wordpress', 'xing.com' => 'fa-xing', 'yahoo.com' => 'fa-yahoo', 'yelp.com' => 'fa-yelp', 'youtube.com' => 'fa-youtube')); // Process each menu item foreach ($sorted_menu_items as $item) { // Item classes $classes = isset($item->classes) && !empty($item->classes) ? implode(' ', (array) $item->classes) : ''; // Item target $target = isset($item->target) && $item->target ? ' target="_blank"' : ''; $item_output = ''; // Look for matching icons foreach ($supported_icons as $pattern => $class) { if (false !== strpos($item->url, $pattern)) { $item_output .= '<li class="' . esc_attr(str_replace('fa-', '', $class)) . ' ' . esc_attr($classes) . '">'; $item_output .= '<a href="' . esc_url($item->url) . '"' . $target . '>'; $item_output .= '<i class="fa fa-fw ' . esc_attr($class) . '">'; $item_output .= '<span>' . esc_html($item->title) . '</span>'; $item_output .= '</i></a></li>'; break; } } // No matching icons if ('' === $item_output) { $item_output .= '<li class="external-link-square ' . esc_attr($classes) . '">'; $item_output .= '<a href="' . esc_url($item->url) . '"' . $target . '>'; $item_output .= '<i class="fa fa-fw fa-external-link-square">'; $item_output .= '<span>' . esc_html($item->title) . '</span>'; $item_output .= '</i></a></li>'; } // Add item to list $output .= $item_output; unset($item_output); } // Email & RSS $customizer_links = ttfmake_get_social_links(); if (isset($customizer_links['email'])) { $output .= '<li class="email menu-item">'; $output .= '<a href="' . esc_url($customizer_links['email']['url']) . '">'; $output .= '<i class="fa fa-fw fa-envelope">'; $output .= '<span>' . esc_html($customizer_links['email']['title']) . '</span>'; $output .= '</i></a></li>'; } if (isset($customizer_links['rss'])) { $output .= '<li class="rss menu-item">'; $output .= '<a href="' . esc_url($customizer_links['rss']['url']) . '">'; $output .= '<i class="fa fa-fw fa-rss">'; $output .= '<span>' . esc_html($customizer_links['rss']['title']) . '</span>'; $output .= '</i></a></li>'; } // If there are menu items, add a wrapper if ('' !== $output) { $output = '<ul class="' . esc_attr($args->menu_class) . '">' . $output . '</ul>'; } return $output; }
/** * Show the social links markup if the theme options and/or menus are configured for it. * * @since 1.0.0. * * @param string $region The site region (header or footer). * @return void */ function ttfmake_maybe_show_social_links($region) { if (!in_array($region, array('header', 'footer'))) { return; } $show_social = (bool) get_theme_mod($region . '-show-social', ttfmake_get_default($region . '-show-social')); if (true === $show_social) { // First look for the alternate custom menu method if (has_nav_menu('social')) { wp_nav_menu(array('theme_location' => 'social', 'container' => false, 'menu_id' => '', 'menu_class' => 'social-menu social-links ' . $region . '-social-links', 'depth' => 1, 'fallback_cb' => '')); } else { $social_links = ttfmake_get_social_links(); if (!empty($social_links)) { ?> <ul class="social-customizer social-links <?php echo $region; ?> -social-links"> <?php foreach ($social_links as $key => $link) { ?> <li class="<?php echo esc_attr($key); ?> "> <a href="<?php echo esc_url($link['url']); ?> "> <i class="fa fa-fw <?php echo esc_attr($link['class']); ?> "> <span><?php echo esc_html($link['title']); ?> </span> </i> </a> </li> <?php } ?> </ul> <?php } } } }