Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Product archive description not translated #2

Closed
soft79 opened this issue Mar 7, 2015 · 8 comments
Closed

Product archive description not translated #2

soft79 opened this issue Mar 7, 2015 · 8 comments

Comments

@soft79
Copy link

soft79 commented Mar 7, 2015

WooCommerce fetches the archive content this way:

wc-template-functions.php function woocommerce_product_archive_description():

$shop_page   = get_post( wc_get_page_id( 'shop' ) );
if ( $shop_page ) {
    $description = wc_format_content( $shop_page->post_content );
    if ( $description ) {
        echo '<div class="page-description">' . $description . '</div>';
    }
}

If displayed by the theme, you see the [:en]raw[:] content.

changing WooCommerce to do it this way fixes the issue:
$description = wc_format_content( apply_filters('the_content', $shop_page->post_content) );

but can it be fixed by adding some kind of hook in WooCommerce qTranslate X ?

@johnclause
Copy link
Member

Hi @josk79, I could not find an existent filter to enable for this case so far. Could you test on your configuration, to change function in woocommerce/includes/wc-formatting-functions.php

function wc_format_content( $string ) {
return do_shortcode( shortcode_unautop( wpautop( $string ) ) );
}

as this

function wc_format_content( $string ) {
return apply_filters('woocommerce_format_content', do_shortcode( shortcode_unautop( wpautop( $string ) ) ));
}

and then add 'woocommerce_format_content' to the array $use_filters in woocommerce-qtranslate-x/qwc-front.php.

If this works well for you, submit this change to https://github.com/woothemes/woocommerce, they are friendly on new filters and their next release will have it.

@johnclause
Copy link
Member

Actually, when you submit to Woocommerce, this version would be more flexible, just in case:

function wc_format_content( $string ) {
$w=wpautop( $string );
$s=shortcode_unautop( $w );
return apply_filters('woocommerce_format_content', do_shortcode($s), $string, $w, $s);
}

@soft79
Copy link
Author

soft79 commented Mar 7, 2015

I made a copy/paste error in the solution in the first post, just fixed it.

What do you think about this:
wc_format_content( apply_filters('the_content', $shop_page->post_content) );

@johnclause
Copy link
Member

This they may oppose, since it may have an effect on others.

@johnclause
Copy link
Member

It is safe to make a change that does nothing to the current users, otherwise they will be hesitant. A new filter at that place would be fine, but I think my version is more advantageous to us and possibly to others since it provides a common flexibility.

@johnclause
Copy link
Member

Besides, there might be other uses of wc_format_content, including their future development, which we have not caught yet, but some day somebody will ;)

@soft79
Copy link
Author

soft79 commented Mar 7, 2015

Yes you're right. That makes sense...

@soft79
Copy link
Author

soft79 commented Mar 9, 2015

Closed in woocommerce/woocommerce@09bee8c

@soft79 soft79 closed this as completed Mar 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants