Skip to content

Instantly share code, notes, and snippets.

@meishern
Last active December 15, 2015 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meishern/fabd02a1491fad761fff to your computer and use it in GitHub Desktop.
Save meishern/fabd02a1491fad761fff to your computer and use it in GitHub Desktop.
Wordpress options table reader for serailized data for wpml plugin
<?php
error_reporting(1);
/**
* This code will create a code for wpml-config.xml file.
* 1) Save the file and call it a.php
* 2) Upload the file to wordpress root folder (it should be in same folder as wp-config.php file and not in theme folder)
* 3) Then execute the file using http://your-domain.com/a.php?option_name=XXX
* Copy the code to line 2 of your wpml-config.xml file
* Author: Harshad Mane
* Modified t by Nick M. of kriesi.at support to include an additional layer in depth , layout for easier reading
* WPML.org
*/
?>
<?php
$option_name = $_GET['option_name'];
if ($option_name) {
require ('./wp-load.php');
$get_array = get_option($option_name);
//echo '&lt;wpml-config&gt;' . "<br />";
echo '&lt;admin-texts&gt;' . "<br />";
echo '&lt;key name="' . $option_name . '"&gt;' . "<br />";
foreach($get_array as $key => $value) {
if (is_array($value)) {
echo '&nbsp;&nbsp;&nbsp;&lt;key name="' . $key . '"&gt;' . "<br />";
foreach($value as $value1 => $value2) {
if (is_array($value2)) {
echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;key name="' . $value1 . '"&gt;' . "<br />";
foreach($value2 as $value3 => $value4) {
if (is_array($value4)) {
echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;key name="' . $value3 . '"&gt;' . "<br />";
foreach($value4 as $value5 => $value6) {
echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;key name="' . $value5 . '" /&gt;' . "<br />";
}
echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/key&gt;' . "<br />";
} else { echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;key name="' . $value3 . '" /&gt;' . "<br />";}
}
echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/key&gt;' . "<br />";
} else { echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;key name="' . $value1 . '" /&gt;' . "<br />";}
}
echo '&nbsp;&nbsp;&nbsp;&lt;/key&gt;' . "<br />";
} else { echo '&nbsp;&nbsp;&nbsp;&lt;key name="' . $key . '" /&gt;' . "<br />";}
}
echo '&lt;/key&gt;' . "<br />";
echo '&lt;/admin-texts&gt;' . "<br />";
// echo '&lt;/wpml-config&gt;';
}
else {
echo "Please enter option name!!";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment