This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Our next available supporter will answer your ticket in about 8.54 hours from now. Thank you for your understanding.

You are not logged in. You can view support threads, but not post.
If you are already logged in, please refresh your browser.

This topic contains 25 replies, has 3 voices, and was last updated by  benedetto 4 years ago. The support staff assigned to this topic is Harshad.

Author Posts
Author Posts
December 17, 2012 at 5:50 pm #91387


Hi guys, i have this problem:

If i assign the array of icl_get_languages() to a variable or costant ( with serialize ) within functions.php, the entire wordpress frontend crash. I can't see any output.

I have the latest version of wpml ( 2.6.2 ) and the latest version of string translator ( 1.5.2 ) and WordPress 3.5

I hope you can help me ­čÖé

December 18, 2012 at 6:15 am #91472

Forum moderator

Can you please paste the code here, that you are using in your theme functions?

December 18, 2012 at 8:47 am #91528


This is the code i use in my functions.php

define( 'TEMAURL' , get_bloginfo( 'template_url' ) );
define( 'ABSTEMA' , dirname( __FILE__ ) );
define( 'SHORTNAME' , strtolower( substr( get_bloginfo( 'name' ) , 0 , 1 ) . substr( get_bloginfo( 'name' ) , -1 ) ) );
define( 'THEMENAME' , get_bloginfo( 'name' ) );
define( 'ARRAY_LANG' , serialize( icl_get_languages() ) );
add_theme_support( 'post-thumbnails' );
add_post_type_support('page', 'excerpt');
register_nav_menu( 'topmenu', 'Top Men├╣' );

If i comment this out

define( 'ARRAY_LANG' , serialize( icl_get_languages() ) );

everything is going to work fine.

December 18, 2012 at 11:30 am #91603

Forum moderator

Dear Benedetto,

I sued the same code in my theme's functions.php file

define( 'ARRAY_LANG' , serialize( icl_get_languages() ) );

At my local install, its working fine without any crash, If I output the constant ARRAY_LANG, I can see the serialized data.

Can you please enable a PHP error log file and check what's there?

From this page:

Edit your wp-config.php file and add these lines, just before it says 'stop editing here':

ini_set('error_reporting', E_ALL);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');

This will create an error_log.txt file in your site's root directory. Let's see what it includes.

December 18, 2012 at 2:11 pm #91675


Thanks Harshad for your reply:

i did exactly what you said to do, and the only output in error_log.txt is

[18-Dec-2012 13:59:04 UTC] PHP Notice:  Undefined index: name in /web/htdocs/ on line 3569

That output is also visible when wp_debug is set to true.

If it can help you, im going to attach my home status when icl_get_languages is declared and when it is commented out.

December 19, 2012 at 6:06 am #91818

Forum moderator

Dear Benedetto,

I need to troubleshoot further, is it possible for you to send me your sites ftp and wp-admin details to my email address?

Please include this forum link for reference.

December 19, 2012 at 10:54 am #91907


Hi Harshad,

unfortunately i can't give you those details, but i can give you some information about debugging:

I tried WP 3.4.2 with the latest version of wpml and string translator, and it works fine.

Upgrading WP from 3.4.2 to 3.5 causes the crash of the frontend when i declare that define.

I suppose, then, some incompatibility with the new WP.

I'll attach my results as image and i'll send to your email the theme i'm using.

December 20, 2012 at 8:04 am #92172

Forum moderator

Dear Benedetto,

I have sent you email, with dev version WPML CMS attached, please download the attachment.

De-activate and delete existing WPML CMS version from plugins menu then upload the attached dev version and activate it.

Let me know if this helps.

December 20, 2012 at 10:33 am #92229


Ok, with the new version you sent to me, it doesn't crash in 3.5

Hovewer icl_get_languages() returns " a:0:{} " when defined in functions.php, but i guess it's not a big problem to solve ­čśÇ

The theme is always the same.

I'll attach the output.

December 20, 2012 at 1:45 pm #92307

Forum moderator

Can you switch your theme to default twenty twelve and use the code below and check?

define( 'ARRAY_LANG' , serialize( icl_get_languages() ) );
December 20, 2012 at 2:15 pm #92314


I switched to Twenty Twelve and added that code in functions.php of the theme itself at the very top ( as you can see in the attachment) ; the output is the same: " a:0:{} "

December 20, 2012 at 2:44 pm #92327

Forum moderator

That's strange at my end I can see the serialized array

December 20, 2012 at 4:13 pm #92363


Very very strange. I've installed wp 3.5 and just wpml on a remote server ( maybe wamp was not configurated properly ) and still that array is empty.

However i find that declaring

define( 'ARRAY_LANG' , serialize( icl_get_languages() ) );

outside functions.php ( like header.php ) , makes

print_r( ARRAY_LANG )

to work fine.

Also i tried this, in function.php this time:

function test(){
if( function_exists( 'icl_get_languages' ) )
	define( 'ARRAY_LANG ' , serialize( icl_get_languages() ) );

and in this case the array is NOT empty.

My issue is half resolved, by the way ­čśÇ

December 21, 2012 at 10:08 am #92603

Forum moderator
My issue is half resolved, by the way :D

Can you please let us know the pending issues

December 26, 2012 at 9:16 am #93100


Well, at the moment i can use the serialized array only when it is declared into an output hook, such as wp_head.

However declaring that costant inside functions.php, without any hook, or if i use other hooks, such as init o after_theme_setup, it doesn't make the array to be assigned ­čÖü

This is my screenshot.

You are not logged in. You can view support threads, but not post.
If you are already logged in, please refresh your browser.