Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/leadin/public/data
File: class-user.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Leadin\data;
[2] Fix | Delete
[3] Fix | Delete
/**
[4] Fix | Delete
* Static function that wraps the WordPress current user functions.
[5] Fix | Delete
*/
[6] Fix | Delete
class User {
[7] Fix | Delete
/**
[8] Fix | Delete
* Return the first role of the current user. If unauthenticated, return 'visitor'.
[9] Fix | Delete
*/
[10] Fix | Delete
public static function get_role() {
[11] Fix | Delete
global $current_user;
[12] Fix | Delete
[13] Fix | Delete
if ( is_user_logged_in() ) {
[14] Fix | Delete
$user_roles = $current_user->roles;
[15] Fix | Delete
$user_role = array_shift( $user_roles );
[16] Fix | Delete
} else {
[17] Fix | Delete
$user_role = 'visitor';
[18] Fix | Delete
}
[19] Fix | Delete
[20] Fix | Delete
return $user_role;
[21] Fix | Delete
}
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* Return true if the current user has the `manage_options` capability.
[25] Fix | Delete
*/
[26] Fix | Delete
public static function is_admin() {
[27] Fix | Delete
return current_user_can( 'manage_options' );
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
/**
[31] Fix | Delete
* Set metadata for current user
[32] Fix | Delete
*
[33] Fix | Delete
* @param String $key metadata key to store data in.
[34] Fix | Delete
* @param String $data metadata value to store.
[35] Fix | Delete
*/
[36] Fix | Delete
public static function set_metadata( $key, $data ) {
[37] Fix | Delete
update_user_meta( get_current_user_id(), $key, $data );
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
/**
[41] Fix | Delete
* Fetch metadata stored for this user by key
[42] Fix | Delete
*
[43] Fix | Delete
* @param String $key metadata to retrieve by the key.
[44] Fix | Delete
*/
[45] Fix | Delete
public static function get_metadata( $key ) {
[46] Fix | Delete
return get_user_meta( get_current_user_id(), $key, true );
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* Delete metadata associated with this user
[51] Fix | Delete
*
[52] Fix | Delete
* @param String $key key to delete metadata for.
[53] Fix | Delete
*/
[54] Fix | Delete
public static function delete_metadata( $key ) {
[55] Fix | Delete
delete_user_meta( get_current_user_id(), $key );
[56] Fix | Delete
}
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function