Roles + caps for various post types and pages. Closes #457.

This commit is contained in:
Mike Jolley 2012-01-09 13:14:36 +00:00
parent 9ec215d16e
commit cf1e36c347
3 changed files with 70 additions and 21 deletions

View File

@ -23,8 +23,8 @@ function woocommerce_admin_menu() {
add_menu_page(__('WooCommerce', 'woocommerce'), __('WooCommerce', 'woocommerce'), 'manage_woocommerce', 'woocommerce' , 'woocommerce_settings_page', $woocommerce->plugin_url() . '/assets/images/icons/menu_icon_wc.png', 55);
add_submenu_page('woocommerce', __('WooCommerce Settings', 'woocommerce'), __('Settings', 'woocommerce') , 'manage_woocommerce', 'woocommerce', 'woocommerce_settings_page');
add_submenu_page('woocommerce', __('Reports', 'woocommerce'), __('Reports', 'woocommerce') , 'manage_woocommerce', 'woocommerce_reports', 'woocommerce_reports_page');
add_submenu_page('edit.php?post_type=product', __('Attributes', 'woocommerce'), __('Attributes', 'woocommerce'), 'manage_categories', 'woocommerce_attributes', 'woocommerce_attributes_page');
add_submenu_page('woocommerce', __('Reports', 'woocommerce'), __('Reports', 'woocommerce') , 'view_woocommerce_reports', 'woocommerce_reports', 'woocommerce_reports_page');
add_submenu_page('edit.php?post_type=product', __('Attributes', 'woocommerce'), __('Attributes', 'woocommerce'), 'manage_woocommerce_products', 'woocommerce_attributes', 'woocommerce_attributes_page');
$print_css_on = array( 'toplevel_page_woocommerce', 'woocommerce_page_woocommerce_reports', 'product_page_woocommerce_attributes', 'edit-tags.php', 'edit.php', 'index.php', 'post-new.php', 'post.php' );

View File

@ -91,6 +91,7 @@ Yes you can! Join in on our GitHub repository :) https://github.com/woothemes/wo
* Moved template function contents to template files
* Added a simple, basic method of adding woocommerce support to themes using a woocommerce.php file based on page.php containing woocommerce_content()
* Moved woocommerce class into the main file
* Improved roles and capabilities for WooCommerce pages - more caps added for easier configuration
* Category ordering fix
* Made 'product' global, and auto filled when calling the_post - also remove this from the hooks. Certain themes may need to be updated.
* Changed woocommerce_breadcrumb args

View File

@ -409,11 +409,19 @@ class woocommerce {
'upload_files' => true,
'export' => true,
'import' => true,
'manage_woocommerce' => true
'manage_woocommerce' => true,
'manage_woocommerce_orders' => true,
'manage_woocommerce_coupons' => true,
'manage_woocommerce_products' => true,
'view_woocommerce_reports' => true
));
// Main Shop capabilities for admin
$wp_roles->add_cap( 'administrator', 'manage_woocommerce' );
$wp_roles->add_cap( 'administrator', 'manage_woocommerce_orders' );
$wp_roles->add_cap( 'administrator', 'manage_woocommerce_coupons' );
$wp_roles->add_cap( 'administrator', 'manage_woocommerce_products' );
$wp_roles->add_cap( 'administrator', 'view_woocommerce_reports' );
endif;
}
@ -478,6 +486,12 @@ class woocommerce {
),
'show_ui' => true,
'query_var' => true,
'capabilities' => array(
'manage_terms' => 'manage_woocommerce_products',
'edit_terms' => 'manage_woocommerce_products',
'delete_terms' => 'manage_woocommerce_products',
'assign_terms' => 'manage_woocommerce_products',
),
'rewrite' => array( 'slug' => $category_base . $category_slug, 'with_front' => false ),
)
);
@ -501,6 +515,12 @@ class woocommerce {
),
'show_ui' => true,
'query_var' => true,
'capabilities' => array(
'manage_terms' => 'manage_woocommerce_products',
'edit_terms' => 'manage_woocommerce_products',
'delete_terms' => 'manage_woocommerce_products',
'assign_terms' => 'manage_woocommerce_products',
),
'rewrite' => array( 'slug' => $category_base . $tag_slug, 'with_front' => false ),
)
);
@ -526,6 +546,12 @@ class woocommerce {
'show_ui' => true,
'show_in_nav_menus' => false,
'query_var' => $admin_only_query_var,
'capabilities' => array(
'manage_terms' => 'manage_woocommerce_products',
'edit_terms' => 'manage_woocommerce_products',
'delete_terms' => 'manage_woocommerce_products',
'assign_terms' => 'manage_woocommerce_products',
),
'rewrite' => false,
)
);
@ -617,6 +643,17 @@ class woocommerce {
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'capabilities' => array(
'publish_posts' => 'manage_woocommerce_products',
'edit_posts' => 'manage_woocommerce_products',
'edit_others_posts' => 'manage_woocommerce_products',
'delete_posts' => 'manage_woocommerce_products',
'delete_others_posts' => 'manage_woocommerce_products',
'read_private_posts' => 'manage_woocommerce_products',
'edit_post' => 'manage_woocommerce_products',
'delete_post' => 'manage_woocommerce_products',
'read_post' => 'manage_woocommerce_products'
),
'publicly_queryable' => true,
'exclude_from_search' => false,
'hierarchical' => true,
@ -649,6 +686,17 @@ class woocommerce {
'public' => true,
'show_ui' => false,
'capability_type' => 'post',
'capabilities' => array(
'publish_posts' => 'manage_woocommerce_products',
'edit_posts' => 'manage_woocommerce_products',
'edit_others_posts' => 'manage_woocommerce_products',
'delete_posts' => 'manage_woocommerce_products',
'delete_others_posts' => 'manage_woocommerce_products',
'read_private_posts' => 'manage_woocommerce_products',
'edit_post' => 'manage_woocommerce_products',
'delete_post' => 'manage_woocommerce_products',
'read_post' => 'manage_woocommerce_products'
),
'publicly_queryable' => true,
'exclude_from_search' => true,
'hierarchical' => true,
@ -681,15 +729,15 @@ class woocommerce {
'show_ui' => true,
'capability_type' => 'post',
'capabilities' => array(
'publish_posts' => 'manage_woocommerce',
'edit_posts' => 'manage_woocommerce',
'edit_others_posts' => 'manage_woocommerce',
'delete_posts' => 'manage_woocommerce',
'delete_others_posts'=> 'manage_woocommerce',
'read_private_posts'=> 'manage_woocommerce',
'edit_post' => 'manage_woocommerce',
'delete_post' => 'manage_woocommerce',
'read_post' => 'manage_woocommerce',
'publish_posts' => 'manage_woocommerce_orders',
'edit_posts' => 'manage_woocommerce_orders',
'edit_others_posts' => 'manage_woocommerce_orders',
'delete_posts' => 'manage_woocommerce_orders',
'delete_others_posts' => 'manage_woocommerce_orders',
'read_private_posts' => 'manage_woocommerce_orders',
'edit_post' => 'manage_woocommerce_orders',
'delete_post' => 'manage_woocommerce_orders',
'read_post' => 'manage_woocommerce_orders'
),
'publicly_queryable' => false,
'exclude_from_search' => true,
@ -725,15 +773,15 @@ class woocommerce {
'show_ui' => true,
'capability_type' => 'post',
'capabilities' => array(
'publish_posts' => 'manage_woocommerce',
'edit_posts' => 'manage_woocommerce',
'edit_others_posts' => 'manage_woocommerce',
'delete_posts' => 'manage_woocommerce',
'delete_others_posts'=> 'manage_woocommerce',
'read_private_posts'=> 'manage_woocommerce',
'edit_post' => 'manage_woocommerce',
'delete_post' => 'manage_woocommerce',
'read_post' => 'manage_woocommerce',
'publish_posts' => 'manage_woocommerce_coupons',
'edit_posts' => 'manage_woocommerce_coupons',
'edit_others_posts' => 'manage_woocommerce_coupons',
'delete_posts' => 'manage_woocommerce_coupons',
'delete_others_posts' => 'manage_woocommerce_coupons',
'read_private_posts' => 'manage_woocommerce_coupons',
'edit_post' => 'manage_woocommerce_coupons',
'delete_post' => 'manage_woocommerce_coupons',
'read_post' => 'manage_woocommerce_coupons'
),
'publicly_queryable' => false,
'exclude_from_search' => true,