array( 'name' => __( 'Option Groups', 'shapeoptions' ), 'singular_name' => __( 'Option Group', 'shapeoptions' ), 'add_new' => __( 'Add New Group', 'shapeoptions' ), 'add_new_item' => __( 'Add New Option Group', 'shapeoptions' ), 'edit_item' => __( 'Edit Option Group', 'shapeoptions' ), 'all_items' => __( 'Option Groups', 'shapeoptions' ), 'menu_name' => __( 'ShapeOptions', 'shapeoptions' ), 'not_found' => __( 'No option groups yet. Create one to add options to your products.', 'shapeoptions' ), ), 'public' => false, 'show_ui' => true, 'show_in_menu' => true, 'menu_position' => 56, 'menu_icon' => 'dashicons-forms', 'capability_type' => array( 'shapeoptions_group', 'shapeoptions_groups' ), 'capabilities' => self::capabilities(), 'map_meta_cap' => true, 'supports' => array( 'title', 'page-attributes' ), ) ); } /** * Map the option-group PRIMITIVE capabilities onto `manage_woocommerce`. * * Shop managers and administrators have it; Editors, Authors and * Contributors do not. With `map_meta_cap` on, WordPress derives the * per-object meta caps (`edit_shapeoptions_group` and friends) from * `capability_type` and translates them into these primitives, so the * builder's `current_user_can( 'edit_post', $id )` check resolves here too. * * The three meta caps — `edit_post`, `read_post`, `delete_post` — are * deliberately NOT listed. `_post_type_meta_capabilities()` records whatever * they point at in the global meta-cap map, so mapping them to * `manage_woocommerce` would make WordPress treat *every* * `current_user_can( 'manage_woocommerce' )` call anywhere on the site as a * meta capability needing a post ID — which then fails for everyone and * takes out this plugin's and WooCommerce's admin menus. Leave them to be * derived from `capability_type`, which yields strings nothing else checks. * * @return array */ public static function capabilities() { $cap = 'manage_woocommerce'; return array( 'edit_posts' => $cap, 'edit_others_posts' => $cap, 'delete_posts' => $cap, 'delete_others_posts' => $cap, 'delete_private_posts' => $cap, 'delete_published_posts' => $cap, 'publish_posts' => $cap, 'read_private_posts' => $cap, 'edit_private_posts' => $cap, 'edit_published_posts' => $cap, 'create_posts' => $cap, ); } } endif;