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() { +?> + + + + +
+ +
+ diff --git a/sass/theme.scss b/sass/theme.scss index 27d7d23..44d168b 100644 --- a/sass/theme.scss +++ b/sass/theme.scss @@ -25,3 +25,4 @@ @import "theme/contact-form7"; // Contact Form 7 - Bootstrap 4 support @import "theme/theme"; // <--------- That's where you can add your own design. Thats your part! @import "theme/offer"; // <--------- That's where you can add your own design. Thats your part! +@import "theme/breadcrumbs"; // <--------- That's where you can add your own design. Thats your part! diff --git a/sass/theme/_breadcrumbs.scss b/sass/theme/_breadcrumbs.scss new file mode 100644 index 0000000..140f719 --- /dev/null +++ b/sass/theme/_breadcrumbs.scss @@ -0,0 +1,16 @@ +.breadcrumb-item { + font-size: 17px; +} + +.breadcrumb { + background-color: inherit; + padding-left: 0; + align-items: left; + border-radius: inherit; +} + +@media( max-width: 768px ) { + .breadcrumb-item.current-item { + display: none; + } +} diff --git a/sass/theme/_offer.scss b/sass/theme/_offer.scss index 6f94d2d..e378637 100644 --- a/sass/theme/_offer.scss +++ b/sass/theme/_offer.scss @@ -48,7 +48,7 @@ margin-top: 20px !important; } } -@media (max-width: 767px) { +@media (max-width: 768px) { .card-header-dp-none { display: none !important; } -- cgit v1.2.3