Raid-Titel ändern bei Custom

master
Seph 2024-08-05 20:19:44 +02:00
parent 52bdd3c703
commit 7d0771be23
15 changed files with 308 additions and 183 deletions

View File

@ -70,7 +70,6 @@
body {
background-color: unset;
--body-bg: url('https://sephger.de/nkbg.png');
position: relative;
z-index: -10;
@apply min-h-screen;

View File

@ -396,7 +396,8 @@ function wowpress_add_category_meta($taxonomy)
}
//* Theme Options Page **/
require_once(get_stylesheet_directory() . '/options/api.php');
require_once(get_stylesheet_directory() . '/options/register.php');
/** Global Helper functions */
function translate_string($string, $lang = "deu")

View File

@ -26,6 +26,8 @@ global $user;
<style>
:root {
--color-background: var(--color-deepblue);
--body-bg: url('/wp-content/bg.jpg');
}
</style>
</head>

View File

@ -1,33 +1,4 @@
<?php
/* ------------------ */
/* theme options page */
/* ------------------ */
add_action( 'admin_init', 'theme_options_init' );
add_action( 'admin_menu', 'theme_options_add_page' );
// Einstellungen registrieren (http://codex.wordpress.org/Function_Reference/register_setting)
function theme_options_init(){
register_setting( 'wowpress_options', 'wowpress_api', 'kb_validate_options' );
}
// Seite in der Dashboard-Navigation erstellen
function theme_options_add_page() {
add_menu_page(
'Theme-Einstellungen',
'Theme-Einstellungen',
'wowpress_edit_site',
'wowpress_options',
'wowpress_api_options_page',
'dashicons-universal-access',
25
);
#add_theme_page('API-Einstellungen', 'API-Einstellungen', 'edit_theme_options', 'api_options', 'wowpress_api_options_page' ); // Seitentitel, Titel in der Navi, Berechtigung zum Editieren (http://codex.wordpress.org/Roles_and_Capabilities) , Slug, Funktion
}
// Optionen-Seite erstellen
function wowpress_api_options_page() {
global $select_options, $radio_options;
@ -35,7 +6,7 @@ if ( ! isset( $_REQUEST['settings-updated'] ) )
$_REQUEST['settings-updated'] = false; ?>
<div class="wrap">
<?php screen_icon(); ?><h2>API-Optionen für <?php bloginfo('name'); ?></h2>
<h2>API-Optionen für <?php bloginfo('name'); ?></h2>
<?php if ( false !== $_REQUEST['settings-updated'] ) : ?>
<div class="updated fade">
@ -73,12 +44,3 @@ if ( ! isset( $_REQUEST['settings-updated'] ) )
</div>
<?php }
// Strip HTML-Code:
// Hier kann definiert werden, ob HTML-Code in einem Eingabefeld
// automatisch entfernt werden soll. Soll beispielsweise im
// Copyright-Feld KEIN HTML-Code erlaubt werden, kommentiert die Zeile
// unten wieder ein. http://codex.wordpress.org/Function_Reference/wp_filter_nohtml_kses
function kb_validate_options( $input ) {
// $input['copyright'] = wp_filter_nohtml_kses( $input['copyright'] );
return $input;
}

View File

@ -0,0 +1,59 @@
<?php
require_once('api.php');
require_once('style.php');
add_action('admin_init', 'theme_options_init');
add_action('admin_menu', 'theme_options_add_page');
/* ------------------ */
/* theme options page */
/* ------------------ */
add_action('admin_init', 'theme_options_init');
add_action('admin_menu', 'theme_options_add_page');
// Einstellungen registrieren (http://codex.wordpress.org/Function_Reference/register_setting)
function theme_options_init()
{
register_setting('wowpress_options', 'wowpress_api', 'kb_validate_options');
register_setting('wowpress_options', 'wowpress_style', 'kb_validate_options');
}
// Seite in der Dashboard-Navigation erstellen
function theme_options_add_page()
{
add_menu_page(
'API-Keys',
'API-Keys',
'wowpress_edit_site',
'wowpress_api_options',
'wowpress_api_options_page',
'dashicons-lock',
25
);
add_menu_page(
'Hintergrund',
'Hintergrund',
'wowpress_edit_site',
'wowpress_style_options',
'wowpress_style_options_page',
'dashicons-format-image',
26
);
}
// Strip HTML-Code:
// Hier kann definiert werden, ob HTML-Code in einem Eingabefeld
// automatisch entfernt werden soll. Soll beispielsweise im
// Copyright-Feld KEIN HTML-Code erlaubt werden, kommentiert die Zeile
// unten wieder ein. http://codex.wordpress.org/Function_Reference/wp_filter_nohtml_kses
function kb_validate_options($input)
{
// $input['copyright'] = wp_filter_nohtml_kses( $input['copyright'] );
return $input;
}

View File

@ -0,0 +1,42 @@
<?php
// Optionen-Seite erstellen
function wowpress_style_options_page() {
global $select_options, $radio_options;
if ( ! isset( $_REQUEST['settings-updated'] ) )
$_REQUEST['settings-updated'] = false; ?>
<div class="wrap">
<h2>Style-Optionen für <?php bloginfo('name'); ?></h2>
<?php if ( false !== $_REQUEST['settings-updated'] ) : ?>
<div class="updated fade">
<p><strong>Einstellungen gespeichert!</strong></p>
</div>
<?php endif; ?>
<form method="post" action="/request" enctype="multipart/form-data">
<input type="hidden" name="action" value="updatePageBG" >
<?php wp_nonce_field('updatePageBG', 'updatePageBG_nonce'); ?>
<h3>Hintergrund</h3>
<table class="form-table">
<tr valign="top">
<th scope="row">Hintergrund-Bild</th>
<td>
<input type="file" name="bg" id="wowpress_bg" accept="image/jpeg">
</td>
</tr>
<tr>
<td colspan="2">
<img src="/wp-content/bg.jpg" alt="" style="width: 42rem;">
</td>
</tr>
</table>
<!-- submit -->
<p class="submit"><input type="submit" class="button-primary" value="Hochladen" /></p>
</form>
</div>
<?php }

View File

@ -21,7 +21,6 @@ if ($raid->id_wowaudit) {
$raid->status = "Cancelled";
$raid->save();
}
}
@ -34,7 +33,20 @@ get_header();
<a href="<?= $raid->previous->link ?>" class="btn btn-outline hidden lg:flex">Vorheriger</a>
<?php endif; ?>
<div class="text-3xl font-bold bg-glass shadow p-3 text-center w-full">
<?php if (current_user_can('wowpress_edit_raids')) : ?>
<form action="/request" method="POST">
<?php wp_nonce_field('updateRaidTitle', 'updateRaidTitle_nonce'); ?>
<input type="hidden" name="action" value="updateRaidTitle">
<input type="hidden" name="raid_id" value="<?= $raid->ID ?>">
<div class="flex flex-row gap-1 justify-center">
<input type="text" name="name" class="bg-white bg-opacity-0 border-alliance" value="<?= $raid->title ?>">
<button class="btn btn-green">Titel ändern</button>
</div>
</form>
<?php else : ?>
<?= $raid->title ?>
<?php endif; ?>
</div>
<?php if ($raid->next) : ?>
<a href="<?= $raid->next->link ?>" class="btn btn-outline hidden lg:flex">Nächster</a>

View File

@ -331,6 +331,27 @@ switch ($_POST['action']) {
}
}
break;
case 'updatePageBG':
isAllowed('wowpress_edit_site');
if (isset($_POST['updatePageBG_nonce']) && wp_verify_nonce($_POST['updatePageBG_nonce'], 'updatePageBG')) {
if (isset($_FILES['bg']) && $_FILES['bg']['type'] == "image/jpeg" ) {
$bg_path = ABSPATH."/wp-content/bg.jpg";
rename($_FILES['bg']['tmp_name'],$bg_path);
chmod(ABSPATH."/wp-content/bg.jpg",0644);
}
}
break;
case 'updateRaidTitle':
isAllowed('wowpress_edit_raids');
if (isset($_POST['updateRaidTitle_nonce']) && wp_verify_nonce($_POST['updateRaidTitle_nonce'], 'updateRaidTitle')) {
if(isset($_POST['raid_id']) && isset($_POST['name'])){
$raid = Raid::find($_POST['raid_id']);
if($raid){
$raid->setTitle($_POST['name']);
}
}
}
}
header('Location: ' . $_SERVER['HTTP_REFERER']);

View File

@ -7,6 +7,9 @@
* @package WowPress
*/
if(!(get_post_meta(get_the_ID(),'loggedin',true) && !is_user_logged_in())){
?>
@ -29,7 +32,7 @@
<?php wowpress_post_thumbnail(); ?>
<div class="" <?php wowpress_content_class( 'entry-content' ); ?>>
<div class="prose text-white" <?php wowpress_content_class( 'entry-content' ); ?>>
<?php
the_content();
@ -45,3 +48,15 @@
</article><!-- #post-<?php the_ID(); ?> -->
<?php }else{
?>
<div class="bg-glass shadow p-auto text-center">
<header class="entry-header">
<h1>Keine Berechtigung die Seite anzuzeigen</h1>
</header>
</div>
<?php } ?>

View File

@ -15,7 +15,7 @@ use WoWPress\Models\Notification;
if (is_user_logged_in()) {
$notifications = Notification::getAll();
} else {
$notifications = [];
$notifications = collect([]);
}
?>

View File

@ -1,10 +1,19 @@
<?php
if(!empty($instance['raid_name'])){
$raid_name = $instance['raid_name'];
}else{
$raid_name = "";
}
?>
<div class="bg-glass shadow p-auto order-last flex flex-col gap-2">
<h3 class="text-xl font-bold text-center"><?= $this->title ?></h3>
<h4 class="text-lg font-bold text-center"><?= $instance['raid_name'] ?></h4>
<h4 class="text-lg font-bold text-center"><?= $raid_name ?></h4>
<div class="relative pt-1">
<div class="overflow-hidden h-2 mb-4 text-xs flex bg-slate-200">
<div style="width:<?=$this->getCompletePercent($instance)?>%" class="shadow-none flex flex-col text-center whitespace-nowrap text-white justify-center bg-alliance"></div>

View File

@ -2,18 +2,6 @@
use WoWPress\Models\Character;
function hasSearch($specs)
{
foreach ($specs as $spec) {
foreach ($spec as $search) {
if ($search) {
return true;
}
}
}
return false;
}
?>
<div class="bg-glass shadow p-auto order-last flex flex-col gap-1">
<h1 class="text-xl font-bold text-center">Klassensuche</h1>
@ -27,25 +15,30 @@ function hasSearch($specs)
<?php if ($this->hasSpec($specs)) : ?>
<div class="col-span-1"><img src="<?= Character::classIconLink($class) ?>" title="<?= translate_string($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
<?php foreach ($specs as $spec => $search) :
switch ($search) {
case 3: ?>class="h-8 border border-red-500" title="<?=translate_string($spec)?>: Hoch"<?php
case 3:
$classes = "border border-red-500";
$text = "Hoch";
break;
case 2: ?>class="h-8 opacity-70 border border-yellow-500" title="<?=translate_string($spec)?>: Mittel"<?php
case 2:
$classes = "border border-yellow-500 opacity-70";
$text = "Mittel";
break;
case 1: ?>class="h-8 opacity-50 border border-green-500" title="<?=translate_string($spec)?>: Niedrig"<?php
case 1:
$classes = "border border-green-500 opacity-50";
$text = "Niedrig";
break;
case 0:
default: ?>class="h-8 opacity-10" title="<?=translate_string($spec)?>: Suche geschlossen"<?php
default:
$classes = "opacity-10";
$text = "Suche geschlossen";
break;
}
?>
></div>
} ?>
<div><img src="<?= Character::specIconLink($class, $spec) ?>" alt="" class="h-8 <?= $classes ?>" title="<?= translate_string($spec) ?>: <?= $text ?>"></div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
</div>

View File

@ -17,13 +17,12 @@ class NavWalker extends \Walker_Nav_Menu
}
function end_lvl(&$output, $depth = 0, $args = null)
{
$output .= '</div></div>';
}
function end_el(&$output, $item, $depth = 0, $args = \null)
{
$classes = collect($item->classes);
if (0 === $depth) {
$output .= '</div>';
}
@ -31,17 +30,16 @@ class NavWalker extends \Walker_Nav_Menu
function start_el(&$output, $item, $depth = 0, $args = [], $id = 0)
{
$classes = collect($item->classes);
$needs_login = $classes->contains('loggedin')&&!is_user_logged_in();
if ($args->walker->has_children) {
$output .= '<div x-cloak @click.away="open = false" class="relative" x-data="{ open: false }">';
$output .= '<div x-cloak @click.away="open = false" class="relative '.($needs_login?"hidden":"").'" x-data="{ open: false }">';
$output .= '<button @click="open = !open" class="w-full nav-btn ' . implode(" ", $item->classes) . '">';
} elseif ($item->url && $item->url != '#' && $item->url != "#LOGIN") {
if (0 === $depth) {
$output .= '<div>';
$output .= '<div class="'.($needs_login?"hidden":"").'">';
}
$output .= '<a class="nav-btn ' . implode(" ", $item->classes) . '" href="' . $item->url . '">';
$output .= '<a class="nav-btn ' . implode(" ", $item->classes) . ' '.($needs_login?"hidden":"").'" href="' . $item->url . '">';
} elseif ($item->url && $item->url == "#LOGIN") {
if (!is_user_logged_in()) {
if (0 === $depth) {
@ -54,8 +52,6 @@ class NavWalker extends \Walker_Nav_Menu
$output .= '<div>';
}
$item->classes[] = "btn-alliance btn-outline";
$output .= '<a class="nav-btn ' . implode(" ", $item->classes) . '" href="/wp-admin/profile.php">';
}
} else {
@ -64,14 +60,12 @@ class NavWalker extends \Walker_Nav_Menu
}
$output .= '<span class="nav-btn ' . implode(" ", $item->classes) . '">';
}
foreach ($item->classes as $class) {
if (str_contains($class, "icon-")) {
$icon_name = substr($class, 5);
$output .= Icon::get($icon_name, "24px");
}
}
if ($item->url && $item->url == "#LOGIN") {
if (is_user_logged_in()) {
@ -82,13 +76,11 @@ class NavWalker extends \Walker_Nav_Menu
} else {
$output .= $item->title;
}
if ($args->walker->has_children) {
$output .= "
<svg fill= \"currentColor\" viewBox=\"0 0 20 20\" :class=\"{'rotate-180': open, 'rotate-0': !open}\" class=\"inline w-4 h-4 mt-1 ml-1 transition-transform duration-200 transform md:-mt-1\"><path fill-rule=\"evenodd\" d=\"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z\" clip-rule=\"evenodd\"></path></svg>
";
}
if ($args->walker->has_children) {
$output .= "</button>";
} elseif ($item->url && $item->url != '#') {

View File

@ -14,6 +14,9 @@ class BossKills extends Widget
public function getBossList($instance){
$out = [];
if(empty($instance['bosses'])){
$instance['bosses'] = [];
}
foreach($instance['bosses'] as $boss){
if(!empty($boss['name'])){
$out[] = $boss;
@ -24,7 +27,10 @@ class BossKills extends Widget
}
public function getCompletePercent($instance){
$bosses = $this->getBossList($instance);
$bosses = $this->getBossList($instance)?:[];
if(empty($bosses)){
return 0;
}
$done = 0;
foreach($bosses as $boss){
if(!empty($boss['date'])){

View File

@ -81,7 +81,11 @@ class Raid extends Model
if (!empty($this->id_wowaudit)) {
$raid = (object)$this->api->getRaid($this->id_wowaudit, $force);
if (!empty($raid->id)) {
if($this->title && $raid->instance == "Custom"){
//Titel nur sezten wenn kein Custom Raid
}else{
$this->title = $raid->instance;
}
$this->start = $raid->date . " " . $raid->start_time;
$this->end = $raid->date . " " . $raid->end_time;
$this->difficulty = $raid->difficulty;
@ -188,6 +192,11 @@ class Raid extends Model
return $this;
}
public function setTitle($title){
$this->title = $title;
$this->save();
}
public function getColorAttribute($type = "")
{
switch ($this->difficulty) {
@ -222,8 +231,11 @@ class Raid extends Model
$clean_name = str_replace([" ","'"],"-",$this->title);
$clean_name = preg_replace('/[^a-zA-Z0-9_-]/', '', $clean_name);
$clean_name = strtolower($clean_name);
return "https://data.wowaudit.com/img/$clean_name-small.jpeg";
$url = "https://data.wowaudit.com/img/$clean_name-small.jpeg";
if(file_exists($url)){
return $url;
}
return "https://data.wowaudit.com/img/custom-small.jpeg";
}