How to use get_option() without any filter?

I’m using the newest WordPress 3.3.1 and newest qTranslate 2.5.27. I have made some an AJAX script which returns a value and message in the current language.

Here I get my first problem, I solve it by sending in AJAX lang from qtrans_getLanguage() and using messages with qtrans_use($lang, '<!--:pl-->PL message<!--:--><!--:de-->DE message<!--:-->');

I have an wp_option in DB: 'example' = '<!--:pl-->polish text<!--:--><!--:de-->deutschland text<!--:-->'
and when using get_option('example') I am always getting Polish text.

I was trying to setlocale in PHP but without any positive result.

get_option() is working correctly in any php WordPress file or template, but not in my AJAX…

EDIT:
In template:

$.post('<?php echo get_bloginfo( 'template_url' ); ?>/sendmail.php', {
message: input_message,
lang: input_lang
}

In sendmail.php:

'destination_email' is set to '<!--:pl-->[email protected]<!--:--><!--:de-->[email protected]<!--:-->'

$mail = _e(get_option('destination_email'));

Always getting Polish email… even

'setlocale(LC_ALL, 'de_DE')'

Now I’m using hardcode email

$mail = qtrans_use($lang, '<!--:pl-->[email protected]<!--:--><!--:de-->[email protected]<!--:-->');

1 Answer
1

I’m guessing that you are using language tags around ‘polish textdeutschland text’ i.e. <!--:pl-->polish text<!--:--><!--:de-->deutschland text<!--:--> but that they got ignored when you posted your answer.

I’m pretty sure what you need to be doing is using the __() (which returns the translation for use in php code) and _e() (echo’s direct to screen) wordpress functions. If you look at the qTranslate support forum FAQ #14, he uses the example:

<?php _e("<!--:en-->english text<!--:--><!--:de-->german text<!--:-->"); ?> 

In your case I think you want to use:

<?php __(get_option('example')); ?>

This is assuming that you are using it within your plugin. If you’re using it in a page template you’d use:

<?php _e(get_option('example')); ?>

Leave a Comment