studio-arrenberg / quartiersplattform

🏡 Repo für die Quartiersplattform
https://arrenberg.app
MIT License
2 stars 3 forks source link

Warnings in debug.log #147

Open Uatschitchun opened 2 years ago

Uatschitchun commented 2 years ago

The theme generates a whole lotta WARNINGS in WP's debug.log: [04-Nov-2022 15:10:06 UTC] PHP Notice: Undefined index: HTTP_ACCEPT_LANGUAGE in /homepages/34/d77201858/htdocs/wp-hammesberg/wp-content/themes/quartiersplattform/functions.php on line 3271

This can be prevented with:

diff --git a/functions.php b/functions.php
index 128f260..378c514 100644
--- a/functions.php
+++ b/functions.php
@@ -3268,7 +3268,12 @@ add_action( 'after_setup_theme', 'qp_translate_theme' );
  * @return string browser language
  */
 function qp_detect_browser_language() {
-       $browser_language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 5);
+       if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
+               $browser_language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 5);
+        }
+       else{
+               $browser_language = '';
+       }
        if(stripos($browser_language, "de") !== false ){
                return "de_DE";
        }elseif(stripos($browser_language, "it") !== false ){

Maybe the isset check could be added in one line, but didn't know how ;)

And another WARNING gets printed: [04-Nov-2022 15:33:46 UTC] PHP Notice: Undefined variable: twitter_site in /homepages/34/d77201858/htdocs/wp-hammesberg/wp-content/themes/quartiersplattform/header.php on line 176

The line is commented out, so it's still needed?