Skip to content

Commit

Permalink
Extend admin email checking
Browse files Browse the repository at this point in the history
Extend the check for bad admin emails by listing unwanted emails
in an array. Include noreply@, no-reply@ and vagrant@.
  • Loading branch information
sjaks authored and Sami Jakonen committed Oct 2, 2020
1 parent 9141d6c commit 07703c4
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions modules/check-default-email.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php
/**
* Plugin name: Seravo Check Default Email
* Description: Checks that the WordPress admin email is not the default no-reply@seravo
* if so, show a notification suggesting to change it to something better.
* Description: Checks if the WordPress admin email address has an evidently
* bad local part, i.e. [email protected] or [email protected]. If so,
* show a notification suggesting to change it to something better.
*/

namespace Seravo;
Expand All @@ -15,14 +16,19 @@
if ( ! class_exists('CheckDefaultEmail') ) {
class CheckDefaultEmail {

private static $bad_email_locals = array( 'no-reply', 'noreply', 'vagrant' );

public static function load() {
add_action('admin_notices', array( __CLASS__, '_seravo_check_default_email' ));
}

public static function _seravo_check_default_email() {
// Get the siteurl and home url and check if https is enabled, if not, show warning
// Get admin email option and take the local part before the @ sign
$email = get_option('admin_email');
if ( $email === '[email protected]' || $email === '[email protected]' ) {
$email_local = strtok($email, '@');

// Check if the email should should be changed. If so, show warning
if ( in_array($email_local, self::$bad_email_locals) ) {
self::_seravo_show_email_warning();
}
}
Expand Down

0 comments on commit 07703c4

Please sign in to comment.