Overview of the Issue
Catchable fatal error: Object of class stdClass could not be converted to string in /home/lahjatup/public_html/markkinointiopisto.fi/wp-content/plugins/sitepress-multilingual-cms/inc/wpml-config/wpml-config.class.php on line 252
Or
Warning: dirname() expects parameter 1 to be string, object given in /home1/treasure/public_html/dev/wp-content/plugins/sitepress-multilingual-cms/inc/wpml-config/wpml-config.class.php on line 252
The above PHP errors will appear in your Admin pages like your plugins, theme or Translation ManagementMultilingual Content Setup pages.
Workaround
This issue is fixed. Updating to the latest version solves it on your site, so you only need this workaround if you can’t update yet.
- Login via FTP
- Locate the sitepress-multilingual-cms/
inc/wpml-config/wpml-config. class.php file - Locate the line mentioned in the PHP error you see (252). For example:
$type = ( dirname( $file ) == get_template_directory() || dirname( $file ) == get_stylesheet_directory() ) ? 'theme' : 'plugin'; $admin_text_context = basename( dirname( $file ) );
- Delete both lines of code
- In the same file locate the following code (around line 210):
}else{ $config = icl_xml2array( file_get_contents( $file ) ); } - Modify this block of code to become:
}else{ $config = icl_xml2array( file_get_contents( $file ) ); $type = ( dirname( $file ) == get_template_directory() || dirname( $file ) == get_stylesheet_directory() ) ? 'theme' : 'plugin'; $admin_text_context = basename( dirname( $file ) ); } - Save the file and upload to your server