rework editing of languages
This commit is contained in:
parent
41609b8ae2
commit
e90da61002
|
@ -31,6 +31,7 @@ class WhatDidTheySayAdmin {
|
||||||
if (isset($_REQUEST['wdts'])) {
|
if (isset($_REQUEST['wdts'])) {
|
||||||
if (isset($_REQUEST['wdts']['_nonce'])) {
|
if (isset($_REQUEST['wdts']['_nonce'])) {
|
||||||
if (wp_verify_nonce($_REQUEST['wdts']['_nonce'], 'what-did-they-say')) {
|
if (wp_verify_nonce($_REQUEST['wdts']['_nonce'], 'what-did-they-say')) {
|
||||||
|
|
||||||
$this->handle_update($_REQUEST['wdts']);
|
$this->handle_update($_REQUEST['wdts']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,18 +5,61 @@
|
||||||
|
|
||||||
<h3><?php _e('Languages', 'what-did-they-say') ?></h3>
|
<h3><?php _e('Languages', 'what-did-they-say') ?></h3>
|
||||||
|
|
||||||
<ul id="language-holder">
|
<table class="widefat fixed">
|
||||||
|
<tr class="thead">
|
||||||
|
<th scope="col" class="manage-col"><?php _e('Language', 'what-did-they-say') ?></th>
|
||||||
|
<th scope="col" class="manage-col"><?php _e('Default?', 'what-did-they-say') ?></th>
|
||||||
|
<th scope="col" class="manage-col"><?php _e('Rename?', 'what-did-they-say') ?></th>
|
||||||
|
<th scope="col" class="manage-col"><?php _e('Make default?', 'what-did-they-say') ?></th>
|
||||||
|
<th scope="col" class="manage-col"><?php _e('Delete?', 'what-did-they-say') ?></th>
|
||||||
|
</tr>
|
||||||
<?php foreach ($options['languages'] as $code => $info) {
|
<?php foreach ($options['languages'] as $code => $info) {
|
||||||
$default = isset($info['default']);
|
$default = isset($info['default']);
|
||||||
$name = $info['name'];
|
$name = $info['name'];
|
||||||
?>
|
?>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">
|
||||||
|
<span><?php echo $name ?></span>
|
||||||
|
<form method="post" style="display: none">
|
||||||
|
<input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
|
||||||
|
<input type="hidden" name="wdts[code]" value="<?php echo $code ?>" />
|
||||||
|
<input type="hidden" name="wdts[action]" value="rename" />
|
||||||
|
<input type="text" name="wdts[name]" value="<?php echo $name ?>" style="width: 50%" />
|
||||||
|
<input type="submit" class="button" value="Rename" />
|
||||||
|
</form>
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
<?php if ($default) { _e('(yes)', 'what-did-they-say'); } ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a class="rename button" href="#"><?php _e('Rename', 'what-did-they-say') ?></a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<form method="post">
|
||||||
|
<input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
|
||||||
|
<input type="hidden" name="wdts[code]" value="<?php echo $code ?>" />
|
||||||
|
<input type="hidden" name="wdts[action]" value="default" />
|
||||||
|
<input type="submit" class="button" value="<?php _e('Default', 'what-did-they-say') ?>" />
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<form method="post" class="verify">
|
||||||
|
<input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
|
||||||
|
<input type="hidden" name="wdts[code]" value="<?php echo $code ?>" />
|
||||||
|
<input type="hidden" name="wdts[action]" value="delete" />
|
||||||
|
<input type="submit" class="button" value="<?php _e('Delete', 'what-did-they-say') ?>" />
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php } ?>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h3><?php _e('Authorized Users', 'what-did-they-say') ?></h3>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<?php foreach (get_users_of_blog() as $user) { ?>
|
||||||
<li>
|
<li>
|
||||||
<strong>
|
<strong><?php echo $user->display_name ?></strong>
|
||||||
<?php echo $name ?>
|
|
||||||
<?php if ($default) { _e('(default)', 'what-did-they-say'); } ?>
|
|
||||||
</strong>
|
|
||||||
| <a href="<?php echo add_query_arg(array('wdts[code]' => $code, 'wdts[action]' => 'default'), $nonce_url) ?>"><?php _e('Default', 'what-did-they-say') ?></a>
|
|
||||||
| <a class="verify" href="<?php echo add_query_arg(array('wdts[code]' => $code, 'wdts[action]' => 'delete'), $nonce_url) ?>"><?php _e('Delete', 'what-did-they-say') ?></a>
|
|
||||||
</li>
|
</li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -27,12 +70,23 @@
|
||||||
|
|
||||||
var language_map = { <?php echo implode(",\n", $language_map_pairs) ?> };
|
var language_map = { <?php echo implode(",\n", $language_map_pairs) ?> };
|
||||||
|
|
||||||
$$('a.verify').each(function(a) {
|
$$('form.verify').each(function(f) {
|
||||||
Event.observe(a, 'click', function(e) {
|
Event.observe(f, 'submit', function(e) {
|
||||||
if (!confirm("<?php _e('You are about to delete this language from the available list. Continue?', 'what-did-they-say') ?>")) {
|
if (!confirm("<?php _e('You are about to delete this language from the available list. Continue?', 'what-did-they-say') ?>")) {
|
||||||
Event.stop(e);
|
Event.stop(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$$('a.rename').each(function(a) {
|
||||||
|
Event.observe(a, 'click', function(e) {
|
||||||
|
Event.stop(e);
|
||||||
|
var th = a.parentNode.parentNode.select('th')[0];
|
||||||
|
if (th) {
|
||||||
|
th.select('span')[0].hide();
|
||||||
|
th.select('form')[0].show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue