| 1 |
<?php |
| 2 |
/** |
| 3 |
* OpenStation App Framework — WordPress Auth adapter. |
| 4 |
* |
| 5 |
* @package OpenStation |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace OpenStation\App\WordPress; |
| 9 |
|
| 10 |
use OpenStation\App\Contracts\Auth as AuthContract; |
| 11 |
|
| 12 |
defined( 'ABSPATH' ) || exit; |
| 13 |
|
| 14 |
/** |
| 15 |
* The current WordPress user. |
| 16 |
*/ |
| 17 |
final class Auth implements AuthContract { |
| 18 |
|
| 19 |
/** {@inheritDoc} */ |
| 20 |
public function user_id() { |
| 21 |
return (int) get_current_user_id(); |
| 22 |
} |
| 23 |
|
| 24 |
/** {@inheritDoc} */ |
| 25 |
public function is_logged_in() { |
| 26 |
return is_user_logged_in(); |
| 27 |
} |
| 28 |
|
| 29 |
/** {@inheritDoc} */ |
| 30 |
public function can( $capability, ...$args ) { |
| 31 |
return current_user_can( (string) $capability, ...$args ); |
| 32 |
} |
| 33 |
} |
| 34 |
|