-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #372 from ministryofjustice/colour-warning-emails
Colour warning email minor updates
- Loading branch information
Showing
2 changed files
with
15 additions
and
10 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 |
---|---|---|
|
@@ -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"; | ||
|
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