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

closed as off-topic by Pieter Goosen, Johannes Pille, s_ha_dum Oct 3 at 16:18

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

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

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