Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm helping someone with a custom plugin and they need it to be WPML compatible. Using the method from WPML I was able to register a string in WPML and output it on the other end. However, when the plugin was initially activated I got a Call to undefined function icl_register_string() error. It worked, but threw a fatal error. Any idea why this could be? Source: http://wpml.org/documentation/support/translation-for-texts-by-other-plugins-and-themes/

Here's my code:

//Register Settings with WPML
icl_register_string( 'Match Previous Order' , 'match_order', 'Do you want these items to match a previous order from Direct Linen? If yes, use "Additional Notes" to explain.' );
share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You should always use the wpml functions as following: (the HowTo linked by you actually suggests this :-)

if( function_exists('icl_register_string') ) { icl_register_string( 'Match Previous Order' , 'match_order', 'Do you want these items to match a previous order from Direct Linen? If yes, use "Additional Notes" to explain.' ); }

This will ensure that you won't get any errors in case WPML doesn't exist in a Wordpress Installation or WPML wasn't fully loaded before your code is run (this is the case when your plugin is activated).

share|improve this answer
    
It works, thank you! –  Jeremiah Prummer Feb 15 '13 at 19:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.