HM\BackUpWordPress\Email_Service::update PHP Метод

update() публичный Метод

Validate the email and return an error if validation fails
public update ( &$new_data, array $old_data ) : array | null
$old_data array The data we are replacing.
Результат array | null Null on success, array of errors if validation failed.
    public function update(&$new_data, $old_data)
    {
        $errors = array();
        if (isset($new_data['email'])) {
            if (!empty($new_data['email'])) {
                foreach (explode(',', $new_data['email']) as $email) {
                    $email = trim($email);
                    if (!is_email($email)) {
                        $errors['email'] = sprintf(__('%s isn\'t a valid email', 'backupwordpress'), $email);
                    }
                }
            }
            if (!empty($errors['email'])) {
                $new_data['email'] = '';
            }
            return $errors;
        }
    }