CharSearch
parent
775966f0dd
commit
457701a907
|
@ -242,6 +242,7 @@ function wowpress_enqueue_block_editor_script()
|
||||||
'wp-blocks',
|
'wp-blocks',
|
||||||
'wp-edit-post',
|
'wp-edit-post',
|
||||||
),
|
),
|
||||||
|
|
||||||
WOWPRESS_VERSION,
|
WOWPRESS_VERSION,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
@ -295,7 +296,6 @@ require get_template_directory() . '/inc/template-tags.php';
|
||||||
require get_template_directory() . '/inc/template-functions.php';
|
require get_template_directory() . '/inc/template-functions.php';
|
||||||
require get_template_directory() . '/inc/config-functions.php';
|
require get_template_directory() . '/inc/config-functions.php';
|
||||||
require get_template_directory() . '/plugins/wowpress-navwalker.php';
|
require get_template_directory() . '/plugins/wowpress-navwalker.php';
|
||||||
require get_template_directory() . '/plugins/wowpress-icons.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hide Admin Bar
|
* Hide Admin Bar
|
||||||
|
@ -471,3 +471,11 @@ function wowpress_add_category_meta($taxonomy)
|
||||||
/** Avatar Filters */
|
/** Avatar Filters */
|
||||||
add_filter('get_avatar_url', '\WoWPress\Models\User::getAvatar', 10, 3);
|
add_filter('get_avatar_url', '\WoWPress\Models\User::getAvatar', 10, 3);
|
||||||
add_filter('asgarosforum_filter_username', '\WoWPress\Models\User::getUsername', 10, 2);
|
add_filter('asgarosforum_filter_username', '\WoWPress\Models\User::getUsername', 10, 2);
|
||||||
|
|
||||||
|
/** Login redirect */
|
||||||
|
add_filter('login_redirect', fn() => "/");
|
||||||
|
|
||||||
|
function sanitize($word){
|
||||||
|
$char = new Character();
|
||||||
|
return $char->sanitize($word);
|
||||||
|
}
|
|
@ -33,17 +33,20 @@ global $user;
|
||||||
<body <?php body_class('dark'); ?>>
|
<body <?php body_class('dark'); ?>>
|
||||||
<?php if (get_sidebar_status('left')) : ?>
|
<?php if (get_sidebar_status('left')) : ?>
|
||||||
<template x-data x-teleport="#sidebar_left">
|
<template x-data x-teleport="#sidebar_left">
|
||||||
<div class="bg-glass shadow p-auto order-1">
|
<div class="bg-glass shadow p-auto order-1 flex flex-col gap-2">
|
||||||
<div class="flex flex-row justify-between">
|
<div class="flex flex-row justify-between">
|
||||||
<div>Hallo <?= $user->username ?></div>
|
<div>Hallo <?= $user->username ?></div>
|
||||||
<?php if (!$user->ID) : ?>
|
<?php if (!$user->ID) : ?>
|
||||||
<div>Bitte <a href="/wp-login.php" class="text-alliance underline">einloggen</a> :)</div>
|
<div>Bitte <a href="/wp-login.php" class="text-alliance underline">einloggen</a> :)</div>
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
<div><a href="/wp-login.php?action=logout" class="text-alliance underline"><?= Icon::get('o-power') ?></a></div>
|
<div><a href="<?=wp_logout_url('/')?>" class="text-alliance underline"><?= Icon::get('o-power') ?></a></div>
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<?php if ($user->ID) : ?>
|
<?php if ($user->ID) : ?>
|
||||||
|
<?php if(current_user_can('wowpress_edit_raids')): ?>
|
||||||
|
<a href="/wp-admin" class="btn btn-red"><?=Icon::get('o-shield-exclamation')?> Admin-Bereich</a>
|
||||||
|
<?php endif; ?>
|
||||||
<div>
|
<div>
|
||||||
<h5 class="text-center text-lg font-bold">Charakter-Liste</h5>
|
<h5 class="text-center text-lg font-bold">Charakter-Liste</h5>
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
get_header();
|
get_header();
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<section id="primary" <?php if(!get_sidebar_status('top')):?> style="margin-top:calc(-1 * var(--wowp-gap))" <?php endif; ?>>
|
<section id="primary" <?php if(!get_sidebar_status('top') || !is_user_logged_in()):?> style="margin-top:calc(-1 * var(--wowp-gap))" <?php endif; ?>>
|
||||||
<main id="main">
|
<main id="main">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
class Icon{
|
|
||||||
|
|
||||||
public static function getIcon($icon_name,$width="24px"){
|
|
||||||
$fname = get_template_directory()."/plugins/heroicons/".$icon_name.".svg";
|
|
||||||
if(file_exists($fname)){
|
|
||||||
return "<div style='width:".$width."'>".file_get_contents($fname)."</div>";
|
|
||||||
}else{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
119
theme/single.php
119
theme/single.php
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The template for displaying all single posts
|
* The template for displaying all single posts
|
||||||
*
|
*
|
||||||
|
@ -8,39 +9,117 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
get_header();
|
get_header();
|
||||||
|
|
||||||
|
use Wenprise\ORM\WP\Post;
|
||||||
|
use WoWPress\Models\User;
|
||||||
|
|
||||||
|
the_post();
|
||||||
|
$author = User::find(get_the_author_meta('ID'));
|
||||||
|
$tp = Post::find(get_the_ID());
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<section id="primary">
|
<section id="primary">
|
||||||
<main id="main">
|
<main id="main">
|
||||||
|
|
||||||
|
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||||
|
<div class="post-wrapper" style="--author-class:var(--color-<?= $author->color ?>)">
|
||||||
|
<div class="post-title">
|
||||||
|
<h1><?php the_title() ?></h1>
|
||||||
|
</div>
|
||||||
|
<div class="post-content"><?php the_content() ?></div>
|
||||||
|
<div class="post-day"><?= get_the_date('d') ?></div>
|
||||||
|
<div class="post-month"><?= get_the_date('F') ?></div>
|
||||||
|
<?php
|
||||||
|
$category = get_the_category();
|
||||||
|
$category = array_pop($category);
|
||||||
|
$color = get_term_meta($category->term_id, 'color', true);
|
||||||
|
?>
|
||||||
|
<div class="post-category ribbon" style="--color-ribbon:#<?= ctype_xdigit($color) ? $color : 'fff' ?>"><span><?= $category->name ?></span></div>
|
||||||
|
<div class="post-avatar"><img src="<?= $author->avatar ?>"></div>
|
||||||
|
<div class="post-author">
|
||||||
|
<?php if (current_user_can('edit_post', $post->ID)) : ?>
|
||||||
|
<a href="<?= get_edit_post_link($post->ID) ?>">
|
||||||
|
<?= $author->username ?>
|
||||||
|
</a>
|
||||||
|
<?php else : ?>
|
||||||
|
<?= $author->username ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</article><!-- #post-${ID} -->
|
||||||
|
|
||||||
|
<?php if (comments_open() || get_comments_number()) : ?>
|
||||||
|
<div class="bg-glass shadow p-auto flex flex-col gap-3">
|
||||||
|
<h3>Kommentare: <?= get_comments_number(); ?></h3>
|
||||||
|
<?php foreach ($tp->comments as $comment) : if($comment->comment_approved && !$comment->comment_approved == "trash") :?>
|
||||||
|
<?=dd($comment)?>
|
||||||
|
<div class="flex flex-col lg:flex-row gap-2 border p-2">
|
||||||
|
<div class="lg:w-1/12">
|
||||||
|
<?php
|
||||||
|
$comment_author = User::where('user_login',$comment->comment_author)->first();
|
||||||
|
if(!empty($comment_author->ID)):
|
||||||
|
?>
|
||||||
|
<img src="<?=$comment_author->avatar?>" alt="" class="w-full hidden lg:block">
|
||||||
|
<div class="flex flex-row justify-center items-center text-<?=$comment_author->color?>"><?=$comment_author->username?></div>
|
||||||
|
<?php
|
||||||
|
else:
|
||||||
|
?>
|
||||||
|
<?=$comment->comment_author?>
|
||||||
|
<?php
|
||||||
|
endif;
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
<div class="bg-slate-500 bg-opacity-45 p-auto w-full text-white">
|
||||||
|
<?= $comment->comment_content ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php endif; endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<?php if(is_user_logged_in() && comments_open()) :?>
|
||||||
|
<div class="bg-glass shadow p-auto flex flex-col gap-2">
|
||||||
|
<!--h3>Kommentar verfassen</h3>
|
||||||
|
|
||||||
|
<button class="btn btn-outline btn-alliance">Kommentar abschicken</button-->
|
||||||
|
<?=comment_form([
|
||||||
|
'class_container' => 'flex flex-col gap-2',
|
||||||
|
'class_submit' => 'btn btn-outline btn-alliance',
|
||||||
|
'title_reply' => "",
|
||||||
|
'logged_in_as' => "",
|
||||||
|
'comment_field' => '<textarea name="comment" id="comment" rows="10" class="w-full bg-glass border-alliance"></textarea>',
|
||||||
|
])?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
/* Start the Loop */
|
/* Start the Loop */
|
||||||
while ( have_posts() ) :
|
// while ( have_posts() ) :
|
||||||
the_post();
|
// the_post();
|
||||||
get_template_part( 'template-parts/content/content', 'single' );
|
// get_template_part( 'template-parts/content/content', 'single' );//
|
||||||
|
|
||||||
if ( is_singular( 'post' ) ) {
|
|
||||||
// Previous/next post navigation.
|
// if ( is_singular( 'post' ) ) {
|
||||||
the_post_navigation(
|
// // Previous/next post navigation.
|
||||||
array(
|
// the_post_navigation(
|
||||||
'next_text' => '<span aria-hidden="true">' . __( 'Next Post', 'wowpress' ) . '</span> ' .
|
// array(
|
||||||
'<span class="sr-only">' . __( 'Next post:', 'wowpress' ) . '</span> <br/>' .
|
// 'next_text' => '<span aria-hidden="true">' . __( 'Next Post', 'wowpress' ) . '</span> ' .
|
||||||
'<span>%title</span>',
|
// '<span class="sr-only">' . __( 'Next post:', 'wowpress' ) . '</span> <br/>' .
|
||||||
'prev_text' => '<span aria-hidden="true">' . __( 'Previous Post', 'wowpress' ) . '</span> ' .
|
// '<span>%title</span>',
|
||||||
'<span class="sr-only">' . __( 'Previous post:', 'wowpress' ) . '</span> <br/>' .
|
// 'prev_text' => '<span aria-hidden="true">' . __( 'Previous Post', 'wowpress' ) . '</span> ' .
|
||||||
'<span>%title</span>',
|
// '<span class="sr-only">' . __( 'Previous post:', 'wowpress' ) . '</span> <br/>' .
|
||||||
)
|
// '<span>%title</span>',
|
||||||
);
|
// )
|
||||||
}
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
// If comments are open, or we have at least one comment, load
|
// If comments are open, or we have at least one comment, load
|
||||||
// the comment template.
|
// the comment template.
|
||||||
if ( comments_open() || get_comments_number() ) {
|
//if ( comments_open() || get_comments_number() ) {
|
||||||
comments_template();
|
// comments_template();
|
||||||
}
|
// }
|
||||||
|
|
||||||
// End the loop.
|
// End the loop.
|
||||||
endwhile;
|
// endwhile;
|
||||||
?>
|
?>
|
||||||
|
|
||||||
</main><!-- #main -->
|
</main><!-- #main -->
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
use WoWPress\Frontend\Icon;
|
use WoWPress\Frontend\Icon;
|
||||||
?>
|
?>
|
||||||
<div>
|
<div>
|
||||||
<label style="" for="tb_<?= $this->id ?>" class="w-full flex <?= $this->row ? 'flex-row gap-2' : 'flex-col' ?> items-center justify-center h-auto select-none cursor-pointer border py-3 px-6
|
<label style="" for="tb_<?= $this->id ?>" class="w-full <?=$this->fullHeight?"h-full":""?> flex <?= $this->row ? 'flex-row gap-2' : 'flex-col' ?> items-center justify-center h-auto select-none cursor-pointer border py-3 px-6
|
||||||
font-bold border-<?=$this->color_no?> transition-colors duration-200 ease-in-out has-[:checked]:bg-<?=$this->color_yes?> has-[:checked]:text-black has-[:checked]:border-<?=$this->color_yes?>">
|
font-bold border-<?=$this->color_no?> transition-colors duration-200 ease-in-out has-[:checked]:bg-<?=$this->color_yes?> has-[:checked]:text-black has-[:checked]:border-<?=$this->color_yes?>">
|
||||||
<input type="<?= $this->type ?>" value="<?=$this->value?>" id="tb_<?= $this->id ?>" name="<?= $this->name ?>" class="peer group hidden" <?= $this->disabled ? 'disabled' : '' ?> <?= $this->checked ? 'checked' : '' ?> />
|
<input type="<?= $this->type ?>" value="<?=$this->value?>" id="tb_<?= $this->id ?>" name="<?= $this->name ?>" class="peer group hidden" <?= $this->disabled ? 'disabled' : '' ?> <?= $this->checked ? 'checked' : '' ?> />
|
||||||
<div class="peer-checked:block hidden">
|
<div class="peer-checked:block hidden">
|
|
@ -17,7 +17,7 @@ $author = User::find(get_the_author_meta('ID'));
|
||||||
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||||
<div class="post-wrapper" style="--author-class:var(--color-<?=$author->color?>)">
|
<div class="post-wrapper" style="--author-class:var(--color-<?=$author->color?>)">
|
||||||
<div class="post-title">
|
<div class="post-title">
|
||||||
<h1><?php the_title() ?></h1>
|
<h1 class="underline"><a href="<?=the_permalink()?>"><?php the_title() ?></a></h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="post-content"><?php the_content() ?></div>
|
<div class="post-content"><?php the_content() ?></div>
|
||||||
<div class="post-day"><?= get_the_date('d') ?></div>
|
<div class="post-day"><?= get_the_date('d') ?></div>
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
* @package WowPress
|
* @package WowPress
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use WoWPress\Frontend\Icon;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<header id="masthead" class="bg-glass">
|
<header id="masthead" class="bg-glass">
|
||||||
|
@ -37,10 +39,10 @@
|
||||||
<button class="btn btn-outline w-full" @click="open = !open">
|
<button class="btn btn-outline w-full" @click="open = !open">
|
||||||
Menü
|
Menü
|
||||||
<div x-show="!open">
|
<div x-show="!open">
|
||||||
<?=Icon::getIcon('bars-3')?>
|
<?=Icon::get('o-bars-3')?>
|
||||||
</div>
|
</div>
|
||||||
<div x-show="open">
|
<div x-show="open">
|
||||||
<?=Icon::getIcon('x-mark')?>
|
<?=Icon::get('o-x-mark')?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -1,5 +1,39 @@
|
||||||
<?php
|
<?php
|
||||||
?>
|
|
||||||
<div class="bg-glass shadow p-auto order-last">
|
|
||||||
|
|
||||||
|
use WoWPress\Models\Character;
|
||||||
|
|
||||||
|
?>
|
||||||
|
<div class="bg-glass shadow p-auto order-last flex flex-col gap-1">
|
||||||
|
<h1 class="text-xl font-bold text-center">Klassensuche</h1>
|
||||||
|
<div class="grid grid-cols-5 gap-2">
|
||||||
|
<?php if($instance['text']): ?>
|
||||||
|
<div class="p-auto col-span-5 text-center">
|
||||||
|
<?=$instance['text']?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php foreach ($instance['classes'] as $class => $specs) : ?>
|
||||||
|
<?php if($this->hasSpec($specs)): ?>
|
||||||
|
<div class="col-span-1"><img src="<?=Character::classIconLink($class)?>" alt="" class="h-8"></div>
|
||||||
|
<div class="col-span-4 grid grid-cols-subgrid">
|
||||||
|
<?php foreach ($specs as $spec => $search) : ?>
|
||||||
|
<div><img src="<?=Character::specIconLink($class,$spec)?>" alt=""
|
||||||
|
<?php
|
||||||
|
switch($search){
|
||||||
|
case 3: ?>class="h-8 border border-red-500" title="Hoch"<?php
|
||||||
|
break;
|
||||||
|
case 2: ?>class="h-8 opacity-70 border border-yellow-500" title="Mittel"<?php
|
||||||
|
break;
|
||||||
|
case 1: ?>class="h-8 opacity-50 border border-green-500" title="Niedrig"<?php
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
default: ?>class="h-8 opacity-10" title="Suche geschlossen"<?php
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
></div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
|
@ -13,13 +13,13 @@ $character = $user->raiders->first();
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="bg-glass shadow p-auto flex flex-col gap-auto order-last">
|
<div class="bg-glass shadow p-auto flex flex-col gap-auto order-last">
|
||||||
<h3 class="text-xl font-bold text-center"><?= $this->title ?></h3>
|
<h1 class="text-xl font-bold text-center"><?= $this->title ?></h1>
|
||||||
<?php if(!empty($character->ID)): ?>
|
<?php if(!empty($character->ID)): ?>
|
||||||
<?php foreach ($raids as $raid) : ?>
|
<?php foreach ($raids as $raid) : ?>
|
||||||
<?php
|
<?php
|
||||||
?>
|
?>
|
||||||
<div class="border shadow p-auto flex flex-col gap-2" style="background-position:center;background-size: cover;background-image:url('<?=$raid->thumbnail?>')">
|
<div class="border shadow p-auto flex flex-col gap-2" style="background-position:center;background-size: cover;background-image:url('<?=$raid->thumbnail?>')">
|
||||||
<h1 class="text-xl font-bold text-center"><?= $raid->title ?></h1>
|
<h2 class="text-xl font-bold text-center"><a href="<?=$raid->link?>"><?= $raid->title ?></a></h2>
|
||||||
<div class="text-center text-<?= $raid->color ?>"><?= $raid->difficulty ?></div>
|
<div class="text-center text-<?= $raid->color ?>"><?= $raid->difficulty ?></div>
|
||||||
|
|
||||||
<div class="flex gap-1 justify-center">
|
<div class="flex gap-1 justify-center">
|
||||||
|
|
|
@ -20,6 +20,8 @@ class ToggleButton{
|
||||||
public $color_yes = "monk";
|
public $color_yes = "monk";
|
||||||
public $color_no = "monk";
|
public $color_no = "monk";
|
||||||
|
|
||||||
|
public $fullHeight = false;
|
||||||
|
|
||||||
public function __construct($args)
|
public function __construct($args)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -46,7 +48,7 @@ class ToggleButton{
|
||||||
|
|
||||||
|
|
||||||
public function render(){
|
public function render(){
|
||||||
require(get_template_directory()."/components/toggle-button.php");
|
require(get_template_directory()."/template-parts/components/toggle-button.php");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
namespace WoWPress\Frontend\Widgets;
|
namespace WoWPress\Frontend\Widgets;
|
||||||
|
|
||||||
|
use Peast\Syntax\Node\Class_;
|
||||||
|
use WoWPress\Frontend\ToggleButton;
|
||||||
|
use WoWPress\Models\Character;
|
||||||
|
|
||||||
class CharacterSearch extends Widget
|
class CharacterSearch extends Widget
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -12,46 +16,206 @@ class CharacterSearch extends Widget
|
||||||
protected $restricted = false;
|
protected $restricted = false;
|
||||||
|
|
||||||
protected $classes = [
|
protected $classes = [
|
||||||
'Death Knight' => [
|
|
||||||
'Frost',
|
|
||||||
'Unholy',
|
|
||||||
'Blood'
|
|
||||||
],
|
|
||||||
'Demon Hunter' => [
|
|
||||||
'Havoc',
|
|
||||||
'Vengeance',
|
|
||||||
],
|
|
||||||
'Druid' => [
|
'Druid' => [
|
||||||
'Feral',
|
'Feral',
|
||||||
'Balance',
|
'Balance',
|
||||||
'Guardian',
|
'Guardian',
|
||||||
'Restoration',
|
'Restoration',
|
||||||
]
|
],
|
||||||
|
'Death Knight' => [
|
||||||
|
'Frost',
|
||||||
|
'Unholy',
|
||||||
|
'Blood'
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
|
'Evoker' => [
|
||||||
|
'Augmentation',
|
||||||
|
'Devastation',
|
||||||
|
'Preservation',
|
||||||
|
],
|
||||||
|
'Warrior' => [
|
||||||
|
'Arms',
|
||||||
|
'Fury',
|
||||||
|
'Protection',
|
||||||
|
],
|
||||||
|
'Paladin' => [
|
||||||
|
'Holy',
|
||||||
|
'Protection',
|
||||||
|
'Retribution',
|
||||||
|
],
|
||||||
|
'Hunter' => [
|
||||||
|
'Beast Mastery',
|
||||||
|
'Marksmanship',
|
||||||
|
'Survival',
|
||||||
|
],
|
||||||
|
'Rogue' => [
|
||||||
|
'Assassination',
|
||||||
|
'Outlaw',
|
||||||
|
'Subtlety',
|
||||||
|
],
|
||||||
|
'Priest' => [
|
||||||
|
'Discipline',
|
||||||
|
'Shadow',
|
||||||
|
'Holy',
|
||||||
|
],
|
||||||
|
'Shaman' => [
|
||||||
|
'Elemental',
|
||||||
|
'Enhancement',
|
||||||
|
'Restoration',
|
||||||
|
],
|
||||||
|
'Mage' => [
|
||||||
|
'Arcane',
|
||||||
|
'Fire',
|
||||||
|
'Frost',
|
||||||
|
],
|
||||||
|
'Warlock' => [
|
||||||
|
'Affliction',
|
||||||
|
'Demonology',
|
||||||
|
'Destruction',
|
||||||
|
],
|
||||||
|
|
||||||
|
'Monk' => [
|
||||||
|
'Brewmaster',
|
||||||
|
'Mistweaver',
|
||||||
|
'Windwalker',
|
||||||
|
],
|
||||||
|
'Demon Hunter' => [
|
||||||
|
'Havoc',
|
||||||
|
'Vengeance',
|
||||||
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function hasSpec($specs)
|
||||||
|
{
|
||||||
|
foreach ($specs as $search) {
|
||||||
|
if ($search) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function form($instance)
|
public function form($instance)
|
||||||
{
|
{
|
||||||
|
|
||||||
foreach ($this->classes as $class => $specs) {
|
|
||||||
foreach ($specs as $spec) {
|
|
||||||
?>
|
?>
|
||||||
<p>
|
<link rel="stylesheet" type="text/css" href="<?= get_template_directory_uri() ?>/style.css">
|
||||||
<label for="<?php echo esc_attr($this->get_field_id("classes[$class][$spec]")); ?>"><?php echo esc_html__("$spec - $class", 'wowpress'); ?></label>
|
<style>
|
||||||
<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]); ?>">
|
input[type=radio] {
|
||||||
</p>
|
display: none !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div class="p-auto">
|
||||||
|
<label for="<?php echo esc_attr($this->get_field_id("text")); ?>"><?php echo esc_html__('Freitext', 'wowpress'); ?></label>
|
||||||
|
<textarea class="w-full" name="<?php echo esc_attr($this->get_field_name("text")); ?>" id="<?php echo esc_attr($this->get_field_id("text")); ?>" rows="10"><?=$instance['text']?></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-col gap-2 p-auto">
|
||||||
|
<?php
|
||||||
|
foreach ($this->classes as $class => $specs) {
|
||||||
|
$classname = sanitize($class);
|
||||||
|
|
||||||
|
?>
|
||||||
|
<div class="bg-<?= $classname ?> bg-opacity-25 p-auto flex flex-col gap-2">
|
||||||
|
<div class="text-center flex flex-col justify-center items-center p-auto">
|
||||||
|
|
||||||
|
<img src="<?= Character::classIconLink($class) ?>" alt="" class="h-8">
|
||||||
|
<h2 class="text-xl font-bold text-<?= $classname ?>"><?= translate_string($class) ?></h2>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
foreach ($specs as $spec) {
|
||||||
|
$specname = sanitize($spec);
|
||||||
|
?>
|
||||||
|
<div class="grid grid-cols-5 gap-2 p-auto border border-<?= $classname ?>">
|
||||||
|
|
||||||
|
<div class="col-span-5">
|
||||||
|
<h3 class="text-lg font-bold text-<?= $classname ?>"><?= translate_string($spec) ?></h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<img src="<?= Character::specIconLink($class, $spec) ?>" alt="" class="">
|
||||||
|
|
||||||
|
<?php
|
||||||
|
(new ToggleButton([
|
||||||
|
'type' => 'radio',
|
||||||
|
'name' => esc_attr($this->get_field_name("classes[$class][$spec]]")),
|
||||||
|
'id' => esc_attr($this->get_field_id("classes[$class][$spec]]")) . "_0",
|
||||||
|
'value' => 0,
|
||||||
|
'text' => "Kein Bedarf",
|
||||||
|
'color' => $classname,
|
||||||
|
'icon_yes' => 'o-check',
|
||||||
|
'checked' => empty($instance['classes'][$class][$spec]),
|
||||||
|
'row' => false,
|
||||||
|
'fullHeight' => true,
|
||||||
|
]))->render();
|
||||||
|
?>
|
||||||
|
<?php
|
||||||
|
(new ToggleButton([
|
||||||
|
'type' => 'radio',
|
||||||
|
'name' => esc_attr($this->get_field_name("classes[$class][$spec]]")),
|
||||||
|
'id' => esc_attr($this->get_field_id("classes[$class][$spec]]")) . "_1",
|
||||||
|
'value' => 1,
|
||||||
|
'text' => "Niedrig",
|
||||||
|
'color' => $classname,
|
||||||
|
'icon_yes' => 'o-check',
|
||||||
|
'checked' => $instance['classes'][$class][$spec] == 1,
|
||||||
|
'row' => false,
|
||||||
|
'fullHeight' => true,
|
||||||
|
]))->render();
|
||||||
|
?>
|
||||||
|
<?php
|
||||||
|
(new ToggleButton([
|
||||||
|
'type' => 'radio',
|
||||||
|
'name' => esc_attr($this->get_field_name("classes[$class][$spec]]")),
|
||||||
|
'id' => esc_attr($this->get_field_id("classes[$class][$spec]]")) . "_2",
|
||||||
|
'value' => 2,
|
||||||
|
'text' => "Mittel",
|
||||||
|
'color' => $classname,
|
||||||
|
'icon_yes' => 'o-check',
|
||||||
|
'checked' => $instance['classes'][$class][$spec] == 2,
|
||||||
|
'row' => false,
|
||||||
|
'fullHeight' => true,
|
||||||
|
]))->render();
|
||||||
|
?>
|
||||||
|
<?php
|
||||||
|
(new ToggleButton([
|
||||||
|
'type' => 'radio',
|
||||||
|
'name' => esc_attr($this->get_field_name("classes[$class][$spec]]")),
|
||||||
|
'id' => esc_attr($this->get_field_id("classes[$class][$spec]]")) . "_3",
|
||||||
|
'value' => 3,
|
||||||
|
'text' => "Hoch",
|
||||||
|
'color' => $classname,
|
||||||
|
'icon_yes' => 'o-check',
|
||||||
|
'checked' => $instance['classes'][$class][$spec] == 3,
|
||||||
|
'row' => false,
|
||||||
|
'fullHeight' => true,
|
||||||
|
]))->render();
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($new_instance, $old_instance)
|
public function update($new_instance, $old_instance)
|
||||||
{
|
{
|
||||||
$instance = array();
|
$instance = array();
|
||||||
|
$instance['text'] = (!empty($new_instance['text'])) ? strip_tags($new_instance['text']) : '';
|
||||||
foreach ($this->classes as $class => $specs) {
|
foreach ($this->classes as $class => $specs) {
|
||||||
foreach ($specs as $spec) {
|
foreach ($specs as $spec) {
|
||||||
$instance['classes'][$class][$spec] = (!empty($new_instance['classes'][$class][$spec])) ? strip_tags($new_instance['classes'][$class][$spec]) : '';
|
$instance['classes'][$class][$spec] = (!empty($new_instance['classes'][$class][$spec])) ? strip_tags($new_instance['classes'][$class][$spec]) : '';
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ class Character extends Model
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected function sanitize($string,$delimiter_space="")
|
public function sanitize($string,$delimiter_space="")
|
||||||
{
|
{
|
||||||
$string = strtolower(str_replace(" ", $delimiter_space, $string));
|
$string = strtolower(str_replace(" ", $delimiter_space, $string));
|
||||||
$string = strtolower(str_replace("'", "", $string));
|
$string = strtolower(str_replace("'", "", $string));
|
||||||
|
@ -77,6 +77,11 @@ class Character extends Model
|
||||||
return get_template_directory_uri() . "/icons/class/$classname/$classname.png";
|
return get_template_directory_uri() . "/icons/class/$classname/$classname.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function classIconLink($class){
|
||||||
|
$classname = (new self())->sanitize($class);
|
||||||
|
return get_template_directory_uri() . "/icons/class/$classname/$classname.png";
|
||||||
|
}
|
||||||
|
|
||||||
public function getSpecIconAttribute()
|
public function getSpecIconAttribute()
|
||||||
{
|
{
|
||||||
$classname = $this->sanitize($this->class);
|
$classname = $this->sanitize($this->class);
|
||||||
|
@ -84,6 +89,12 @@ class Character extends Model
|
||||||
return get_template_directory_uri() . "/icons/class/$classname/$specname.png";
|
return get_template_directory_uri() . "/icons/class/$classname/$specname.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function specIconLink($class,$spec){
|
||||||
|
$classname = (new self())->sanitize($class);
|
||||||
|
$specname = (new self())->sanitize($spec);
|
||||||
|
return get_template_directory_uri() . "/icons/class/$classname/$specname.png";
|
||||||
|
}
|
||||||
|
|
||||||
public function updateFromAPI()
|
public function updateFromAPI()
|
||||||
{
|
{
|
||||||
$realm = $this->sanitize($this->realm,"-");
|
$realm = $this->sanitize($this->realm,"-");
|
||||||
|
@ -134,6 +145,6 @@ class Character extends Model
|
||||||
|
|
||||||
|
|
||||||
public function getClassButtonAttribute(){
|
public function getClassButtonAttribute(){
|
||||||
require(get_template_directory()."/components/class-button.php");
|
require(get_template_directory()."/template-parts/components/class-button.php");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ class Signup extends Model
|
||||||
$showRole = false;
|
$showRole = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
require(get_template_directory() . "/components/raid-signup.php");
|
require(get_template_directory() . "/template-parts/components/raid-signup.php");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStatusList($selectable = false)
|
public function getStatusList($selectable = false)
|
||||||
|
@ -165,6 +165,12 @@ class Signup extends Model
|
||||||
|
|
||||||
public function getStatus()
|
public function getStatus()
|
||||||
{
|
{
|
||||||
|
$tooLate = $this->raid->status == "Locked";
|
||||||
|
if($tooLate && $this->status == "Unknown"){
|
||||||
|
$this->setStatus('Too Late');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (key_exists($this->status, $this->statusList)) {
|
if (key_exists($this->status, $this->statusList)) {
|
||||||
return $this->statusList[$this->status];
|
return $this->statusList[$this->status];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue