61 lines
1.4 KiB
PHP
61 lines
1.4 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace WoWPress\Frontend\Widgets;
|
||
|
|
||
|
class CharacterSearch extends Widget
|
||
|
{
|
||
|
|
||
|
protected $template_path = "char_search.php";
|
||
|
protected $title = "Charaktersuche";
|
||
|
protected $base_id = "wowpress_char_search";
|
||
|
public $name = "Charaktersuche";
|
||
|
protected $restricted = false;
|
||
|
|
||
|
protected $classes = [
|
||
|
'Death Knight' => [
|
||
|
'Frost',
|
||
|
'Unholy',
|
||
|
'Blood'
|
||
|
],
|
||
|
'Demon Hunter' => [
|
||
|
'Havoc',
|
||
|
'Vengeance',
|
||
|
],
|
||
|
'Druid' => [
|
||
|
'Feral',
|
||
|
'Balance',
|
||
|
'Guardian',
|
||
|
'Restoration',
|
||
|
]
|
||
|
];
|
||
|
|
||
|
|
||
|
public function form($instance)
|
||
|
{
|
||
|
|
||
|
foreach ($this->classes as $class => $specs) {
|
||
|
foreach ($specs as $spec) {
|
||
|
?>
|
||
|
<p>
|
||
|
<label for="<?php echo esc_attr($this->get_field_id("classes[$class][$spec]")); ?>"><?php echo esc_html__("$spec - $class", 'wowpress'); ?></label>
|
||
|
<input type="text" class="widefat" id="<?php echo esc_attr($this->get_field_id("classes[$class][$spec]")); ?>" name="<?php echo esc_attr($this->get_field_name("classes[$class][$spec]]")); ?>" value="<?php echo esc_attr($instance['classes'][$class][$spec]); ?>">
|
||
|
</p>
|
||
|
<?php
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function update($new_instance, $old_instance)
|
||
|
{
|
||
|
$instance = array();
|
||
|
foreach ($this->classes as $class => $specs) {
|
||
|
foreach ($specs as $spec) {
|
||
|
$instance['classes'][$class][$spec] = (!empty($new_instance['classes'][$class][$spec])) ? strip_tags($new_instance['classes'][$class][$spec]) : '';
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return $instance;
|
||
|
}
|
||
|
}
|