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
WooCommerceGroups.php
55 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\PostType; |
| 10 | use AC\TableScreen; |
| 11 | use AC\Taxonomy; |
| 12 | |
| 13 | class WooCommerceGroups implements MenuGroupFactory |
| 14 | { |
| 15 | public function create(TableScreen $table_screen): ?MenuGroup |
| 16 | { |
| 17 | $table_id = (string)$table_screen->get_id(); |
| 18 | |
| 19 | if ( |
| 20 | $table_id === 'wc_order' || |
| 21 | $table_id === 'wc_order_subscription' || |
| 22 | $table_id === 'shop_subscription' |
| 23 | ) { |
| 24 | return new MenuGroup('woocommerce', __('WooCommerce'), 13, 'cpacicon-woo'); |
| 25 | } |
| 26 | |
| 27 | if ($table_screen instanceof PostType) { |
| 28 | $post_type = (string)$table_screen->get_post_type(); |
| 29 | |
| 30 | if (in_array($post_type, ['product', 'shop_order', 'product_variation'], true)) { |
| 31 | return new MenuGroup('woocommerce', __('WooCommerce'), 13, 'cpacicon-woo'); |
| 32 | } |
| 33 | |
| 34 | if ('shop_coupon' === $post_type) { |
| 35 | return new MenuGroup('woocommerce', __('WooCommerce'), 14, 'cpacicon-woo'); |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | if ($table_screen instanceof Taxonomy) { |
| 40 | $taxonomy = (string)$table_screen->get_taxonomy(); |
| 41 | |
| 42 | if (in_array($taxonomy, ['product_tag', 'product_cat'], true)) { |
| 43 | return new MenuGroup('woocommerce-taxonomy', __('WooCommerce Taxonomies'), 14, 'cpacicon-woo'); |
| 44 | } |
| 45 | |
| 46 | if (function_exists('taxonomy_is_product_attribute') && taxonomy_is_product_attribute($taxonomy)) { |
| 47 | return new MenuGroup('woocommerce-attributes', __('WooCommerce Attributes'), 14, 'cpacicon-woo'); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | return null; |
| 52 | } |
| 53 | |
| 54 | } |
| 55 |