Created
February 12, 2018 10:54
-
-
Save ekandreas/bf920e9c81173ed373973f072995a29c to your computer and use it in GitHub Desktop.
PHP Deployer script to add language support for WordPress installations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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