Breadcrumb NavXT 7.4.0

Holy incremental improvements Batman! This second feature release of 2024 introduces the bcn_admin_post_root_args filter. This filter adds the ability to modify the arguments passed into wp_dropdown_pages() for the root page selection for the posts in the Breadcrumb NavXT settings page.

On the bugfix front, the cause of the “Function _load_textdomain_just_in_time was called incorrectly” notice in WordPress 6.7 was fixed. Additionally, two bugs relating to breadcrumb trail generation on the home page when in the loop and when using the Breadcrumb Trail block in the block theme editor. Speaking of the Breadcrumb Trail block, two typos in two of the strings in the Breadcrumb Trail block were fixed. Lastly, bcn_breadcrumb_trail::post_hierarchy() was improved to be more resilient to unexpected returns from get_post().

Lastly, as a final reminder, in the next release of Breadcrumb NavXT (7.5.0) the bcn_breadcrumb::title_trim function will be removed. This is in alignment with the deprecation schedule for the title_trim function outlined back in 2021.

-John Havlik

Breadcrumb NavXT 7.3.1

This is the first, and hopefully only, bug fix release of the 7.3 branch of Breadcrumb NavXT. This release features three bug fixes. Two bugs involving the new behavior of $force when used on breadcrumb trails called within the loop were fixed. The first caused the incorrect template to be used when $force was set to false. The second bug was the $force parameter was not always passed into the bcn_breadcrumb_trail::fill() function. Lastly, an incorrect translation textdomain within adminKit was fixed.

-John Havlik

Breadcrumb NavXT 7.3.0

Holy revamped block Batman! Introduced originally in 6.3.0, the Breadcrumb Trail block has been rewritten in 7.3.0 to have feature parity with the Breadcrumb NavXT widget. This includes the ability to set the breadcrumb output order, output format, and whether or not the breadcrumbs are linked. Additionally, basic styling support via the editor was added.

On the bugfix front, the settings export/import function was updated to fix issues with handling boolean settings. Previously, if a boolean had a default value of ‘true’ it’s value would get lost in the export/import process. The recently introduced $outer_template parameter for the bcn_display() functions now actually works (it accidentally was dropped). display_json_ld() now produces unescaped Unicode JSON, which is easier to read (and given JSON is supposed to be Unicode text, escaping Unicode didn’t make sense). Lastly, a couple of data sanity checks are performed to reduce PHP warnings and errors when 3rd party code breaks the WordPress API.

-John Havlik

Customizing the Separator Based on Position Within Breadcrumb Trail

With Breadcrumb NavXT 7.0, updates to the internals of the plugin added support for more than a single dimension for the breadcrumb trail, allowing portions of the plugin to be cleaned up. As a consequence, non-hierarchical terms now are separated by an actual separator that is controllable. While this separator was not exposed in the settings page, Breadcrumb NavXT 7.2 introduced the bcn_display_separator filter which allows us to control the breadcrumb separator.

The combination of these two features allows new breadcrumb trails that were only possible with lists and CSS in the past. Which, while a valid method, can be a little clunky.

An Example

Suppose the site design requires changing the last separator for non-hierarchical terms (e.g. tags) from the default , to & resulting in a breadcrumb trail for an example post to look like:

Home > Blog > Tag 1, Tag 2 & Tag 3 > Awesome Post

To accomplish this, the bcn_display_separator filter can be used to dynamically replace the separator. Below is an example implementation that does just that:

add_filter('bcn_display_separator', my_bcn_separator, 10, 4);
function my_bcn_separator($separator, $position, $last_position, $depth)
{
    //On the 2nd level and lower, change the last separator to an ampersand
    if($depth > 1 && $position == $last_position - 1)
    {
        return ' & ';
    }
    return $separator;
}

This code will, for any breadcrumb that is beyond the first dimension/level (indicated by $depth) set the separator to & before the final breadcrumb in that dimension/level. Using this code is straightforward, just place it in a site specific plugin (and activate the site specific plugin if it isn’t already active). Naturally, the example code can be modified to use a different separator and to target different positions within the breadcrumb trail, should that be required.

-John Havlik