I've made Woocommerce product variations show up in the admin main menu as a "post type list".
add_filter('woocommerce_register_post_type_product_variation', 'my_func1');
function my_func1($arr){
$arr['public'] = true;
$arr['supports'] = array('title', 'editor', 'custom-fields');
$arr['menu_icon'] = 'dashicons-calendar-alt';
$arr['menu_name'] = 'Dates';
$arr['label'] = 'Dates';
return $arr;
}
When looking at the post-type admin page in debug mode I get:
Notice: Undefined property: stdClass::$delete_posts in /wp-admin/includes/class-wp-posts-list-table.php on line 400
If I var_dump at line 392 in class-wp-posts-list-table.php: var_dump($post_type_obj);
The result is an object without "delete_posts" defined, only "delete_post" defined.
["cap"]=> object(stdClass)#16026 (8) {
["edit_post"]=> string(12) "edit_product"
["read_post"]=> string(12) "read_product"
["delete_post"]=> string(14) "delete_product"
["edit_posts"]=> string(13) "edit_products"
["edit_others_posts"]=> string(20) "edit_others_products"
["publish_posts"]=> string(16) "publish_products"
["read_private_posts"]=> string(21) "read_private_products"
["create_posts"]=> string(13) "edit_products" }`
Is this an oversight? Why isn't this part of capability_type='product'?
Where does that capability get registered? How do I register the capability of "delete_posts" to an existing post_type registered by Woocommerce core?
Seems it helped to read the wordpress codex more thouroughly...
You can set map_meta_cap
in the register hook:
add_filter('woocommerce_register_post_type_product_variation', 'my_func1');
function my_func1($arr){
$arr['public'] = true;
$arr['supports'] = array('title', 'editor', 'custom-fields');
$arr['menu_icon'] = 'dashicons-calendar-alt';
$arr['menu_name'] = 'Dates';
$arr['label'] = 'Dates';
$arr['map_meta_cap'] = true;
return $arr;
}
This picks up the capabilites I seemed to be lacking.