File: /var/www/innodrive/migrations/import_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 = [5, 6];
if (!empty($translations)) {
echo 'Import translations.' . PHP_EOL;;
foreach($translations as $postId) {
$content = file_get_contents($postId . '.txt');
$data = json_decode($content, true);
update_post_meta($postId, '_pll_strings_translations', $data);
echo $postId . '.txt - imported' . PHP_EOL;
}
} else {
echo 'No translations';
}