Array Splice does not preserve "trail_end"
<p>I am a newbie and have a piece of Wordpress code which has a glitch in it.</p>

<p>Sorry if my question is silly, though the support from where I bought the theme seems to answer with a great delay.</p>

<p>I will paste it and maybe someone can help. If no one can figure out the problem I will delete the question.</p>

<p>The code adds a few changes to the <strong>breadcrumb navigation</strong> on my <a href="http://www.inutritie.ro/product/xpand-xtreme-pump/" rel="nofollow">site</a>.</p>

<p><strong>The problem I think is with this:</strong></p>

<pre><code>// Add the trail back on to the end.
$links[] = $trail['trail_end'];

// Add the new links, and the original trail's end, back into the trail.
array_splice( $trail, 1, count( $trail ) - 1, $links );
</code></pre>

<p><strong>These two line of code should add a <code>&lt;span class="trail-end"&gt;&lt;/span&gt;</code> to the end of the breadcrumbs around the words "Xpand Xtreme Pump" (in my link example)</strong></p>

<p>Here is the code:</p>

<pre><code>function woo_custom_breadcrumbs_trail_add_product_categories ( $trail ) {
    if ( ( get_post_type() == 'product' ) &amp;&amp; is_singular() ) {
        global $post;

        $taxonomy = 'product_cat';

        $terms = get_the_terms( $post-&gt;ID, $taxonomy );
        $links = array();

        if ( $terms &amp;&amp; ! is_wp_error( $terms ) ) {
            foreach ( $terms as $c ) {
                $parents = woo_get_term_parents( $c-&gt;term_id, $taxonomy, true, ', ', $c-&gt;name, array() );

                if ( $parents != '' &amp;&amp; ! is_wp_error( $parents ) ) {
                    $parents_arr = explode( ', ', $parents );

                    foreach ( $parents_arr as $p ) {
                        if ( $p != '' ) { $links[] = $p; }
                    }
                }
            }

            // Add the trail back on to the end.
            $links[] = $trail['trail_end'];


            // Add the new links, and the original trail's end, back into the trail.
            array_splice( $trail, 1, count( $trail ) - 1, $links );

        }
    }

    return $trail;
} // End woo_custom_breadcrumbs_trail_add_product_categories()
</code></pre>
