41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
|
|
class Wiaas_Product {
|
|
|
|
public static function init() {
|
|
require_once dirname( __FILE__ ) . '/product/class-wiaas-product-category.php';
|
|
require_once dirname( __FILE__ ) . '/product/class-wiaas-product-supplier.php';
|
|
|
|
add_filter('woocommerce_register_post_type_product', array(__CLASS__, 'manage_product_settings'));
|
|
}
|
|
|
|
/**
|
|
* Update product type settins before it is created:
|
|
* - Define capabilities for editing products so we can easily control read/edit/create access for them
|
|
* - Declare fields supported by product
|
|
*
|
|
* @param $args
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public static function manage_product_settings($args) {
|
|
|
|
$args['capabilities'] = array(
|
|
'edit_post' => 'edit_product',
|
|
'read_post' => 'read_product',
|
|
'delete_post' => 'delete_product',
|
|
'edit_posts' => 'edit_products',
|
|
'edit_others_posts' => 'edit_others_products',
|
|
'publish_posts' => 'publish_products',
|
|
'read_private_posts' => 'read_private_products',
|
|
'create_posts' => 'create_products', // use `create_products` instead of default `edit_products`
|
|
);
|
|
|
|
$args['supports'] = array( 'title', 'thumbnail' );
|
|
|
|
|
|
return $args;
|
|
}
|
|
}
|
|
|
|
Wiaas_Product::init(); |