summaryrefslogtreecommitdiff
path: root/functions.php
diff options
context:
space:
mode:
Diffstat (limited to 'functions.php')
-rw-r--r--functions.php64
1 files changed, 64 insertions, 0 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';