roles : array(); $user_id = ( $user instanceof \WP_User ) ? (int) $user->ID : 0; if ( in_array( 'administrator', $roles, true ) || ( function_exists( 'is_super_admin' ) && is_super_admin( $user_id ) ) ) { $allcaps[ self::VIEW ] = true; $allcaps[ self::MANAGE ] = true; $allcaps[ self::EXPORT ] = true; $allcaps[ self::DELETE ] = true; return $allcaps; } $settings = Settings::all(); if ( ! empty( $settings['editors_can_view_content'] ) && ( in_array( 'editor', $roles, true ) || in_array( 'shop_manager', $roles, true ) ) ) { $allcaps[ self::VIEW ] = true; } return $allcaps; } /** * Persist administrator capabilities on each site. */ public static function grant_roles() { $role = get_role( 'administrator' ); if ( ! $role ) { return; } foreach ( array( self::VIEW, self::MANAGE, self::EXPORT, self::DELETE ) as $cap ) { $role->add_cap( $cap ); } } /** * Remove stored capabilities. */ public static function remove_roles() { $role = get_role( 'administrator' ); if ( ! $role ) { return; } foreach ( array( self::VIEW, self::MANAGE, self::EXPORT, self::DELETE ) as $cap ) { $role->remove_cap( $cap ); } } }