Forum Replies Created

Viewing 14 replies - 1 through 14 (of 14 total)
  • Thread Starter dbriard

    (@dbriard)

    Hi Chouby,

    I forgot to thank you for the reply, I will take a look at pll_translation_url, which I didn’t know about.

    Thanks!

    Thread Starter dbriard

    (@dbriard)

    I’ve found where the problem is and a workaround.

    in links-permalinks.php

    When PageBuilder is disabled:

    get_translated_post_types:
    Array
    (
        [post] => post
        [page] => page
        [attachement] => attachment
        [0] => product
        [1] => cookielawinfo
    )
    
    get_translated_taxonomies:
    Array
    (
        [category] => category
        [post_tag] => post_tag
        [0] => product_cat
        [1] => product_tag
        [2] => product_shipping_class
        [3] => pa_print-size
        [4] => pa_finish
        [5] => city
        [6] => country
        [7] => camera
        [8] => lens
        [9] => region
        [10] => location
        [11] => aspect
        [12] => treatment
        [13] => keyword
    )
    
    get_filtered_taxonomies:
    Array
    (
        [post_format] => post_format
    )

    When it is enabled:

    get_translated_post_types:
    Array
    (
        [post] => post
        [page] => page
        [attachement] => attachment
    )
    
    get_translated_taxonomies:
    Array
    (
        [category] => category
        [post_tag] => post_tag
    )
    
    get_filtered_taxonomies:
    Array
    (
        [post_format] => post_format
    )

    My workaround is to add the missing types in function.php of my theme

    function fix_rewrite_rules($types) {
    	$force_rewrite = array('product', 'country', 'aspect', ...);
    	$types = array_merge($force_rewrite, $types);
    	return $types;
    }
    
    if (function_exists('pll_get_post')) {
    add_action( 'pll_rewrite_rules', 'fix_rewrite_rules');
    }

    Do you know if it is a problem related to Polylang or PageBuilder?

    Thread Starter dbriard

    (@dbriard)

    Well, I disabled all the plugins except woocommerce and polylang, then reactivated plugins one by one.

    The problem appear when SiteOrigin-PageBuilder is a active! I will look at it more in depth and notify you if I fix the issue.

    Thread Starter dbriard

    (@dbriard)

    Hi Hyyan and thanks for the replies!

    I tried to disable all the plugin then reactive one by one and it look like its because of SiteOrigin-PageBuilder – the first plugin I ever installed.

    I also discover that the problem is related to rewrite rules.

    When I activate Polylang (with your plugin disabled) for the first time. I have a lot of rules such as:

    [(fr)/product/([^/]+)(/[0-9]+)?/?$] => index.php?product=$matches[2]&page=$matches[3]

    But if rules are flushed (for exemple, if I save on Permalinks page), all the Polylang rules are removed (or not added anymore) of the $wp_rewrite->rules array.

    Pages and posts translation still work, but all custom taxonomies translation not not work anymore, so its not related to WooCommerce as I thinked in the first place.

    You can close the ticket as it is not related to polylang/woocommerce or your plugin.

    By the way, if you know how to fix that issue, don’t hesitate πŸ˜‰

    Best regards and thanks a lot!

    Thread Starter dbriard

    (@dbriard)

    After more search, it look like its related to rewrite rules.

    When I activate Polylang for the first time. I have a lot of rules such as:

    [(fr)/product/([^/]+)(/[0-9]+)?/?$] => index.php?product=$matches[2]&page=$matches[3]

    But if rules are flushed (for exemple, if I save on Permalinks page), all the Polylang rules are removed (or not added anymore) of the $wp_rewrite->rules array.

    Pages and posts translation still work, but all custom taxonomies translation not not work anymore. So its not related to WooCommerce.

    Is this a know problem in Polylang?
    Is there something I can do?

    Thread Starter dbriard

    (@dbriard)

    Here are more information.

    I added add_action( ‘pre_get_posts’, ..) in my theme function.php and printed $query->query_vars;

    When it worked:

    Array
    (
        [page] =>
        [product] => print-eiffel-tower
        [post_type] => product
        [name] => print-eiffel-tower
        [attachment] =>

    When it don’t work:

    Array
    (
        [attachment] => tirage-tour-eiffel

    I have no idea why….

    Thread Starter dbriard

    (@dbriard)

    Here are more information.

    I added add_action( ‘pre_get_posts’, ..) in my theme function.php and printed $query->query_vars;

    When it worked:

    Array
    (
        [page] =>
        [product] => print-eiffel-tower
        [post_type] => product
        [name] => print-eiffel-tower
        [attachment] =>

    When it don’t work:

    Array
    (
        [attachment] => tirage-tour-eiffel

    I have no idea why….

    Thread Starter dbriard

    (@dbriard)

    Yes I am using a plugin called Types to categorize my images with taxonomies such as keyword (hierarchical), country, city…. And I modified my thΓ¨me to display dynamic galleries as archives based on these taxonomies. For example: http://www.davidbriard.com/fr/city/paris-fr

    Types plugin: https://ww.wp.xz.cn/plugins/types/

    Thread Starter dbriard

    (@dbriard)

    Hi, thanks for your help!

    I changed your terms_clauses function by adding:

    if ($_GET['lang'] == 'undefined' && isset($_GET['pll_post_id']) && is_numeric($_GET['pll_post_id']))
    $lang = $this->model->get_post_language($_GET['pll_post_id']);

    here:

    // FIXME can we simplify how we deal with the admin language filter?
    // the language filter selection has just changed
    // test $screen->base to avoid interference between the language filter and the post language selection and the category parent dropdown list
    elseif (!empty($_GET['lang']) && !(isset($screen) && in_array($screen->base, array('post', 'edit-tags')))) {
    if ($_GET['lang'] == 'undefined' && isset($_GET['pll_post_id']) && is_numeric($_GET['pll_post_id']))
    $lang = $this->model->get_post_language($_GET['pll_post_id']);
    elseif ($_GET['lang'] != 'all')
    $lang = $this->model->get_language($_GET['lang']);
    elseif ($screen->base == 'edit-tags' && isset($args['class']))
    $lang = $this->pref_lang; // parent dropdown
    }

    I am not sure if it had side-effects… but it works for images.

    The non filtering of images-taxonomy, is that a bug? or something that you can fix in future builds? So that I will not need to modify after each update.

    I really don’t understand why posts attached to media have a different behavior than normal posts in regards to $_GET[‘lang’].

    Thank you. You can consider this post as resolved πŸ™‚

    Thread Starter dbriard

    (@dbriard)

    Awesome!

    The two tick icons made me think that both langages was set, but in fact none was set πŸ™‚

    That work perfectly now, thank you!

    I will keep improving by translating the taxonomy with the image at the same time.

    Thank a lot!

    Thread Starter dbriard

    (@dbriard)

    Ok, thanks for your awswer, I will continue to duplicate.

    Thread Starter dbriard

    (@dbriard)

    Hi,
    Thanks for the clue.

    I am looking into terms_clauses.
    It look like for media, the language cannot be retrieved.

    On both pages, $lang is set on line 571, after the comment
    // FIXME can we simplify how we deal with the admin language filter?

    In Edit Post page, $_GET[‘lang’] return “fr”;
    In Edit Media page, $_GET[‘lang’] return “undefined”;

    Any idea how to get the right value in $lang for media? I mean the value in the Language panel drop down list?

    The only value with ‘fr’ seems to be $this->pref_lang but I think it is related to the topmost drop down list.

    Best regards,

    Thread Starter dbriard

    (@dbriard)

    Hi Chrystl,
    Thanks a lot! I did not see that option :$

    Thread Starter dbriard

    (@dbriard)

    Thanks a lot for your reply.
    I hope the idea is on a good position on your todo list πŸ˜‰
    And I will take a look at your code to try to deal with my images.

Viewing 14 replies - 1 through 14 (of 14 total)