Support » Plugin: Breadcrumb NavXT » Compatibility with WPML – @language is shown

  • Resolved jsrobillard

    (@jsrobillard)


    Hi,

    Using WPML, when taxonomies are spelled exactly the same in 2 languages (i.e. “Documents”), WPML appends @language to the taxonomy name.

    As example:
    English: Documents
    French : Documents @fr (@fr is added automatically by WPML)

    >> Breadcrumbs NavXT returns “Documents @fr” in the displayed path.

    Questions/Comments:

    1. Is there a fix for that?
    2. I’ve managed to “patch” Breadcrumb NavXT file to fix the issue. I would like to see this (or another) fix implemented in a future version.

    Here’s the patch i’ve added:

    I’ve simply replaced $term->name by str_replace('@'.ICL_LANGUAGE_CODE, '', $term->name).

    /breadcrumb_navxt/class.bcn_breadcrumb_trail.php (line: 450)
    $breadcrumb = $this->add(new bcn_breadcrumb($term->name, $this->opt['H' . $term->taxonomy . '_template_no_anchor'], array('archive', 'taxonomy', $term->taxonomy, 'current-item'), NULL, $term->term_id));

    by:

    $breadcrumb = $this->add(new bcn_breadcrumb(str_replace('@'.ICL_LANGUAGE_CODE, '', $term->name), $this->opt['H' . $term->taxonomy . '_template_no_anchor'], array('archive', 'taxonomy', $term->taxonomy, 'current-item'), NULL, $term->term_id));

    Thanks for your input.

    https://wordpress.org/plugins/breadcrumb-navxt/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter jsrobillard

    (@jsrobillard)

    Actually, I’ve switched my patch to the constructor in:

    /breadcrumb_navxt/class.bnc_breadcrumb.php (line: 57)

    //Set the title
    $this->set_title(str_replace('@'.ICL_LANGUAGE_CODE, '', $title));

    Probably a better place… What do you think?

    Plugin Author John Havlik

    (@mtekk)

    For the time being, you probably will be better served by using the bcn_breadcrumb_title filter for the str_replace code. See http://mtekk.us/code/breadcrumb-navxt/breadcrumb-navxt-doc/2/#filter_reference for more information on the currently available filters in Breadcrumb NavXT. That way with new releases you won’t lose your code.

    That said, I need to update the WPML compatibility extensions plugin, but I don’t have time to look at it until May.

    Thread Starter jsrobillard

    (@jsrobillard)

    Thanks for the input.
    I’ve added the filter.

    Here’s the code for reference.
    Added in theme’s function.php file.

    /**
     * breadcrumb_NavXT_WPML_duplicate_taxonomies_patch
     *
     * Using WPML, when taxonomies are spelled exactly the same in 2 languages (i.e. "documents"), WPML appends @language to the taxonomy name.
     * This filter strips it from the displayed name.
     *
     * @param string $title The title.
     * @return string The title stripped of @language.
     */
    function breadcrumb_NavXT_WPML_duplicate_taxonomies_patch( $name ){
    	$name = str_replace('@'.ICL_LANGUAGE_CODE, '', $name);
    	return $name;
    }
    add_filter('bcn_breadcrumb_title', 'breadcrumb_NavXT_WPML_duplicate_taxonomies_patch');

    Thanks again.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Compatibility with WPML – @language is shown’ is closed to new replies.