forked from justintadlock/breadcrumb-trail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
breadcrumb-trail.php
108 lines (91 loc) · 2.94 KB
/
breadcrumb-trail.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
/**
* Plugin Name: Breadcrumb Trail
* Plugin URI: https://themehybrid.com/plugins/breadcrumb-trail
* Description: A smart breadcrumb menu plugin embedded with <a href="http://schema.org">Schema.org</a> microdata that can handle variations in site structure more accurately than any other breadcrumb plugin for WordPress. Insert into your theme with the <code>breadcrumb_trail()</code> template tag.
* Version: 1.2.0
* Author: Justin Tadlock
* Author URI: https://themehybrid.com
* Text Domain: breadcrumb-trail
* Domain Path: /lang
*/
# Extra check in case the script is being loaded by a theme.
if ( ! function_exists( 'breadcrumb_trail' ) )
require_once( 'inc/breadcrumbs.php' );
# Plugin setup callback.
add_action( 'plugins_loaded', 'breadcrumb_trail_setup' );
# Check theme support. */
add_action( 'after_setup_theme', 'breadcrumb_trail_theme_setup', 12 );
# Polylang support
add_filter( 'pll_home_url_white_list', 'breadcrumb_trail_allow_pll_home_url' );
/**
* Plugin setup. For now, it just loads the translation.
*
* @since 1.1.0
* @access public
* @return void
*/
function breadcrumb_trail_setup() {
load_plugin_textdomain( 'breadcrumb-trail', false, trailingslashit( dirname( plugin_basename( __FILE__ ) ) ) . 'lang' );
}
/**
* Allow Polylang to filter home_url function in this plugin.
*
* @since 1.2.0
* @access public
* @return array
*/
function breadcrumb_trail_allow_pll_home_url( $allowlist ) {
return array_merge( $allowlist, array( array( 'file' => 'breadcrumbs' ) ) );
}
/**
* Checks if the theme supports the Breadcrumb Trail script. If it doesn't, we'll hook some styles
* into the header.
*
* @since 1.0.0
* @access public
* @return void
*/
function breadcrumb_trail_theme_setup() {
if ( ! current_theme_supports( 'breadcrumb-trail' ) )
add_action( 'wp_head', 'breadcrumb_trail_print_styles' );
}
/**
* Prints CSS styles in the header for themes that don't support Breadcrumb Trail.
*
* @since 1.0.0
* @access public
* @return void
*/
function breadcrumb_trail_print_styles() {
$style = '
.breadcrumbs .trail-browse,
.breadcrumbs .trail-items,
.breadcrumbs .trail-items li {
display: inline-block;
margin: 0;
padding: 0;
border: none;
background: transparent;
text-indent: 0;
}
.breadcrumbs .trail-browse {
font-size: inherit;
font-style: inherit;
font-weight: inherit;
color: inherit;
}
.breadcrumbs .trail-items {
list-style: none;
}
.trail-items li::after {
content: "\002F";
padding: 0 0.5em;
}
.trail-items li:last-of-type::after {
display: none;
}';
$style = apply_filters( 'breadcrumb_trail_inline_style', trim( str_replace( array( "\r", "\n", "\t", " " ), '', $style ) ) );
if ( $style )
echo "\n" . '<style type="text/css" id="breadcrumb-trail-css">' . $style . '</style>' . "\n";
}