Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions PolylangHelperFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,11 @@ function pll_get_languages_list () {
*/
function pll_get_default_language_information($language_code) {
global $polylang;
require(PLL_ADMIN_INC.'/languages.php');
require(PLL_SETTINGS_INC.'/languages.php');
foreach ($languages as $language) {
if ($language[0] == $language_code || $language[1] == $language_code) {
$rtl = (count($language) > 3) && ($language[3] == 'rtl');
return array(
'code' => $language[0],
'locale' => $language[1],
'name' => $language[2],
'rtl' => $rtl
);
if ( isset($language['code']) && $language['code'] == $language_code
|| isset($language['locale']) && $language['locale'] == $language_code) {
return $language;
}
}
return null;
Expand Down Expand Up @@ -75,11 +70,11 @@ function pll_add_language($language_code, $language_order = 0, &$error_code = 0)
$info = pll_get_default_language_information($language_code);

$args = array(
name => $info['name'],
slug => $info['code'],
locale => $info['locale'],
rtl => $info['rtl'] ? 1 : 0,
term_group => $language_order
'name' => $info['name'],
'slug' => $info['code'],
'locale' => $info['locale'],
'rtl' => ($info['dir'] == 'rtl' ? 1 : 0),
'term_group' => $language_order
);
$error_code = $adminModel->add_language($args);
return $error_code !== 0;
Expand Down
3 changes: 1 addition & 2 deletions Polylang_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class Polylang_Command extends WP_CLI_Command {
*
* wp polylang languages
*
* @synopsis
* @alias langs
*/
function languages ($args, $assocArgs) {
Expand Down Expand Up @@ -150,7 +149,7 @@ function language ($args, $assocArgs) {
WP_CLI::line('Code: ' . $language_info['code']);
WP_CLI::line('Locale ' . $language_info['locale']);
WP_CLI::line('Name: ' . $language_info['name']);
WP_CLI::line('RTL: ' . ($language_info['rtl'] ? 'yes' : 'no'));
WP_CLI::line('Dir: ' . $language_info['dir']);
WP_CLI::line('Installed: ' . ($language_installed ? 'yes' : 'no'));
break;

Expand Down
14 changes: 11 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "dereckson/wp-cli-polylang",
"name": "superhuit-ch/wp-cli-polylang",
"type": "wp-cli-package",
"description": "Add a `wp polylang` command to support the Polylang plug-in",
"keywords": [
Expand All @@ -9,12 +9,20 @@
],
"homepage": "https://github.com/dereckson/wp-cli-polylang",
"license": "GPLv2",
"authors": [{
"authors": [
{
"name": "Sébastien Santoro aka Dereckson",
"email": "dereckson@espace-win.org",
"homepage": "http://www.dereckson.be",
"role": "Developer"
}],
},
{
"name": "Superhuit",
"email": "tech@superhuit.ch",
"homepage": "https://superhuit.ch",
"role": "Developer"
}
],
"require": {
"php": ">=5.3.0"
},
Expand Down