wsl.mail.notification.php ➔ wsl_admin_notification()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 21
rs 9.584
c 0
b 0
f 0
1
<?php
2
/*!
3
* WordPress Social Login
4
*
5
* https://miled.github.io/wordpress-social-login/ | https://github.com/miled/wordpress-social-login
6
*   (c) 2011-2020 Mohamed Mrassi and contributors | https://wordpress.org/plugins/wordpress-social-login/
7
*/
8
9
/** 
10
* Email notifications to send. so far only the admin one is implemented
11
*/
12
13
// Exit if accessed directly
14
if ( !defined( 'ABSPATH' ) ) exit;
15
16
// --------------------------------------------------------------------
17
18
/**
19
* Send a notification to blog administrator when a new user register using WSL 
20
*
21
* also borrowed from http://wordpress.org/extend/plugins/oa-social-login/
22
* 
23
* Note: 
24
*   You may redefine this function
25
*/
26
if( ! function_exists( 'wsl_admin_notification' ) )
27
{
28
	function wsl_admin_notification( $user_id, $provider )
29
	{
30
		//Get the user details
31
		$user = new WP_User($user_id);
32
		$user_login = stripslashes( $user->user_login );
33
34
		// The blogname option is escaped with esc_html on the way into the database
35
		// in sanitize_option we want to reverse this for the plain text arena of emails.
36
		$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
37
38
		$message  = sprintf(__('New user registration on your site: %s', 'wordpress-social-login'), $blogname        ) . "\r\n\r\n";
39
		$message .= sprintf(__('Username: %s'                          , 'wordpress-social-login'), $user_login      ) . "\r\n";
40
		$message .= sprintf(__('Provider: %s'                          , 'wordpress-social-login'), $provider        ) . "\r\n";
41
		$message .= sprintf(__('Profile: %s'                           , 'wordpress-social-login'), $user->user_url  ) . "\r\n";
42
		$message .= sprintf(__('Email: %s'                             , 'wordpress-social-login'), $user->user_email) . "\r\n";
43
		$message .= "\r\n--\r\n";
44
		$message .= "WordPress Social Login\r\n";
45
		$message .= "http://wordpress.org/extend/plugins/wordpress-social-login/\r\n";
46
47
		@ wp_mail(get_option('admin_email'), '[WordPress Social Login] '.sprintf(__('[%s] New User Registration', 'wordpress-social-login'), $blogname), $message);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
48
	}
49
}
50
51
// --------------------------------------------------------------------
52