From b54bc0d070ca21a1ec9c8a46da08ec3fb88a7bb8 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 28 Feb 2019 16:58:53 +0100 Subject: Adds support for breadcrumbs navigation. --- functions.php | 64 ++++++++++++++++++++++++++++++++++++++++++++ header.php | 14 ++++++++++ sass/theme.scss | 1 + sass/theme/_breadcrumbs.scss | 16 +++++++++++ sass/theme/_offer.scss | 2 +- 5 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 sass/theme/_breadcrumbs.scss diff --git a/functions.php b/functions.php index 8321d02..5e3d34b 100644 --- a/functions.php +++ b/functions.php @@ -256,6 +256,70 @@ if ( ! function_exists("get_my_clean_title")) { } +/** + * If the plugin Breadcrumb NaXT is installed and active, this function adds support for bootstrap-styled breadcrumbs. + */ +if( function_exists('bcn_display_list') ) { + function my_display_attributes_filter($attribs, $types, $id) { + $extra_attribs = array('class' => array('breadcrumb-item')); + //For the current item we need to add a little more info + if(is_array($types) && in_array('current-item', $types)) + { + $extra_attribs['class'][] = 'active'; + $extra_attribs['aria-current'] = array('page'); + } + $atribs_array = array(); + preg_match_all('/([a-zA-Z]+)=["\']([a-zA-Z0-9\-\_ ]*)["\']/i', $attribs, $matches); + if(isset($matches[1])) + { + foreach ($matches[1] as $key => $tag) + { + if(isset($matches[2][$key])) + { + $atribs_array[$tag] = explode(' ', $matches[2][$key]); + } + } + } + $merged_attribs = array_merge_recursive($atribs_array , $extra_attribs); + $output = ''; + foreach($merged_attribs as $tag => $vals) + { + $output .= sprintf(' %1$s="%2$s"', $tag, implode(' ', $vals)); + } + return $output; + } + add_filter('bcn_display_attributes', my_display_attributes_filter, 10, 3); + + /** + * Reduces padding when breadcrumbs are visible (not on the front page). + */ + function breadcrumbs_dynamic_css() { +?> + + + + +