Skip to content

Commit

Permalink
Merge pull request #372 from ministryofjustice/colour-warning-emails
Browse files Browse the repository at this point in the history
Colour warning email minor updates
  • Loading branch information
MalcolmVonMoJ authored Sep 4, 2024
2 parents 2f4234b + 4b8b4c4 commit 83781ae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
23 changes: 14 additions & 9 deletions inc/colour-email-warning.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,41 @@ function emailWarning($unset_colours,$custom_colours_found,$max,$location,) {
* $location [string] file which calls the function
*/
if (!empty($unset_colours)) {
$email = "[email protected]";
$email = "[email protected]"; //fallback if no admin email found
$email_admin = get_option('admin_email');
if ($email_admin) $email = $email_admin;
if ($email_admin) $email = $email_admin; //set email to admin email
$env = getenv('WP_ENVIRONMENT_TYPE');
$customizer = is_customize_preview();
$siteName = get_bloginfo('name');
$site№ = get_current_blog_id();
$uri = $_SERVER['REQUEST_URI'];
$uri = (empty($_SERVER['HTTPS']) ? 'http' : 'https') . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$message = "";
if ($env == "prod" && !$custom_colours_found) {
// Send condition 1: Production site has utterly failed to retrieve any colours
$subject = "Warning: Production site № $site№ colours have failed";
} elseif ($env == "prod") {
// Send condition 2: A production site has some unset colours - but it isn't thought to be a major issue.
$subject = "Notice: Undeclared colours on production site № $site№";
} elseif (!$custom_colours_found) {
// Send condition 3: Any other site has utterly failed to retrieve any colours
} elseif (!$custom_colours_found && $env != "local") {
// Send condition 3: Any other (non-local) site has utterly failed to retrieve any colours
$subject = "Notice: Site № $site№ colours have failed ($env)";
} else {
// For testing, add something in here to set a subject and set the email to your own email.
// $email = "[email protected]";
// $subject = "Test - colour warnings ($siteName)";
}
// We only send the email if one of the above send conditions is met
if (isset($subject)) {
$message .= "##Situation\r\n";
if ($customizer) {
$message .= "Someone is using the customizer for site № $site№ on $env. They may or may not be changing colours.\r\n";
$message .= "Someone is using the customizer for $siteName (site № $site№) on $env. They may or may not be changing colours.\r\n";
} else {
$message .= "The colour code has been triggered for site № $site№ on $env. A new colour might have been added to the palette and this has been defaulted to the GDS colour.\r\n";
$message .= "The colour code has been triggered for $siteName (site № $site№) on $env. A new colour might have been added to the palette and this has been defaulted to the GDS colour.\r\n";
}
$message .= "## Problem\r\n";
if ($custom_colours_found) {
$message .= "Site $site№ on $env is set to use custom colours. A total of $custom_colours_found colours set out of a possible $max.\r\n"; //uses the $i from the above loop
$message .= "This is not necessarily a problem, but might indicate some unintended GDS colours appearing on the site\r\n";
$message .= "$siteName (site № $site№) on $env is set to use custom colours. A total of $custom_colours_found colours set out of a possible $max.\r\n"; //uses the $i from the above loop
$message .= "This is not necessarily a problem, but might indicate some unintended GDS colours appearing on the site.\r\n";
$message .= "## Unset colours\r\n";
foreach($unset_colours as $unset_colour) {
$message .= "- $unset_colour\r\n";
Expand Down
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Theme Name: Hale
Text Domain: hale
Version: 4.10.7
Version: 4.10.8
Domain Path: /languages
Description: Theme for Ministry of Justice websites.
Author: Ministry of Justice
Expand Down

0 comments on commit 83781ae

Please sign in to comment.