diff options
| -rw-r--r-- | functions.php | 64 | ||||
| -rw-r--r-- | header.php | 14 | ||||
| -rw-r--r-- | sass/theme.scss | 1 | ||||
| -rw-r--r-- | sass/theme/_breadcrumbs.scss | 16 | ||||
| -rw-r--r-- | sass/theme/_offer.scss | 2 |
5 files changed, 96 insertions, 1 deletions
diff --git a/functions.php b/functions.php index 8321d02..5e3d34b 100644 --- a/functions.php +++ b/functions.php @@ -257,6 +257,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() { +?> + <style> + .wrapper { + padding-top: 0px; + } + #index-wrapper { + padding-top: 40px; + } + </style> +<?php + } + add_action('wp_head', 'breadcrumbs_dynamic_css', 99); + + /** + * Changes the breadcrumb title if a meta field with the key "bc" is set. + */ + add_filter('bcn_breadcrumb_title', function($title, $type, $id) { + + if ( ! is_null($id) ) { + $title = get_post_meta($id, "bc", true) ?: $title; + } + + return $title; + }, 42, 3); +} + +/** * Support for special offer pages. */ require_once __DIR__ . '/angebote/inc/functions.php'; @@ -122,3 +122,17 @@ $container = get_theme_mod( 'understrap_container_type' ); </div> </div> </div> + +<?php + /** + * Adds breadcrumbs navigation via plugin Breadcrumbs NavXT. + */ + if ( function_exists('bcn_display_list') && ! is_front_page() ): ?> + <div class="container"> + <nav class="breadcrumbs" typeof="BreadcrumbList" vocab="https://schema.org/" aria-label="breadcrumb"> + <ol class="breadcrumb"> + <?php bcn_display_list();?> + </ol> + </nav> + </div> + <?php endif; ?> 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; } |
