Ook proberen? Check dan ook even WPML compatibiliteit voor de zekerheid. Komende van Polyglot heb ik zelf even een hele ruwe convertor gemaakt, hieronder na de break de code. Het is Q&D dus het maakt alleen maar een SQL bestandje, gebruik op eigen risico natuurlijk 🙂
PHP code for polyglot_convert.php
$database="yourdb";
$dbuser="youruser";
$dbpassword="yourpw";
# We need 2 functions from WordPress' wp-includes/formatting
include("../wordpress/wp-includes/formatting.php");
mysql_connect("localhost",$dbuser,$dbpassword); $query='select * from wp_posts where (post_title like "%lang_nl%" OR post_content like "%lang_nl%") AND post_status="publish" AND post_type="post" ';
$result=mysql_query($query);
$i=0;
while ($i < mysql_numrows($result)) {
$title_nl=addslashes(preg_replace("/\[.?lang_nl\]/","",preg_replace("/\[lang_en\].*\[\/lang_en\]/","",mysql_result($result,$i,'post_title'))));
$title_en=addslashes(preg_replace("/\[.?lang_en\]/","",preg_replace("/\[lang_nl\].*\[\/lang_nl\]/","",mysql_result($result,$i,'post_title')))); $title_en_short=$title_en;
if ($title_nl == $title_en ) { $title_en_short=$title_en_short."2"; }
$content_nl=mysql_result($result,$i,'post_content');
$content_nl=preg_replace("/\[.?lang_nl\]/","",$content_nl);
$content_nl=preg_replace("/\[lang_en\].*?\[\/lang_en\]/sU","",$content_nl);
$content_nl=addslashes($content_nl);
$content_en=mysql_result($result,$i,'post_content');
$content_en=preg_replace("/\[.?lang_en\]/","",$content_en);
$content_en=preg_replace("/\[lang_nl\].*?\[\/lang_nl\]/sU","",$content_en);
$content_en=addslashes($content_en);
echo "UPDATE wp_posts SET post_title = '".$title_nl."', post_content = '".$content_nl."' WHERE ID=".mysql_result($result,$i,'ID')."; ","\n";
echo "INSERT INTO wp_posts SET post_title = '".$title_en."', post_content = '".$content_en."', post_date = '".mysql_result($result,$i,'post_date')."', post_date_gmt = '".mysql_result($result,$i,'post_date_gmt')."', post_author = ''.mysql_result($result,$i,'po
st_author')."', post_category = '".mysql_result($result,$i,'post_category')."', post_name = '".sanitize_title_with_dashes($title_en_short)."'; ","\n";
echo "insert into wp_icl_translations set element_type='post_post', element_id=LAST_INSERT_ID(), trid=".mysql_result($result,$i,'ID').", language_code='en', source_language_code='nl';","\n";
$i++;
}