Multisite-Language-Switcher icon indicating copy to clipboard operation
Multisite-Language-Switcher copied to clipboard

msls_options_get_permalink filter not working with WooCommerce product_cat

Open llos opened this issue 6 years ago • 5 comments

I’m using msls_options_get_permalink to control de rewrite of some custom taxonomies and it works fine. However, it doesn’t work fine with product_cat woocommerce taxnomy. It seem to be some kind of conflict with its rewrite, maybe because you can choose it from back-end? This issue has been already posted here https://wordpress.org/support/topic/msls_options_get_permalink-filter-not-working-with-woocommerce-product_cat/

llos avatar May 09 '18 09:05 llos

Hi @lloc,

Any updates regarding this problem? Is there anything we can do to help you debug this? Do you have any idea of where the problem can come from?

Thank you in advance.

llos avatar May 29 '19 14:05 llos

Hi guys, I have the same problem. I am trying to solve this problem... But I've been trying for over a year. It doesn't works with product-cat and product-tag. Even though the custom filter below, works with everything else on the website, except with WooCommerce. (Example: Sculpture Page).

filtre-msls

I'll let you know about the progress...

Tepeek avatar Sep 26 '19 15:09 Tepeek

Hi, There, it's done! I ended up finding a solution... I hope it's the right one. In my case, it works very well for product categories as well as for product tags.

Here's what I changed in the file "includes/MslsOptionsTax.php", line 128:

`/**
 * Wraps the call to get_term_link
 *
 * @param int $term_id
 *
 * @return string
 */
public function get_term_link( $term_id ) {
	if ( ! empty( $term_id ) ) {
		$taxonomy = $this->get_tax_query();
		if ( ! empty( $taxonomy ) ) {
			$link = get_term_link( $term_id, $taxonomy );
			if ( ! is_wp_error( $link ) ) {
				return $link;
			}
		}
	}
	return apply_filters( 'check_url', get_term_link( $term_id ), $this );
}`

Enjoy!

Tepeek avatar Oct 02 '19 13:10 Tepeek

Interesting would you mind to send a pull-request? Or do you prefer that just I test and integrate your code?

lloc avatar Oct 05 '19 06:10 lloc

Hi Dennis and frankly a big congratulations for your great plugin! Ok, For my part, I did tests with the latest versions of Woocommerce and WordPress; Thus that PHP 7.0.x. Now, with your approval, I would like it to be integrated in a future version of your Plugin.

I read somewhere that Woocommerce is not what you prefer... or at least you did not develop MSLS for it. Anyway, I can confirm that it works very well! For it to be perfect, maybe make sure the x-default tag:

rel="alternate" hreflang="x-default"

present everywhere, not just when there are no translations, because, for SEO rules, if an user does not find his native language, if possible, must indicate the origin language of the website. What do you think about it?

Voilà !

Tepeek avatar Oct 05 '19 10:10 Tepeek