some cleanup
This commit is contained in:
parent
5a8c7fd8f6
commit
c4f7d2c5ce
@ -47,7 +47,7 @@ class WDTSLanguageOptions {
|
|||||||
|
|
||||||
$did_delete = false;
|
$did_delete = false;
|
||||||
if (isset($options['languages'][$code_to_delete])) {
|
if (isset($options['languages'][$code_to_delete])) {
|
||||||
$did_delete = true;
|
$did_delete = $options['languages'][$code_to_delete];
|
||||||
unset($options['languages'][$code_to_delete]);
|
unset($options['languages'][$code_to_delete]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,15 +240,19 @@ class WhatDidTheySayAdmin {
|
|||||||
function handle_update_languages($info) {
|
function handle_update_languages($info) {
|
||||||
$updated = false;
|
$updated = false;
|
||||||
if (current_user_can('change_languages')) {
|
if (current_user_can('change_languages')) {
|
||||||
$options = get_option('what-did-they-say-options');
|
$language_options = new WDTSLanguageOptions();
|
||||||
|
|
||||||
switch ($info['action']) {
|
switch ($info['action']) {
|
||||||
case "delete":
|
case "delete":
|
||||||
$updated = sprintf(__('%s deleted.', 'what-did-they-say'), $options['languages'][$info['code']]['name']);
|
if ($result = $language_options->delete_language($info['code'])) {
|
||||||
unset($options['languages'][$info['code']]);
|
$updated = sprintf(__('%s deleted.', 'what-did-they-say'), $result['name']);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "add":
|
case "add":
|
||||||
$this->read_language_file();
|
$this->read_language_file();
|
||||||
if (isset($this->all_languages[$info['code']])) {
|
if (isset($this->all_languages[$info['code']])) {
|
||||||
|
|
||||||
|
|
||||||
$options['languages'][$info['code']] = array('name' => $this->all_languages[$info['code']]);
|
$options['languages'][$info['code']] = array('name' => $this->all_languages[$info['code']]);
|
||||||
$updated = sprintf(__('%s added.', 'what-did-they-say'), $this->all_languages[$info['code']]);
|
$updated = sprintf(__('%s added.', 'what-did-they-say'), $this->all_languages[$info['code']]);
|
||||||
}
|
}
|
||||||
@ -274,10 +278,6 @@ class WhatDidTheySayAdmin {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ($updated !== false) {
|
|
||||||
ksort($options['languages']);
|
|
||||||
update_option('what-did-they-say-options', $options);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $updated;
|
return $updated;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ class WDTSLanguageOptionsTest extends PHPUnit_Framework_TestCase {
|
|||||||
|
|
||||||
function providerTestDeleteLanguage() {
|
function providerTestDeleteLanguage() {
|
||||||
return array(
|
return array(
|
||||||
array('de', true),
|
array('de', array('name' => 'German')),
|
||||||
array('fr', false)
|
array('fr', false)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -71,12 +71,10 @@ class WDTSLanguageOptionsTest extends PHPUnit_Framework_TestCase {
|
|||||||
$this->l->delete_language($code)
|
$this->l->delete_language($code)
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($expected_result) {
|
if ($expected_result) { unset($check[$code]); }
|
||||||
unset($check[$code]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertEquals(array(
|
$this->assertEquals(
|
||||||
'languages' => $check ),
|
array('languages' => $check),
|
||||||
get_option($this->l->key)
|
get_option($this->l->key)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user