funkjedi / acf-qtranslate

Adds qTranslate compatible fields for Text, Text Area, Wysiwyg Editor and Image.
http://wordpress.org/plugins/acf-qtranslate/
57 stars 32 forks source link

Give ability to either set return preferences if language isn't found – or, return raw! #51

Open shankie-codes opened 9 years ago

shankie-codes commented 9 years ago

Hi there Funkjedi,

The plugin (very helpfully for the most part) applies the filter before the value is returned to the template using get_field(). Indeed, this is the core of the plugin!

However, in certain circumstances, I'd like to be able to control how the field is returned to the template. For instance, qTranslate-x provides the following functions to control how a given request is handled if the requested language isn't found:

qtranxf_useCurrentLanguageIfNotFoundShowEmpty() qtranxf_useCurrentLanguageIfNotFoundShowAvailable() qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage()

However, the plugin always bakes in qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage().

I'd like to be able to either set my return preferences for the field, or better yet, have the option to return the raw field content – which would then allow the developer to pass the returned raw content through the qtranxf_useCurrentLanguageIfNotFound function of his/her choosing.

Any thoughts on how to do this?

Cheers,

Andrew

puntonero commented 8 years ago

Hi, same question from me! I think that would be useful to have the option to get the raw content of a field. In my case I'm trying to write a pdf document in a different language than the one displayed in current web page. I've found a little workaround: defining and setting the value of a custom qtranslate option _$q_config['return_raw']_ changing few lines in _acf-qtranslate/src/acf5/acf.php

and

then at the bottom of acf-qtranslate/compatibility/qtranslatexs.php

Now I can get the raw content of a _acf_qtranslate_acf_5textarea and _acf_qtranslate_acf_5text using the funcion _get_fieldraw in the same way you use the already provided _getfield function, but it doesn't with the _acf_qtranslate_acf_5wysiwyg field.

I can't manage to get the raw data from this field type

Any help would be apreciated.