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

Add hooks for terms #39

Closed
wants to merge 19 commits into
base: master
from

Conversation

Projects
None yet
7 participants
@soft79
Copy link

soft79 commented Feb 24, 2015

get_terms will translate all terms (for example for the tag cloud)
term_description will translate the term description (for example for themes that show the WooCommerce product category description)

Add hooks for terms
get_terms will translate all terms (for example for the tag cloud)
term_description will translate the term description (for example for themes that show the WooCommerce product category description)
@@ -225,6 +225,9 @@ function qtranxf_wpseo_replacements($replacements){
add_filter('link_description', 'qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage',0);
add_filter('the_author', 'qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage',0);
add_filter('get_terms', 'qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage',0);

This comment has been minimized.

@johnclause

johnclause Feb 27, 2015

Member

Filter 'get_terms' is already in the code at line 484 in qtranslate_frontend.php. Did you test it, btw? Since terms are translated with a different method other than useCurrentLanguageIfNotFoundUseDefaultLanguage and I do not see how your filter can work.

This comment has been minimized.

@soft79

soft79 Feb 27, 2015

Author

I did test it. It probably works here because I imported the terms with my W2Q: WPML to qTranslate tool and I wasn't aware that terms were translated a different way. Any reason why terms are treated differently?

This comment has been minimized.

@johnclause

johnclause Feb 27, 2015

Member

Yes, translations of terms are stored differently in database.

@@ -225,6 +225,9 @@ function qtranxf_wpseo_replacements($replacements){
add_filter('link_description', 'qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage',0);
add_filter('the_author', 'qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage',0);
add_filter('get_terms', 'qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage',0);
add_filter('term_description', 'qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage',0);

This comment has been minimized.

@johnclause

johnclause Feb 27, 2015

Member

Hi, josk79. could you point me to a place with a complimentary calls to apply_filters('term_description') in the WP code?

This comment has been minimized.

@soft79

soft79 Feb 27, 2015

Author

See /wp-includes/default-filters.php lines 40 and 112

This comment has been minimized.

@johnclause

johnclause Feb 27, 2015

Member

This is add_filter, not apply_filter. Where is apply_filter?

This comment has been minimized.

@soft79

soft79 Feb 27, 2015

Author

Well it's a bit of a cascade:

wp-includes\category-template.php:1230 calls:
$description = get_term_field( 'description', $term, $taxonomy );

which calls wp-includes\taxonomy.php:1503
return sanitize_term_field($field, $term->$field, $term->term_id, $taxonomy, $context);

which calls wp-includes\taxonomy.php:2276:
apply_filters( "term_{$field}", $value, $term_id, $taxonomy, $context );

This comment has been minimized.

@johnclause

johnclause Feb 27, 2015

Member

I am glad you found it. Thanks a lot! I will put it in _front.php

This comment has been minimized.

@soft79

soft79 Feb 27, 2015

Author

this little trick did it for me:

add_filter('term_description', 
 function()
 {
    debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
    die();
 }, 0);

This comment has been minimized.

@johnclause

johnclause Feb 27, 2015

Member

Perfect! I wanted to see what arguments are passed. Just in case...

mweimerskirch and others added some commits Feb 25, 2015

Load translations manually in the widget constructor, because otherwi…
…se the translations are not available inside the constructor

Fixes #43
Update admin_utils.php
Replaced mysql_real_escape_string with $wpdb->prepare to avoid errors happening under PHP 5.5
Update localization in native pt language
Corrected country flag for original 'pt' localization
Corrected text and localization codes from Brazil to native Portuguese (pt_BR to pt_PT)
WordPress have 'pt' and 'pt_BR', pt as native PT and uses _BR sufix for Brazil localization.
Bugfix for highlighting translatable fields
* Textarea was not highlighted in Text mode, and in Visual mode only if it was already in Visual mode on page load
* Also fixes the problem of the class name being added multiple times
@tyteen4a03

This comment has been minimized.

Copy link

tyteen4a03 commented Mar 19, 2015

How do I disable this behaviour temporarily? remove_filter seemed to have no effect.

@johnclause

This comment has been minimized.

Copy link
Member

johnclause commented Mar 19, 2015

@tyteen4a03: which filter? which behaviour? This issue is awfully obsolete and outdated. Please, open a new issue with a step-by-step description of how to reproduce your specific problem.

@johnclause johnclause closed this Mar 19, 2015

@herrvigg herrvigg referenced this pull request Jun 21, 2018

Closed

Add hooks for terms #39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.