Skip to content

Instantly share code, notes, and snippets.

@ekandreas
Created February 12, 2018 10:54
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 ekandreas/bf920e9c81173ed373973f072995a29c to your computer and use it in GitHub Desktop.
Save ekandreas/bf920e9c81173ed373973f072995a29c to your computer and use it in GitHub Desktop.
PHP Deployer script to add language support for WordPress installations
<?php
/**
* Install WordPress languages after php deployer deploy.
* Please, set wp_languages as array with language codes!
* Support added for local development environment
*/
namespace Deployer;
use Deployer\Task\Context;
use Dotenv\Dotenv;
task('deploy:languages', function () {
$languages = get('wp_languages');
if (!is_array($languages)) {
writeln('Environment array `wp_languages` missing. No languages installed.');
return;
}
foreach ($languages as $language) {
$actions[] = "wp language core install {$language}";
}
foreach ($actions as $action) {
writeln("{$action}");
if (get('stage')=='development') {
writeln(runLocally($action));
} else {
writeln(run("cd {{deploy_path}}/current && {$action}"));
}
}
});
/**
* Add this task after global deploy recipe
*/
after('deploy', 'deploy:languages');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment