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