-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
1,883 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
class Post_Color | ||
{ | ||
|
||
public function __construct($post_id) { | ||
return $this->get_post_it_color($post_id); | ||
} | ||
function generate_post_it_colors() { | ||
// Überprüfe, ob die Farben bereits in der wp_options gespeichert sind | ||
$colors = get_option('post_it_colors'); | ||
|
||
// Wenn noch keine Farben vorhanden sind, generiere 12 Farben | ||
if (!$colors) { | ||
$colors = []; | ||
for ($i = 0; $i < 12; $i++) { | ||
$colors[] = $this->generate_contrast_color(); | ||
} | ||
// Speichere die generierten Farben in wp_options | ||
update_option('post_it_colors', $colors); | ||
} | ||
|
||
return $colors; | ||
} | ||
|
||
function generate_contrast_color() { | ||
// Helligkeit der Farben für gute Lesbarkeit mit schwarzer Schrift | ||
$min_brightness = 130; | ||
|
||
do { | ||
// Generiere eine zufällige Farbe | ||
$color = sprintf('#%02X%02X%02X', mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255)); | ||
// Berechne die Helligkeit der Farbe | ||
$brightness = $this->calculate_brightness($color); | ||
} while ($brightness < $min_brightness); | ||
|
||
return $color; | ||
} | ||
|
||
function calculate_brightness($hex) { | ||
// Entferne das "#" Zeichen, wenn vorhanden | ||
$hex = str_replace('#', '', $hex); | ||
|
||
// Wandle HEX in RGB um | ||
$r = hexdec(substr($hex, 0, 2)); | ||
$g = hexdec(substr($hex, 2, 2)); | ||
$b = hexdec(substr($hex, 4, 2)); | ||
|
||
// Berechne die Helligkeit (simplifiziert) | ||
return ($r * 299 + $g * 587 + $b * 114) / 1000; | ||
} | ||
|
||
function get_post_it_color($post_id) { | ||
// Überprüfe, ob die Farbe bereits als Meta-Information gespeichert ist | ||
$color = get_post_meta($post_id, '_post_it_color', true); | ||
|
||
if (!$color) { | ||
// Hol die Liste der 12 Farben | ||
$colors = $this->generate_post_it_colors(); | ||
|
||
// Wähle eine zufällige Farbe aus | ||
$color = $colors[array_rand($colors)]; | ||
|
||
// Speichere die Farbe als Post-Meta | ||
update_post_meta($post_id, '_post_it_color', $color); | ||
} | ||
|
||
return $color; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
:root{ | ||
--textcolor: var(--theme-palette-color-3); | ||
--background: var(--theme-palette-color-7); | ||
--buttoncolor: var(--theme-palette-color-1); | ||
--buttontext: var(--theme-palette-color-6); | ||
--inverse: var(--theme-palette-color-4); | ||
--akcent: var(--theme-palette-color-2); | ||
--akcent2: var(--theme-palette-color-5); | ||
--background1: var(--theme-palette-color-6); | ||
--background2: var(--theme-palette-color-8); | ||
--modal-background: rgba(0,0,0,0.4); | ||
--bordercolor: var(--theme-palette-color-2); | ||
--bordercolor2: var(--theme-palette-color-9); | ||
--gray: #d3d3d3; | ||
|
||
} | ||
|
Oops, something went wrong.