Authors.php
9 months ago
Categories.php
9 months ago
Countries.php
6 months ago
DeviceBrowsers.php
9 months ago
DeviceOperatingSystems.php
9 months ago
DeviceTypes.php
9 months ago
FormConversions.php
6 months ago
LinkPatternConversions.php
6 months ago
LinkPatterns.php
9 months ago
PageTypes.php
9 months ago
ReferrerTypes.php
9 months ago
Authors.php
24 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP\ColumnOptions\Plugins; |
| 4 | |
| 5 | use IAWP\ColumnOptions\Option; |
| 6 | use IAWP\ColumnOptions\OptionsPlugin; |
| 7 | /** @internal */ |
| 8 | class Authors implements OptionsPlugin |
| 9 | { |
| 10 | public function get_options() : array |
| 11 | { |
| 12 | $roles_that_can_edit_posts = []; |
| 13 | foreach (\wp_roles()->roles as $role_name => $role_obj) { |
| 14 | if ($role_obj['capabilities']['edit_posts'] ?? \false) { |
| 15 | $roles_that_can_edit_posts[] = $role_name; |
| 16 | } |
| 17 | } |
| 18 | $authors = \get_users(['role__in' => $roles_that_can_edit_posts]); |
| 19 | return \array_map(function ($author) { |
| 20 | return new Option($author->ID, $author->display_name); |
| 21 | }, $authors); |
| 22 | } |
| 23 | } |
| 24 |