2017 © Pedro Peláez
 

library wp-breadcrumbs

A library for WordPress breadcrumbs.

image

inc2734/wp-breadcrumbs

A library for WordPress breadcrumbs.

  • Friday, July 27, 2018
  • by inc2734
  • Repository
  • 1 Watchers
  • 2 Stars
  • 1,757 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 16 Versions
  • 21 % Grown

The README.md

WP Breadcrumbs

CI Latest Stable Version License, (*1)

Install

composer require inc2734/wp-breadcrumbs

How to use

<?php
$breadcrumbs = new Inc2734\WP_Breadcrumbs\Bootstrap();
$items = $breadcrumbs->get();
?>
<div class="c-breadcrumbs">
    <div class="container">
        <ol class="c-breadcrumbs__list" itemscope itemtype="http://schema.org/BreadcrumbList">
            <?php foreach ( $items as $key => $item ) : ?>
                <li class="c-breadcrumbs__item" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
                    <?php if ( empty($item['link']) ) : ?>
                        <span itemscope itemtype="http://schema.org/Thing" itemprop="item">
                            <span itemprop="name"><?php echo esc_html( $item['title'] ); ?></span>
                        </span>
                    <?php else : ?>
                        <a itemscope itemtype="http://schema.org/Thing" itemprop="item" href="<?php echo esc_url( $item['link'] ); ?>">
                            <span itemprop="name"><?php echo esc_html( $item['title'] ); ?></span>
                        </a>
                    <?php endif; ?>
                    <meta itemprop="position" content="<?php echo esc_attr( $key + 1 ); ?>" />
                </li>
            <?php endforeach; ?>
        </ol>
    </div>
</div>

Filters

Some filters are available if you need to change wp-breadcrumbs behavior., (*2)

/**
 * Filter items
 */
add_filter(
    'inc2734_wp_breadcrumbs',
    function( $items ) {
        // Do something here
        return $items;
    }
);
/**
 * Add link attribute for the last item (default: true)
 */
add_filter( 'inc2734_wp_breadcrumbs_remove_last_link', '__return_false' );
/**
 * Change the taxonomy used in the breadcrumb (default: first taxonomy attached)
 */
add_filter(
    'inc2734_wp_breadcrumbs_main_taxonomy',
    function( $first_post_type_taxonomy, $taxonomies, $post_type_object ) {
        // Logic to set the primary taxonomy of your post type if it has multiple ones
        if ( 'product' === $post_type_object->name ) {
            return 'my_main_product_taxonomy';
        }
        return $first_post_type_taxonomy;
    },
    10,
    3
);
/**
 * If a post (post, CPT, etc.) has more than one term, this filter provides a way to set the main term
 */
add_filter(
    'inc2734_wp_breadcrumbs_main_term',
    function( $main_term, $terms, $taxonomy, $post_id ) {
        // Example with the SEO Framework plugin
        $tsf_main_term = get_post_meta( $post_id, sprintf( '_primary_term_%s', $taxonomy ), true );
        return $tsf_main_term ? get_term( $tsf_main_term ) : $main_term;
    },
    10,
    3
);

The Versions

04/03 2018

1.0.2

1.0.2.0

A library for WordPress breadcrumbs.

  Sources   Download

GPL-2.0-or-later

The Requires

  • php >=5.6

 

The Development Requires

04/03 2018

1.0.1

1.0.1.0

A library for WordPress breadcrumbs.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.6

 

The Development Requires

09/01 2018

1.0.0

1.0.0.0

A library for WordPress breadcrumbs.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.6

 

The Development Requires

29/09 2017

0.3.2

0.3.2.0

A library for WordPress breadcrumbs.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.6

 

The Development Requires

23/07 2017

0.3.1

0.3.1.0

A library for WordPress breadcrumbs.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.6

 

The Development Requires

21/07 2017

0.3.0

0.3.0.0

A library for WordPress breadcrumbs.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.6

 

The Development Requires

16/07 2017

0.2.2

0.2.2.0

A library for WordPress breadcrumbs.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.6

 

The Development Requires

29/06 2017

0.2.1

0.2.1.0

A library for WordPress breadcrumbs.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.6

 

The Development Requires

13/06 2017

dev-develop

dev-develop

A library for WordPress breadcrumbs.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3

 

The Development Requires

13/06 2017

0.2.0

0.2.0.0

A library for WordPress breadcrumbs.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3

 

The Development Requires

10/02 2017

0.1.3

0.1.3.0

A library for WordPress breadcrumbs.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3

 

The Development Requires

10/02 2017

0.1.2

0.1.2.0

A library for WordPress breadcrumbs.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3

 

The Development Requires

10/02 2017

0.1.1

0.1.1.0

A library for WordPress breadcrumbs.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3

 

The Development Requires

10/02 2017

v0.1.0

0.1.0.0

A library for WordPress breadcrumbs.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3

 

The Development Requires