File: /var/www/innodrive/migrations/export_lang.php
<?php
if( php_sapi_name() !== 'cli' ) {
die("Meant to be run from command line");
}
if (!empty($argv[1])) {
define('APPLICATION_ENV', $argv[1]);
} else {
define('APPLICATION_ENV', 'production');
}
define( 'BASE_PATH', './public/' );
define('WP_USE_THEMES', false);
global $wp, $wp_query, $wp_the_query, $wp_rewrite, $wp_did_header, $wpdb;
require(BASE_PATH . 'wp-load.php');
$translations = $wpdb->get_results('SELECT * FROM wp_postmeta WHERE meta_key = "_pll_strings_translations"');
if (!empty($translations)) {
echo 'Export translations.' . PHP_EOL;;
foreach($translations as $translation) {
$data = unserialize($translation->meta_value);
file_put_contents($translation->post_id . '.txt', json_encode($data));
echo $translation->post_id . '.txt - saved' . PHP_EOL;
}
} else {
echo 'No translations';
}