v1.0.1
This commit is contained in:
parent
212d64abfa
commit
b8e17df2db
17 changed files with 1145 additions and 732 deletions
|
|
@ -25,7 +25,7 @@ class Two_Factor_Extended_Role_Manager {
|
|||
*
|
||||
* @since 0.1.0
|
||||
*
|
||||
* @return array Array of role slugs and names.
|
||||
* @return array<string, string> Array of role slugs and names.
|
||||
*/
|
||||
public static function get_all_roles(): array {
|
||||
if ( ! function_exists( 'get_editable_roles' ) ) {
|
||||
|
|
@ -64,12 +64,12 @@ class Two_Factor_Extended_Role_Manager {
|
|||
*
|
||||
* @param int $user_id User ID.
|
||||
*
|
||||
* @return array Array of role slugs.
|
||||
* @return array<string> Array of role slugs.
|
||||
*/
|
||||
public static function get_user_roles( int $user_id ): array {
|
||||
$user = get_userdata( $user_id );
|
||||
|
||||
if ( ! $user || ! isset( $user->roles ) ) {
|
||||
if ( ! $user ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +130,7 @@ class Two_Factor_Extended_Role_Manager {
|
|||
* @param int $user_id User ID.
|
||||
* @param int $blog_id Blog ID (optional, defaults to current blog).
|
||||
*
|
||||
* @return array Array of role slugs for the specified blog.
|
||||
* @return array<string> Array of role slugs for the specified blog.
|
||||
*/
|
||||
public static function get_user_roles_for_blog( int $user_id, int $blog_id = 0 ): array {
|
||||
if ( ! is_multisite() ) {
|
||||
|
|
@ -148,8 +148,9 @@ class Two_Factor_Extended_Role_Manager {
|
|||
}
|
||||
|
||||
// Get roles for specific blog.
|
||||
$roles_key = $GLOBALS['wpdb']->get_blog_prefix( $blog_id ) . 'capabilities';
|
||||
$roles = isset( $user->{$roles_key} ) ? array_keys( $user->{$roles_key} ) : array();
|
||||
global $wpdb;
|
||||
$roles_key = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
|
||||
$roles = isset( $user->{$roles_key} ) && is_array( $user->{$roles_key} ) ? array_keys( $user->{$roles_key} ) : array();
|
||||
|
||||
return $roles;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue