Aggregate.php
3 days ago
BeaverBuilderGroups.php
3 days ago
BuddyPressGroups.php
3 days ago
DefaultGroups.php
3 days ago
EventsCalendarGroups.php
3 days ago
GravityFormsGroups.php
3 days ago
JetEngineGroups.php
3 days ago
MediaLibraryAssistantGroups.php
3 days ago
MetaBoxGroups.php
3 days ago
WooCommerceGroups.php
3 days ago
DefaultGroups.php
66 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Admin\MenuGroupFactory; |
| 6 | |
| 7 | use AC\Admin\MenuGroupFactory; |
| 8 | use AC\Admin\Type\MenuGroup; |
| 9 | use AC\TableScreen; |
| 10 | |
| 11 | class DefaultGroups implements MenuGroupFactory |
| 12 | { |
| 13 | public function create(TableScreen $table_screen): ?MenuGroup |
| 14 | { |
| 15 | switch ($table_screen) { |
| 16 | case $table_screen instanceof TableScreen\Post: |
| 17 | $post_type = get_post_type_object((string)$table_screen->get_post_type()); |
| 18 | |
| 19 | if (! $post_type) { |
| 20 | return null; |
| 21 | } |
| 22 | |
| 23 | if ('post' === $post_type->name) { |
| 24 | return $this->get_default_group(1); |
| 25 | } |
| 26 | |
| 27 | if ('page' === $post_type->name) { |
| 28 | return $this->get_default_group(2); |
| 29 | } |
| 30 | |
| 31 | if ($post_type->show_in_menu) { |
| 32 | return new MenuGroup( |
| 33 | 'post', |
| 34 | __('Post Types', 'codepress-admin-columns'), |
| 35 | 7, |
| 36 | 'material-description' |
| 37 | ); |
| 38 | } |
| 39 | |
| 40 | return new MenuGroup( |
| 41 | 'post-hidden', |
| 42 | sprintf( |
| 43 | '%s (%s)', |
| 44 | __('Custom Post Types', 'codepress-admin-columns'), |
| 45 | __('hidden', 'codepress-admin-columns') |
| 46 | ), |
| 47 | 30 |
| 48 | ); |
| 49 | case $table_screen instanceof TableScreen\User: |
| 50 | return $this->get_default_group(4); |
| 51 | case $table_screen instanceof TableScreen\Media: |
| 52 | return $this->get_default_group(5); |
| 53 | case $table_screen instanceof TableScreen\Comment: |
| 54 | return $this->get_default_group(6); |
| 55 | default: |
| 56 | return null; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | private function get_default_group(int $prio): MenuGroup |
| 61 | { |
| 62 | return new MenuGroup('default', __('Default'), $prio, 'dashicons-wordpress'); |
| 63 | } |
| 64 | |
| 65 | } |
| 66 |