| 1 |
<?php |
| 2 |
|
| 3 |
namespace EssentialBlocks\API; |
| 4 |
|
| 5 |
class Common extends Base |
| 6 |
{ |
| 7 |
/** |
| 8 |
* Register REST Routes |
| 9 |
* |
| 10 |
* @return void |
| 11 |
*/ |
| 12 |
public function register() |
| 13 |
{ |
| 14 |
$this->get('roles', [ |
| 15 |
'callback' => [$this, 'get_roles'], |
| 16 |
'permission_callback' => [$this, 'check_edit_page_permission'] |
| 17 |
]); |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* Check if user has permission to edit pages |
| 22 |
* |
| 23 |
* @return bool |
| 24 |
*/ |
| 25 |
public function check_edit_page_permission() |
| 26 |
{ |
| 27 |
return current_user_can('edit_posts'); |
| 28 |
} |
| 29 |
|
| 30 |
public function get_roles() |
| 31 |
{ |
| 32 |
global $wp_roles; |
| 33 |
return rest_ensure_response($wp_roles->roles); |
| 34 |
} |
| 35 |
} |
| 36 |
|