WC_Post_types

WC_Post_types Class.

Defined (1)

The class is defined in the following location(s).

/includes/class-wc-post-types.php  
  1. class WC_Post_types { 
  2.  
  3. /** 
  4. * Hook in methods. 
  5. */ 
  6. public static function init() { 
  7. add_action( 'init', array( __CLASS__, 'register_taxonomies' ), 5 ); 
  8. add_action( 'init', array( __CLASS__, 'register_post_types' ), 5 ); 
  9. add_action( 'init', array( __CLASS__, 'register_post_status' ), 9 ); 
  10. add_action( 'init', array( __CLASS__, 'support_jetpack_omnisearch' ) ); 
  11. add_filter( 'rest_api_allowed_post_types', array( __CLASS__, 'rest_api_allowed_post_types' ) ); 
  12. add_action( 'woocommerce_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) ); 
  13.  
  14. /** 
  15. * Register core taxonomies. 
  16. */ 
  17. public static function register_taxonomies() { 
  18.  
  19. if ( ! is_blog_installed() ) { 
  20. return; 
  21.  
  22. if ( taxonomy_exists( 'product_type' ) ) { 
  23. return; 
  24.  
  25. do_action( 'woocommerce_register_taxonomy' ); 
  26.  
  27. $permalinks = wc_get_permalink_structure(); 
  28.  
  29. register_taxonomy( 'product_type',  
  30. apply_filters( 'woocommerce_taxonomy_objects_product_type', array( 'product' ) ),  
  31. apply_filters( 'woocommerce_taxonomy_args_product_type', array( 
  32. 'hierarchical' => false,  
  33. 'show_ui' => false,  
  34. 'show_in_nav_menus' => false,  
  35. 'query_var' => is_admin(),  
  36. 'rewrite' => false,  
  37. 'public' => false,  
  38. ) ) 
  39. ); 
  40.  
  41. register_taxonomy( 'product_visibility',  
  42. apply_filters( 'woocommerce_taxonomy_objects_product_visibility', array( 'product', 'product_variation' ) ),  
  43. apply_filters( 'woocommerce_taxonomy_args_product_visibility', array( 
  44. 'hierarchical' => false,  
  45. 'show_ui' => false,  
  46. 'show_in_nav_menus' => false,  
  47. 'query_var' => is_admin(),  
  48. 'rewrite' => false,  
  49. 'public' => false,  
  50. ) ) 
  51. ); 
  52.  
  53. register_taxonomy( 'product_cat',  
  54. apply_filters( 'woocommerce_taxonomy_objects_product_cat', array( 'product' ) ),  
  55. apply_filters( 'woocommerce_taxonomy_args_product_cat', array( 
  56. 'hierarchical' => true,  
  57. 'update_count_callback' => '_wc_term_recount',  
  58. 'label' => __( 'Categories', 'woocommerce' ),  
  59. 'labels' => array( 
  60. 'name' => __( 'Product categories', 'woocommerce' ),  
  61. 'singular_name' => __( 'Category', 'woocommerce' ),  
  62. 'menu_name' => _x( 'Categories', 'Admin menu name', 'woocommerce' ),  
  63. 'search_items' => __( 'Search categories', 'woocommerce' ),  
  64. 'all_items' => __( 'All categories', 'woocommerce' ),  
  65. 'parent_item' => __( 'Parent category', 'woocommerce' ),  
  66. 'parent_item_colon' => __( 'Parent category:', 'woocommerce' ),  
  67. 'edit_item' => __( 'Edit category', 'woocommerce' ),  
  68. 'update_item' => __( 'Update category', 'woocommerce' ),  
  69. 'add_new_item' => __( 'Add new category', 'woocommerce' ),  
  70. 'new_item_name' => __( 'New category name', 'woocommerce' ),  
  71. 'not_found' => __( 'No categories found', 'woocommerce' ),  
  72. ),  
  73. 'show_ui' => true,  
  74. 'query_var' => true,  
  75. 'capabilities' => array( 
  76. 'manage_terms' => 'manage_product_terms',  
  77. 'edit_terms' => 'edit_product_terms',  
  78. 'delete_terms' => 'delete_product_terms',  
  79. 'assign_terms' => 'assign_product_terms',  
  80. ),  
  81. 'rewrite' => array( 
  82. 'slug' => $permalinks['category_rewrite_slug'],  
  83. 'with_front' => false,  
  84. 'hierarchical' => true,  
  85. ),  
  86. ) ) 
  87. ); 
  88.  
  89. register_taxonomy( 'product_tag',  
  90. apply_filters( 'woocommerce_taxonomy_objects_product_tag', array( 'product' ) ),  
  91. apply_filters( 'woocommerce_taxonomy_args_product_tag', array( 
  92. 'hierarchical' => false,  
  93. 'update_count_callback' => '_wc_term_recount',  
  94. 'label' => __( 'Product tags', 'woocommerce' ),  
  95. 'labels' => array( 
  96. 'name' => __( 'Product tags', 'woocommerce' ),  
  97. 'singular_name' => __( 'Tag', 'woocommerce' ),  
  98. 'menu_name' => _x( 'Tags', 'Admin menu name', 'woocommerce' ),  
  99. 'search_items' => __( 'Search tags', 'woocommerce' ),  
  100. 'all_items' => __( 'All tags', 'woocommerce' ),  
  101. 'edit_item' => __( 'Edit tag', 'woocommerce' ),  
  102. 'update_item' => __( 'Update tag', 'woocommerce' ),  
  103. 'add_new_item' => __( 'Add new tag', 'woocommerce' ),  
  104. 'new_item_name' => __( 'New tag name', 'woocommerce' ),  
  105. 'popular_items' => __( 'Popular tags', 'woocommerce' ),  
  106. 'separate_items_with_commas' => __( 'Separate tags with commas', 'woocommerce' ),  
  107. 'add_or_remove_items' => __( 'Add or remove tags', 'woocommerce' ),  
  108. 'choose_from_most_used' => __( 'Choose from the most used tags', 'woocommerce' ),  
  109. 'not_found' => __( 'No tags found', 'woocommerce' ),  
  110. ),  
  111. 'show_ui' => true,  
  112. 'query_var' => true,  
  113. 'capabilities' => array( 
  114. 'manage_terms' => 'manage_product_terms',  
  115. 'edit_terms' => 'edit_product_terms',  
  116. 'delete_terms' => 'delete_product_terms',  
  117. 'assign_terms' => 'assign_product_terms',  
  118. ),  
  119. 'rewrite' => array( 
  120. 'slug' => $permalinks['tag_rewrite_slug'],  
  121. 'with_front' => false,  
  122. ),  
  123. ) ) 
  124. ); 
  125.  
  126. register_taxonomy( 'product_shipping_class',  
  127. apply_filters( 'woocommerce_taxonomy_objects_product_shipping_class', array( 'product', 'product_variation' ) ),  
  128. apply_filters( 'woocommerce_taxonomy_args_product_shipping_class', array( 
  129. 'hierarchical' => false,  
  130. 'update_count_callback' => '_update_post_term_count',  
  131. 'label' => __( 'Shipping classes', 'woocommerce' ),  
  132. 'labels' => array( 
  133. 'name' => __( 'Product shipping classes', 'woocommerce' ),  
  134. 'singular_name' => __( 'Shipping class', 'woocommerce' ),  
  135. 'menu_name' => _x( 'Shipping classes', 'Admin menu name', 'woocommerce' ),  
  136. 'search_items' => __( 'Search shipping classes', 'woocommerce' ),  
  137. 'all_items' => __( 'All shipping classes', 'woocommerce' ),  
  138. 'parent_item' => __( 'Parent shipping class', 'woocommerce' ),  
  139. 'parent_item_colon' => __( 'Parent shipping class:', 'woocommerce' ),  
  140. 'edit_item' => __( 'Edit shipping class', 'woocommerce' ),  
  141. 'update_item' => __( 'Update shipping class', 'woocommerce' ),  
  142. 'add_new_item' => __( 'Add new shipping class', 'woocommerce' ),  
  143. 'new_item_name' => __( 'New shipping class Name', 'woocommerce' ),  
  144. ),  
  145. 'show_ui' => false,  
  146. 'show_in_quick_edit' => false,  
  147. 'show_in_nav_menus' => false,  
  148. 'query_var' => is_admin(),  
  149. 'capabilities' => array( 
  150. 'manage_terms' => 'manage_product_terms',  
  151. 'edit_terms' => 'edit_product_terms',  
  152. 'delete_terms' => 'delete_product_terms',  
  153. 'assign_terms' => 'assign_product_terms',  
  154. ),  
  155. 'rewrite' => false,  
  156. ) ) 
  157. ); 
  158.  
  159. global $wc_product_attributes; 
  160.  
  161. $wc_product_attributes = array(); 
  162.  
  163. if ( $attribute_taxonomies = wc_get_attribute_taxonomies() ) { 
  164. foreach ( $attribute_taxonomies as $tax ) { 
  165. if ( $name = wc_attribute_taxonomy_name( $tax->attribute_name ) ) { 
  166. $tax->attribute_public = absint( isset( $tax->attribute_public ) ? $tax->attribute_public : 1 ); 
  167. $label = ! empty( $tax->attribute_label ) ? $tax->attribute_label : $tax->attribute_name; 
  168. $wc_product_attributes[ $name ] = $tax; 
  169. $taxonomy_data = array( 
  170. 'hierarchical' => false,  
  171. 'update_count_callback' => '_update_post_term_count',  
  172. 'labels' => array( 
  173. 'name' => sprintf( _x( 'Product %s', 'Product Attribute', 'woocommerce' ), $label ),  
  174. 'singular_name' => $label,  
  175. 'search_items' => sprintf( __( 'Search %s', 'woocommerce' ), $label ),  
  176. 'all_items' => sprintf( __( 'All %s', 'woocommerce' ), $label ),  
  177. 'parent_item' => sprintf( __( 'Parent %s', 'woocommerce' ), $label ),  
  178. 'parent_item_colon' => sprintf( __( 'Parent %s:', 'woocommerce' ), $label ),  
  179. 'edit_item' => sprintf( __( 'Edit %s', 'woocommerce' ), $label ),  
  180. 'update_item' => sprintf( __( 'Update %s', 'woocommerce' ), $label ),  
  181. 'add_new_item' => sprintf( __( 'Add new %s', 'woocommerce' ), $label ),  
  182. 'new_item_name' => sprintf( __( 'New %s', 'woocommerce' ), $label ),  
  183. 'not_found' => sprintf( __( 'No "%s" found', 'woocommerce' ), $label ),  
  184. ),  
  185. 'show_ui' => true,  
  186. 'show_in_quick_edit' => false,  
  187. 'show_in_menu' => false,  
  188. 'show_in_nav_menus' => false,  
  189. 'meta_box_cb' => false,  
  190. 'query_var' => 1 === $tax->attribute_public,  
  191. 'rewrite' => false,  
  192. 'sort' => false,  
  193. 'public' => 1 === $tax->attribute_public,  
  194. 'show_in_nav_menus' => 1 === $tax->attribute_public && apply_filters( 'woocommerce_attribute_show_in_nav_menus', false, $name ),  
  195. 'capabilities' => array( 
  196. 'manage_terms' => 'manage_product_terms',  
  197. 'edit_terms' => 'edit_product_terms',  
  198. 'delete_terms' => 'delete_product_terms',  
  199. 'assign_terms' => 'assign_product_terms',  
  200. ),  
  201. ); 
  202.  
  203. if ( 1 === $tax->attribute_public && sanitize_title( $tax->attribute_name ) ) { 
  204. $taxonomy_data['rewrite'] = array( 
  205. 'slug' => trailingslashit( $permalinks['attribute_rewrite_slug'] ) . sanitize_title( $tax->attribute_name ),  
  206. 'with_front' => false,  
  207. 'hierarchical' => true,  
  208. ); 
  209.  
  210. register_taxonomy( $name, apply_filters( "woocommerce_taxonomy_objects_{$name}", array( 'product' ) ), apply_filters( "woocommerce_taxonomy_args_{$name}", $taxonomy_data ) ); 
  211.  
  212. do_action( 'woocommerce_after_register_taxonomy' ); 
  213.  
  214. /** 
  215. * Register core post types. 
  216. */ 
  217. public static function register_post_types() { 
  218. if ( ! is_blog_installed() || post_type_exists( 'product' ) ) { 
  219. return; 
  220.  
  221. do_action( 'woocommerce_register_post_type' ); 
  222.  
  223. $permalinks = wc_get_permalink_structure(); 
  224.  
  225. register_post_type( 'product',  
  226. apply_filters( 'woocommerce_register_post_type_product',  
  227. array( 
  228. 'labels' => array( 
  229. 'name' => __( 'Products', 'woocommerce' ),  
  230. 'singular_name' => __( 'Product', 'woocommerce' ),  
  231. 'menu_name' => _x( 'Products', 'Admin menu name', 'woocommerce' ),  
  232. 'add_new' => __( 'Add product', 'woocommerce' ),  
  233. 'add_new_item' => __( 'Add new product', 'woocommerce' ),  
  234. 'edit' => __( 'Edit', 'woocommerce' ),  
  235. 'edit_item' => __( 'Edit product', 'woocommerce' ),  
  236. 'new_item' => __( 'New product', 'woocommerce' ),  
  237. 'view' => __( 'View product', 'woocommerce' ),  
  238. 'view_item' => __( 'View product', 'woocommerce' ),  
  239. 'search_items' => __( 'Search products', 'woocommerce' ),  
  240. 'not_found' => __( 'No products found', 'woocommerce' ),  
  241. 'not_found_in_trash' => __( 'No products found in trash', 'woocommerce' ),  
  242. 'parent' => __( 'Parent product', 'woocommerce' ),  
  243. 'featured_image' => __( 'Product image', 'woocommerce' ),  
  244. 'set_featured_image' => __( 'Set product image', 'woocommerce' ),  
  245. 'remove_featured_image' => __( 'Remove product image', 'woocommerce' ),  
  246. 'use_featured_image' => __( 'Use as product image', 'woocommerce' ),  
  247. 'insert_into_item' => __( 'Insert into product', 'woocommerce' ),  
  248. 'uploaded_to_this_item' => __( 'Uploaded to this product', 'woocommerce' ),  
  249. 'filter_items_list' => __( 'Filter products', 'woocommerce' ),  
  250. 'items_list_navigation' => __( 'Products navigation', 'woocommerce' ),  
  251. 'items_list' => __( 'Products list', 'woocommerce' ),  
  252. ),  
  253. 'description' => __( 'This is where you can add new products to your store.', 'woocommerce' ),  
  254. 'public' => true,  
  255. 'show_ui' => true,  
  256. 'capability_type' => 'product',  
  257. 'map_meta_cap' => true,  
  258. 'publicly_queryable' => true,  
  259. 'exclude_from_search' => false,  
  260. 'hierarchical' => false, // Hierarchical causes memory issues - WP loads all records! 
  261. 'rewrite' => $permalinks['product_rewrite_slug'] ? array( 'slug' => $permalinks['product_rewrite_slug'], 'with_front' => false, 'feeds' => true ) : false,  
  262. 'query_var' => true,  
  263. 'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'comments', 'custom-fields', 'publicize', 'wpcom-markdown' ),  
  264. 'has_archive' => ( $shop_page_id = wc_get_page_id( 'shop' ) ) && get_post( $shop_page_id ) ? get_page_uri( $shop_page_id ) : 'shop',  
  265. 'show_in_nav_menus' => true,  
  266. 'show_in_rest' => true,  
  267. ); 
  268.  
  269. register_post_type( 'product_variation',  
  270. apply_filters( 'woocommerce_register_post_type_product_variation',  
  271. array( 
  272. 'label' => __( 'Variations', 'woocommerce' ),  
  273. 'public' => false,  
  274. 'hierarchical' => false,  
  275. 'supports' => false,  
  276. 'capability_type' => 'product',  
  277. 'rewrite' => false,  
  278. ); 
  279.  
  280. wc_register_order_type( 
  281. 'shop_order',  
  282. apply_filters( 'woocommerce_register_post_type_shop_order',  
  283. array( 
  284. 'labels' => array( 
  285. 'name' => __( 'Orders', 'woocommerce' ),  
  286. 'singular_name' => _x( 'Order', 'shop_order post type singular name', 'woocommerce' ),  
  287. 'add_new' => __( 'Add order', 'woocommerce' ),  
  288. 'add_new_item' => __( 'Add new order', 'woocommerce' ),  
  289. 'edit' => __( 'Edit', 'woocommerce' ),  
  290. 'edit_item' => __( 'Edit order', 'woocommerce' ),  
  291. 'new_item' => __( 'New order', 'woocommerce' ),  
  292. 'view' => __( 'View order', 'woocommerce' ),  
  293. 'view_item' => __( 'View order', 'woocommerce' ),  
  294. 'search_items' => __( 'Search orders', 'woocommerce' ),  
  295. 'not_found' => __( 'No orders found', 'woocommerce' ),  
  296. 'not_found_in_trash' => __( 'No orders found in trash', 'woocommerce' ),  
  297. 'parent' => __( 'Parent orders', 'woocommerce' ),  
  298. 'menu_name' => _x( 'Orders', 'Admin menu name', 'woocommerce' ),  
  299. 'filter_items_list' => __( 'Filter orders', 'woocommerce' ),  
  300. 'items_list_navigation' => __( 'Orders navigation', 'woocommerce' ),  
  301. 'items_list' => __( 'Orders list', 'woocommerce' ),  
  302. ),  
  303. 'description' => __( 'This is where store orders are stored.', 'woocommerce' ),  
  304. 'public' => false,  
  305. 'show_ui' => true,  
  306. 'capability_type' => 'shop_order',  
  307. 'map_meta_cap' => true,  
  308. 'publicly_queryable' => false,  
  309. 'exclude_from_search' => true,  
  310. 'show_in_menu' => current_user_can( 'manage_woocommerce' ) ? 'woocommerce' : true,  
  311. 'hierarchical' => false,  
  312. 'show_in_nav_menus' => false,  
  313. 'rewrite' => false,  
  314. 'query_var' => false,  
  315. 'supports' => array( 'title', 'comments', 'custom-fields' ),  
  316. 'has_archive' => false,  
  317. ); 
  318.  
  319. wc_register_order_type( 
  320. 'shop_order_refund',  
  321. apply_filters( 'woocommerce_register_post_type_shop_order_refund',  
  322. array( 
  323. 'label' => __( 'Refunds', 'woocommerce' ),  
  324. 'capability_type' => 'shop_order',  
  325. 'public' => false,  
  326. 'hierarchical' => false,  
  327. 'supports' => false,  
  328. 'exclude_from_orders_screen' => false,  
  329. 'add_order_meta_boxes' => false,  
  330. 'exclude_from_order_count' => true,  
  331. 'exclude_from_order_views' => false,  
  332. 'exclude_from_order_reports' => false,  
  333. 'exclude_from_order_sales_reports' => true,  
  334. 'class_name' => 'WC_Order_Refund',  
  335. 'rewrite' => false,  
  336. ); 
  337.  
  338. if ( 'yes' == get_option( 'woocommerce_enable_coupons' ) ) { 
  339. register_post_type( 'shop_coupon',  
  340. apply_filters( 'woocommerce_register_post_type_shop_coupon',  
  341. array( 
  342. 'labels' => array( 
  343. 'name' => __( 'Coupons', 'woocommerce' ),  
  344. 'singular_name' => __( 'Coupon', 'woocommerce' ),  
  345. 'menu_name' => _x( 'Coupons', 'Admin menu name', 'woocommerce' ),  
  346. 'add_new' => __( 'Add coupon', 'woocommerce' ),  
  347. 'add_new_item' => __( 'Add new coupon', 'woocommerce' ),  
  348. 'edit' => __( 'Edit', 'woocommerce' ),  
  349. 'edit_item' => __( 'Edit coupon', 'woocommerce' ),  
  350. 'new_item' => __( 'New coupon', 'woocommerce' ),  
  351. 'view' => __( 'View coupons', 'woocommerce' ),  
  352. 'view_item' => __( 'View coupon', 'woocommerce' ),  
  353. 'search_items' => __( 'Search coupons', 'woocommerce' ),  
  354. 'not_found' => __( 'No coupons found', 'woocommerce' ),  
  355. 'not_found_in_trash' => __( 'No coupons found in trash', 'woocommerce' ),  
  356. 'parent' => __( 'Parent coupon', 'woocommerce' ),  
  357. 'filter_items_list' => __( 'Filter coupons', 'woocommerce' ),  
  358. 'items_list_navigation' => __( 'Coupons navigation', 'woocommerce' ),  
  359. 'items_list' => __( 'Coupons list', 'woocommerce' ),  
  360. ),  
  361. 'description' => __( 'This is where you can add new coupons that customers can use in your store.', 'woocommerce' ),  
  362. 'public' => false,  
  363. 'show_ui' => true,  
  364. 'capability_type' => 'shop_coupon',  
  365. 'map_meta_cap' => true,  
  366. 'publicly_queryable' => false,  
  367. 'exclude_from_search' => true,  
  368. 'show_in_menu' => current_user_can( 'manage_woocommerce' ) ? 'woocommerce' : true,  
  369. 'hierarchical' => false,  
  370. 'rewrite' => false,  
  371. 'query_var' => false,  
  372. 'supports' => array( 'title' ),  
  373. 'show_in_nav_menus' => false,  
  374. 'show_in_admin_bar' => true,  
  375. ); 
  376.  
  377. register_post_type( 'shop_webhook',  
  378. apply_filters( 'woocommerce_register_post_type_shop_webhook',  
  379. array( 
  380. 'labels' => array( 
  381. 'name' => __( 'Webhooks', 'woocommerce' ),  
  382. 'singular_name' => __( 'Webhook', 'woocommerce' ),  
  383. 'menu_name' => _x( 'Webhooks', 'Admin menu name', 'woocommerce' ),  
  384. 'add_new' => __( 'Add webhook', 'woocommerce' ),  
  385. 'add_new_item' => __( 'Add new webhook', 'woocommerce' ),  
  386. 'edit' => __( 'Edit', 'woocommerce' ),  
  387. 'edit_item' => __( 'Edit webhook', 'woocommerce' ),  
  388. 'new_item' => __( 'New webhook', 'woocommerce' ),  
  389. 'view' => __( 'View webhooks', 'woocommerce' ),  
  390. 'view_item' => __( 'View webhook', 'woocommerce' ),  
  391. 'search_items' => __( 'Search webhooks', 'woocommerce' ),  
  392. 'not_found' => __( 'No webhooks found', 'woocommerce' ),  
  393. 'not_found_in_trash' => __( 'No webhooks found in trash', 'woocommerce' ),  
  394. 'parent' => __( 'Parent webhook', 'woocommerce' ),  
  395. ),  
  396. 'public' => false,  
  397. 'show_ui' => true,  
  398. 'capability_type' => 'shop_webhook',  
  399. 'map_meta_cap' => true,  
  400. 'publicly_queryable' => false,  
  401. 'exclude_from_search' => true,  
  402. 'show_in_menu' => false,  
  403. 'hierarchical' => false,  
  404. 'rewrite' => false,  
  405. 'query_var' => false,  
  406. 'supports' => false,  
  407. 'show_in_nav_menus' => false,  
  408. 'show_in_admin_bar' => false,  
  409. ); 
  410.  
  411. do_action( 'woocommerce_after_register_post_type' ); 
  412.  
  413. /** 
  414. * Register our custom post statuses, used for order status. 
  415. */ 
  416. public static function register_post_status() { 
  417.  
  418. $order_statuses = apply_filters( 'woocommerce_register_shop_order_post_statuses',  
  419. array( 
  420. 'wc-pending' => array( 
  421. 'label' => _x( 'Pending payment', 'Order status', 'woocommerce' ),  
  422. 'public' => false,  
  423. 'exclude_from_search' => false,  
  424. 'show_in_admin_all_list' => true,  
  425. 'show_in_admin_status_list' => true,  
  426. 'label_count' => _n_noop( 'Pending payment <span class="count">(%s)</span>', 'Pending payment <span class="count">(%s)</span>', 'woocommerce' ),  
  427. ),  
  428. 'wc-processing' => array( 
  429. 'label' => _x( 'Processing', 'Order status', 'woocommerce' ),  
  430. 'public' => false,  
  431. 'exclude_from_search' => false,  
  432. 'show_in_admin_all_list' => true,  
  433. 'show_in_admin_status_list' => true,  
  434. 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'woocommerce' ),  
  435. ),  
  436. 'wc-on-hold' => array( 
  437. 'label' => _x( 'On hold', 'Order status', 'woocommerce' ),  
  438. 'public' => false,  
  439. 'exclude_from_search' => false,  
  440. 'show_in_admin_all_list' => true,  
  441. 'show_in_admin_status_list' => true,  
  442. 'label_count' => _n_noop( 'On hold <span class="count">(%s)</span>', 'On hold <span class="count">(%s)</span>', 'woocommerce' ),  
  443. ),  
  444. 'wc-completed' => array( 
  445. 'label' => _x( 'Completed', 'Order status', 'woocommerce' ),  
  446. 'public' => false,  
  447. 'exclude_from_search' => false,  
  448. 'show_in_admin_all_list' => true,  
  449. 'show_in_admin_status_list' => true,  
  450. 'label_count' => _n_noop( 'Completed <span class="count">(%s)</span>', 'Completed <span class="count">(%s)</span>', 'woocommerce' ),  
  451. ),  
  452. 'wc-cancelled' => array( 
  453. 'label' => _x( 'Cancelled', 'Order status', 'woocommerce' ),  
  454. 'public' => false,  
  455. 'exclude_from_search' => false,  
  456. 'show_in_admin_all_list' => true,  
  457. 'show_in_admin_status_list' => true,  
  458. 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'woocommerce' ),  
  459. ),  
  460. 'wc-refunded' => array( 
  461. 'label' => _x( 'Refunded', 'Order status', 'woocommerce' ),  
  462. 'public' => false,  
  463. 'exclude_from_search' => false,  
  464. 'show_in_admin_all_list' => true,  
  465. 'show_in_admin_status_list' => true,  
  466. 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'woocommerce' ),  
  467. ),  
  468. 'wc-failed' => array( 
  469. 'label' => _x( 'Failed', 'Order status', 'woocommerce' ),  
  470. 'public' => false,  
  471. 'exclude_from_search' => false,  
  472. 'show_in_admin_all_list' => true,  
  473. 'show_in_admin_status_list' => true,  
  474. 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'woocommerce' ),  
  475. ),  
  476. ); 
  477.  
  478. foreach ( $order_statuses as $order_status => $values ) { 
  479. register_post_status( $order_status, $values ); 
  480.  
  481. /** 
  482. * Flush rewrite rules. 
  483. */ 
  484. public static function flush_rewrite_rules() { 
  485. flush_rewrite_rules(); 
  486.  
  487. /** 
  488. * Add Product Support to Jetpack Omnisearch. 
  489. */ 
  490. public static function support_jetpack_omnisearch() { 
  491. if ( class_exists( 'Jetpack_Omnisearch_Posts' ) ) { 
  492. new Jetpack_Omnisearch_Posts( 'product' ); 
  493.  
  494. /** 
  495. * Added product for Jetpack related posts. 
  496. * @param array $post_types 
  497. * @return array 
  498. */ 
  499. public static function rest_api_allowed_post_types( $post_types ) { 
  500. $post_types[] = 'product'; 
  501.  
  502. return $post_types;