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0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / includes / class-wc-post-types.php
woocommerce / includes Last commit date
abstracts 6 years ago admin 6 years ago api 6 years ago blocks 7 years ago cli 7 years ago customizer 8 years ago data-stores 6 years ago emails 7 years ago export 7 years ago gateways 7 years ago import 7 years ago interfaces 7 years ago legacy 7 years ago libraries 6 years ago log-handlers 7 years ago payment-tokens 8 years ago queue 7 years ago shipping 7 years ago shortcodes 6 years ago theme-support 7 years ago tracks 6 years ago walkers 8 years ago widgets 6 years ago class-wc-ajax.php 6 years ago class-wc-api.php 7 years ago class-wc-auth.php 7 years ago class-wc-autoloader.php 6 years ago class-wc-background-emailer.php 8 years ago class-wc-background-updater.php 7 years ago class-wc-breadcrumb.php 7 years ago class-wc-cache-helper.php 7 years ago class-wc-cart-fees.php 8 years ago class-wc-cart-session.php 7 years ago class-wc-cart-totals.php 7 years ago class-wc-cart.php 7 years ago class-wc-checkout.php 7 years ago class-wc-cli.php 8 years ago class-wc-comments.php 7 years ago class-wc-countries.php 6 years ago class-wc-coupon.php 7 years ago class-wc-customer-download-log.php 8 years ago class-wc-customer-download.php 8 years ago class-wc-customer.php 7 years ago class-wc-data-exception.php 8 years ago class-wc-data-store.php 7 years ago class-wc-datetime.php 7 years ago class-wc-deprecated-action-hooks.php 8 years ago class-wc-deprecated-filter-hooks.php 7 years ago class-wc-discounts.php 7 years ago class-wc-download-handler.php 6 years ago class-wc-emails.php 7 years ago class-wc-embed.php 8 years ago class-wc-form-handler.php 6 years ago class-wc-frontend-scripts.php 7 years ago class-wc-geo-ip.php 8 years ago class-wc-geolite-integration.php 7 years ago class-wc-geolocation.php 7 years ago class-wc-https.php 8 years ago class-wc-install.php 6 years ago class-wc-integrations.php 8 years ago class-wc-log-levels.php 7 years ago class-wc-logger.php 7 years ago class-wc-meta-data.php 7 years ago class-wc-order-factory.php 8 years ago class-wc-order-item-coupon.php 7 years ago class-wc-order-item-fee.php 7 years ago class-wc-order-item-meta.php 7 years ago class-wc-order-item-product.php 7 years ago class-wc-order-item-shipping.php 7 years ago class-wc-order-item-tax.php 8 years ago class-wc-order-item.php 6 years ago class-wc-order-query.php 7 years ago class-wc-order-refund.php 8 years ago class-wc-order.php 7 years ago class-wc-payment-gateways.php 7 years ago class-wc-payment-tokens.php 7 years ago class-wc-post-data.php 7 years ago class-wc-post-types.php 7 years ago class-wc-privacy-background-process.php 8 years ago class-wc-privacy-erasers.php 8 years ago class-wc-privacy-exporters.php 7 years ago class-wc-privacy.php 7 years ago class-wc-product-attribute.php 7 years ago class-wc-product-download.php 7 years ago class-wc-product-external.php 8 years ago class-wc-product-factory.php 7 years ago class-wc-product-grouped.php 8 years ago class-wc-product-query.php 7 years ago class-wc-product-simple.php 8 years ago class-wc-product-variable.php 7 years ago class-wc-product-variation.php 7 years ago class-wc-query.php 7 years ago class-wc-regenerate-images-request.php 7 years ago class-wc-regenerate-images.php 7 years ago class-wc-register-wp-admin-settings.php 8 years ago class-wc-session-handler.php 7 years ago class-wc-shipping-rate.php 8 years ago class-wc-shipping-zone.php 7 years ago class-wc-shipping-zones.php 8 years ago class-wc-shipping.php 7 years ago class-wc-shortcodes.php 7 years ago class-wc-structured-data.php 6 years ago class-wc-tax.php 7 years ago class-wc-template-loader.php 7 years ago class-wc-tracker.php 6 years ago class-wc-validation.php 6 years ago class-wc-webhook.php 7 years ago class-woocommerce.php 6 years ago wc-account-functions.php 7 years ago wc-attribute-functions.php 7 years ago wc-cart-functions.php 7 years ago wc-conditional-functions.php 6 years ago wc-core-functions.php 7 years ago wc-coupon-functions.php 7 years ago wc-deprecated-functions.php 7 years ago wc-formatting-functions.php 6 years ago wc-notice-functions.php 7 years ago wc-order-functions.php 7 years ago wc-order-item-functions.php 7 years ago wc-page-functions.php 7 years ago wc-product-functions.php 7 years ago wc-rest-functions.php 7 years ago wc-stock-functions.php 7 years ago wc-template-functions.php 7 years ago wc-template-hooks.php 7 years ago wc-term-functions.php 7 years ago wc-update-functions.php 7 years ago wc-user-functions.php 7 years ago wc-webhook-functions.php 7 years ago wc-widget-functions.php 8 years ago
class-wc-post-types.php
614 lines
1 <?php
2 /**
3 * Post Types
4 *
5 * Registers post types and taxonomies.
6 *
7 * @package WooCommerce/Classes/Products
8 * @version 2.5.0
9 */
10
11 defined( 'ABSPATH' ) || exit;
12
13 /**
14 * Post types Class.
15 */
16 class WC_Post_Types {
17
18 /**
19 * Hook in methods.
20 */
21 public static function init() {
22 add_action( 'init', array( __CLASS__, 'register_taxonomies' ), 5 );
23 add_action( 'init', array( __CLASS__, 'register_post_types' ), 5 );
24 add_action( 'init', array( __CLASS__, 'register_post_status' ), 9 );
25 add_action( 'init', array( __CLASS__, 'support_jetpack_omnisearch' ) );
26 add_filter( 'rest_api_allowed_post_types', array( __CLASS__, 'rest_api_allowed_post_types' ) );
27 add_action( 'woocommerce_after_register_post_type', array( __CLASS__, 'maybe_flush_rewrite_rules' ) );
28 add_action( 'woocommerce_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) );
29 add_filter( 'gutenberg_can_edit_post_type', array( __CLASS__, 'gutenberg_can_edit_post_type' ), 10, 2 );
30 add_filter( 'use_block_editor_for_post_type', array( __CLASS__, 'gutenberg_can_edit_post_type' ), 10, 2 );
31 }
32
33 /**
34 * Register core taxonomies.
35 */
36 public static function register_taxonomies() {
37
38 if ( ! is_blog_installed() ) {
39 return;
40 }
41
42 if ( taxonomy_exists( 'product_type' ) ) {
43 return;
44 }
45
46 do_action( 'woocommerce_register_taxonomy' );
47
48 $permalinks = wc_get_permalink_structure();
49
50 register_taxonomy(
51 'product_type',
52 apply_filters( 'woocommerce_taxonomy_objects_product_type', array( 'product' ) ),
53 apply_filters(
54 'woocommerce_taxonomy_args_product_type',
55 array(
56 'hierarchical' => false,
57 'show_ui' => false,
58 'show_in_nav_menus' => false,
59 'query_var' => is_admin(),
60 'rewrite' => false,
61 'public' => false,
62 )
63 )
64 );
65
66 register_taxonomy(
67 'product_visibility',
68 apply_filters( 'woocommerce_taxonomy_objects_product_visibility', array( 'product', 'product_variation' ) ),
69 apply_filters(
70 'woocommerce_taxonomy_args_product_visibility',
71 array(
72 'hierarchical' => false,
73 'show_ui' => false,
74 'show_in_nav_menus' => false,
75 'query_var' => is_admin(),
76 'rewrite' => false,
77 'public' => false,
78 )
79 )
80 );
81
82 register_taxonomy(
83 'product_cat',
84 apply_filters( 'woocommerce_taxonomy_objects_product_cat', array( 'product' ) ),
85 apply_filters(
86 'woocommerce_taxonomy_args_product_cat',
87 array(
88 'hierarchical' => true,
89 'update_count_callback' => '_wc_term_recount',
90 'label' => __( 'Categories', 'woocommerce' ),
91 'labels' => array(
92 'name' => __( 'Product categories', 'woocommerce' ),
93 'singular_name' => __( 'Category', 'woocommerce' ),
94 'menu_name' => _x( 'Categories', 'Admin menu name', 'woocommerce' ),
95 'search_items' => __( 'Search categories', 'woocommerce' ),
96 'all_items' => __( 'All categories', 'woocommerce' ),
97 'parent_item' => __( 'Parent category', 'woocommerce' ),
98 'parent_item_colon' => __( 'Parent category:', 'woocommerce' ),
99 'edit_item' => __( 'Edit category', 'woocommerce' ),
100 'update_item' => __( 'Update category', 'woocommerce' ),
101 'add_new_item' => __( 'Add new category', 'woocommerce' ),
102 'new_item_name' => __( 'New category name', 'woocommerce' ),
103 'not_found' => __( 'No categories found', 'woocommerce' ),
104 ),
105 'show_ui' => true,
106 'query_var' => true,
107 'capabilities' => array(
108 'manage_terms' => 'manage_product_terms',
109 'edit_terms' => 'edit_product_terms',
110 'delete_terms' => 'delete_product_terms',
111 'assign_terms' => 'assign_product_terms',
112 ),
113 'rewrite' => array(
114 'slug' => $permalinks['category_rewrite_slug'],
115 'with_front' => false,
116 'hierarchical' => true,
117 ),
118 )
119 )
120 );
121
122 register_taxonomy(
123 'product_tag',
124 apply_filters( 'woocommerce_taxonomy_objects_product_tag', array( 'product' ) ),
125 apply_filters(
126 'woocommerce_taxonomy_args_product_tag',
127 array(
128 'hierarchical' => false,
129 'update_count_callback' => '_wc_term_recount',
130 'label' => __( 'Product tags', 'woocommerce' ),
131 'labels' => array(
132 'name' => __( 'Product tags', 'woocommerce' ),
133 'singular_name' => __( 'Tag', 'woocommerce' ),
134 'menu_name' => _x( 'Tags', 'Admin menu name', 'woocommerce' ),
135 'search_items' => __( 'Search tags', 'woocommerce' ),
136 'all_items' => __( 'All tags', 'woocommerce' ),
137 'edit_item' => __( 'Edit tag', 'woocommerce' ),
138 'update_item' => __( 'Update tag', 'woocommerce' ),
139 'add_new_item' => __( 'Add new tag', 'woocommerce' ),
140 'new_item_name' => __( 'New tag name', 'woocommerce' ),
141 'popular_items' => __( 'Popular tags', 'woocommerce' ),
142 'separate_items_with_commas' => __( 'Separate tags with commas', 'woocommerce' ),
143 'add_or_remove_items' => __( 'Add or remove tags', 'woocommerce' ),
144 'choose_from_most_used' => __( 'Choose from the most used tags', 'woocommerce' ),
145 'not_found' => __( 'No tags found', 'woocommerce' ),
146 ),
147 'show_ui' => true,
148 'query_var' => true,
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' => array(
156 'slug' => $permalinks['tag_rewrite_slug'],
157 'with_front' => false,
158 ),
159 )
160 )
161 );
162
163 register_taxonomy(
164 'product_shipping_class',
165 apply_filters( 'woocommerce_taxonomy_objects_product_shipping_class', array( 'product', 'product_variation' ) ),
166 apply_filters(
167 'woocommerce_taxonomy_args_product_shipping_class',
168 array(
169 'hierarchical' => false,
170 'update_count_callback' => '_update_post_term_count',
171 'label' => __( 'Shipping classes', 'woocommerce' ),
172 'labels' => array(
173 'name' => __( 'Product shipping classes', 'woocommerce' ),
174 'singular_name' => __( 'Shipping class', 'woocommerce' ),
175 'menu_name' => _x( 'Shipping classes', 'Admin menu name', 'woocommerce' ),
176 'search_items' => __( 'Search shipping classes', 'woocommerce' ),
177 'all_items' => __( 'All shipping classes', 'woocommerce' ),
178 'parent_item' => __( 'Parent shipping class', 'woocommerce' ),
179 'parent_item_colon' => __( 'Parent shipping class:', 'woocommerce' ),
180 'edit_item' => __( 'Edit shipping class', 'woocommerce' ),
181 'update_item' => __( 'Update shipping class', 'woocommerce' ),
182 'add_new_item' => __( 'Add new shipping class', 'woocommerce' ),
183 'new_item_name' => __( 'New shipping class Name', 'woocommerce' ),
184 ),
185 'show_ui' => false,
186 'show_in_quick_edit' => false,
187 'show_in_nav_menus' => false,
188 'query_var' => is_admin(),
189 'capabilities' => array(
190 'manage_terms' => 'manage_product_terms',
191 'edit_terms' => 'edit_product_terms',
192 'delete_terms' => 'delete_product_terms',
193 'assign_terms' => 'assign_product_terms',
194 ),
195 'rewrite' => false,
196 )
197 )
198 );
199
200 global $wc_product_attributes;
201
202 $wc_product_attributes = array();
203 $attribute_taxonomies = wc_get_attribute_taxonomies();
204
205 if ( $attribute_taxonomies ) {
206 foreach ( $attribute_taxonomies as $tax ) {
207 $name = wc_attribute_taxonomy_name( $tax->attribute_name );
208
209 if ( $name ) {
210 $tax->attribute_public = absint( isset( $tax->attribute_public ) ? $tax->attribute_public : 1 );
211 $label = ! empty( $tax->attribute_label ) ? $tax->attribute_label : $tax->attribute_name;
212 $wc_product_attributes[ $name ] = $tax;
213 $taxonomy_data = array(
214 'hierarchical' => false,
215 'update_count_callback' => '_update_post_term_count',
216 'labels' => array(
217 /* translators: %s: attribute name */
218 'name' => sprintf( _x( 'Product %s', 'Product Attribute', 'woocommerce' ), $label ),
219 'singular_name' => $label,
220 /* translators: %s: attribute name */
221 'search_items' => sprintf( __( 'Search %s', 'woocommerce' ), $label ),
222 /* translators: %s: attribute name */
223 'all_items' => sprintf( __( 'All %s', 'woocommerce' ), $label ),
224 /* translators: %s: attribute name */
225 'parent_item' => sprintf( __( 'Parent %s', 'woocommerce' ), $label ),
226 /* translators: %s: attribute name */
227 'parent_item_colon' => sprintf( __( 'Parent %s:', 'woocommerce' ), $label ),
228 /* translators: %s: attribute name */
229 'edit_item' => sprintf( __( 'Edit %s', 'woocommerce' ), $label ),
230 /* translators: %s: attribute name */
231 'update_item' => sprintf( __( 'Update %s', 'woocommerce' ), $label ),
232 /* translators: %s: attribute name */
233 'add_new_item' => sprintf( __( 'Add new %s', 'woocommerce' ), $label ),
234 /* translators: %s: attribute name */
235 'new_item_name' => sprintf( __( 'New %s', 'woocommerce' ), $label ),
236 /* translators: %s: attribute name */
237 'not_found' => sprintf( __( 'No &quot;%s&quot; found', 'woocommerce' ), $label ),
238 /* translators: %s: attribute name */
239 'back_to_items' => sprintf( __( '&larr; Back to "%s" attributes', 'woocommerce' ), $label ),
240 ),
241 'show_ui' => true,
242 'show_in_quick_edit' => false,
243 'show_in_menu' => false,
244 'meta_box_cb' => false,
245 'query_var' => 1 === $tax->attribute_public,
246 'rewrite' => false,
247 'sort' => false,
248 'public' => 1 === $tax->attribute_public,
249 'show_in_nav_menus' => 1 === $tax->attribute_public && apply_filters( 'woocommerce_attribute_show_in_nav_menus', false, $name ),
250 'capabilities' => array(
251 'manage_terms' => 'manage_product_terms',
252 'edit_terms' => 'edit_product_terms',
253 'delete_terms' => 'delete_product_terms',
254 'assign_terms' => 'assign_product_terms',
255 ),
256 );
257
258 if ( 1 === $tax->attribute_public && sanitize_title( $tax->attribute_name ) ) {
259 $taxonomy_data['rewrite'] = array(
260 'slug' => trailingslashit( $permalinks['attribute_rewrite_slug'] ) . sanitize_title( $tax->attribute_name ),
261 'with_front' => false,
262 'hierarchical' => true,
263 );
264 }
265
266 register_taxonomy( $name, apply_filters( "woocommerce_taxonomy_objects_{$name}", array( 'product' ) ), apply_filters( "woocommerce_taxonomy_args_{$name}", $taxonomy_data ) );
267 }
268 }
269 }
270
271 do_action( 'woocommerce_after_register_taxonomy' );
272 }
273
274 /**
275 * Register core post types.
276 */
277 public static function register_post_types() {
278 if ( ! is_blog_installed() || post_type_exists( 'product' ) ) {
279 return;
280 }
281
282 do_action( 'woocommerce_register_post_type' );
283
284 $permalinks = wc_get_permalink_structure();
285 $supports = array( 'title', 'editor', 'excerpt', 'thumbnail', 'custom-fields', 'publicize', 'wpcom-markdown' );
286
287 if ( 'yes' === get_option( 'woocommerce_enable_reviews', 'yes' ) ) {
288 $supports[] = 'comments';
289 }
290
291 $shop_page_id = wc_get_page_id( 'shop' );
292
293 if ( current_theme_supports( 'woocommerce' ) ) {
294 $has_archive = $shop_page_id && get_post( $shop_page_id ) ? urldecode( get_page_uri( $shop_page_id ) ) : 'shop';
295 } else {
296 $has_archive = false;
297 }
298
299 // If theme support changes, we may need to flush permalinks since some are changed based on this flag.
300 $theme_support = current_theme_supports( 'woocommerce' ) ? 'yes' : 'no';
301 if ( get_option( 'current_theme_supports_woocommerce' ) !== $theme_support && update_option( 'current_theme_supports_woocommerce', $theme_support ) ) {
302 update_option( 'woocommerce_queue_flush_rewrite_rules', 'yes' );
303 }
304
305 register_post_type(
306 'product',
307 apply_filters(
308 'woocommerce_register_post_type_product',
309 array(
310 'labels' => array(
311 'name' => __( 'Products', 'woocommerce' ),
312 'singular_name' => __( 'Product', 'woocommerce' ),
313 'all_items' => __( 'All Products', 'woocommerce' ),
314 'menu_name' => _x( 'Products', 'Admin menu name', 'woocommerce' ),
315 'add_new' => __( 'Add New', 'woocommerce' ),
316 'add_new_item' => __( 'Add new product', 'woocommerce' ),
317 'edit' => __( 'Edit', 'woocommerce' ),
318 'edit_item' => __( 'Edit product', 'woocommerce' ),
319 'new_item' => __( 'New product', 'woocommerce' ),
320 'view_item' => __( 'View product', 'woocommerce' ),
321 'view_items' => __( 'View products', 'woocommerce' ),
322 'search_items' => __( 'Search products', 'woocommerce' ),
323 'not_found' => __( 'No products found', 'woocommerce' ),
324 'not_found_in_trash' => __( 'No products found in trash', 'woocommerce' ),
325 'parent' => __( 'Parent product', 'woocommerce' ),
326 'featured_image' => __( 'Product image', 'woocommerce' ),
327 'set_featured_image' => __( 'Set product image', 'woocommerce' ),
328 'remove_featured_image' => __( 'Remove product image', 'woocommerce' ),
329 'use_featured_image' => __( 'Use as product image', 'woocommerce' ),
330 'insert_into_item' => __( 'Insert into product', 'woocommerce' ),
331 'uploaded_to_this_item' => __( 'Uploaded to this product', 'woocommerce' ),
332 'filter_items_list' => __( 'Filter products', 'woocommerce' ),
333 'items_list_navigation' => __( 'Products navigation', 'woocommerce' ),
334 'items_list' => __( 'Products list', 'woocommerce' ),
335 ),
336 'description' => __( 'This is where you can add new products to your store.', 'woocommerce' ),
337 'public' => true,
338 'show_ui' => true,
339 'capability_type' => 'product',
340 'map_meta_cap' => true,
341 'publicly_queryable' => true,
342 'exclude_from_search' => false,
343 'hierarchical' => false, // Hierarchical causes memory issues - WP loads all records!
344 'rewrite' => $permalinks['product_rewrite_slug'] ? array(
345 'slug' => $permalinks['product_rewrite_slug'],
346 'with_front' => false,
347 'feeds' => true,
348 ) : false,
349 'query_var' => true,
350 'supports' => $supports,
351 'has_archive' => $has_archive,
352 'show_in_nav_menus' => true,
353 'show_in_rest' => true,
354 )
355 )
356 );
357
358 register_post_type(
359 'product_variation',
360 apply_filters(
361 'woocommerce_register_post_type_product_variation',
362 array(
363 'label' => __( 'Variations', 'woocommerce' ),
364 'public' => false,
365 'hierarchical' => false,
366 'supports' => false,
367 'capability_type' => 'product',
368 'rewrite' => false,
369 )
370 )
371 );
372
373 wc_register_order_type(
374 'shop_order',
375 apply_filters(
376 'woocommerce_register_post_type_shop_order',
377 array(
378 'labels' => array(
379 'name' => __( 'Orders', 'woocommerce' ),
380 'singular_name' => _x( 'Order', 'shop_order post type singular name', 'woocommerce' ),
381 'add_new' => __( 'Add order', 'woocommerce' ),
382 'add_new_item' => __( 'Add new order', 'woocommerce' ),
383 'edit' => __( 'Edit', 'woocommerce' ),
384 'edit_item' => __( 'Edit order', 'woocommerce' ),
385 'new_item' => __( 'New order', 'woocommerce' ),
386 'view_item' => __( 'View order', 'woocommerce' ),
387 'search_items' => __( 'Search orders', 'woocommerce' ),
388 'not_found' => __( 'No orders found', 'woocommerce' ),
389 'not_found_in_trash' => __( 'No orders found in trash', 'woocommerce' ),
390 'parent' => __( 'Parent orders', 'woocommerce' ),
391 'menu_name' => _x( 'Orders', 'Admin menu name', 'woocommerce' ),
392 'filter_items_list' => __( 'Filter orders', 'woocommerce' ),
393 'items_list_navigation' => __( 'Orders navigation', 'woocommerce' ),
394 'items_list' => __( 'Orders list', 'woocommerce' ),
395 ),
396 'description' => __( 'This is where store orders are stored.', 'woocommerce' ),
397 'public' => false,
398 'show_ui' => true,
399 'capability_type' => 'shop_order',
400 'map_meta_cap' => true,
401 'publicly_queryable' => false,
402 'exclude_from_search' => true,
403 'show_in_menu' => current_user_can( 'manage_woocommerce' ) ? 'woocommerce' : true,
404 'hierarchical' => false,
405 'show_in_nav_menus' => false,
406 'rewrite' => false,
407 'query_var' => false,
408 'supports' => array( 'title', 'comments', 'custom-fields' ),
409 'has_archive' => false,
410 )
411 )
412 );
413
414 wc_register_order_type(
415 'shop_order_refund',
416 apply_filters(
417 'woocommerce_register_post_type_shop_order_refund',
418 array(
419 'label' => __( 'Refunds', 'woocommerce' ),
420 'capability_type' => 'shop_order',
421 'public' => false,
422 'hierarchical' => false,
423 'supports' => false,
424 'exclude_from_orders_screen' => false,
425 'add_order_meta_boxes' => false,
426 'exclude_from_order_count' => true,
427 'exclude_from_order_views' => false,
428 'exclude_from_order_reports' => false,
429 'exclude_from_order_sales_reports' => true,
430 'class_name' => 'WC_Order_Refund',
431 'rewrite' => false,
432 )
433 )
434 );
435
436 if ( 'yes' === get_option( 'woocommerce_enable_coupons' ) ) {
437 register_post_type(
438 'shop_coupon',
439 apply_filters(
440 'woocommerce_register_post_type_shop_coupon',
441 array(
442 'labels' => array(
443 'name' => __( 'Coupons', 'woocommerce' ),
444 'singular_name' => __( 'Coupon', 'woocommerce' ),
445 'menu_name' => _x( 'Coupons', 'Admin menu name', 'woocommerce' ),
446 'add_new' => __( 'Add coupon', 'woocommerce' ),
447 'add_new_item' => __( 'Add new coupon', 'woocommerce' ),
448 'edit' => __( 'Edit', 'woocommerce' ),
449 'edit_item' => __( 'Edit coupon', 'woocommerce' ),
450 'new_item' => __( 'New coupon', 'woocommerce' ),
451 'view_item' => __( 'View coupon', 'woocommerce' ),
452 'search_items' => __( 'Search coupons', 'woocommerce' ),
453 'not_found' => __( 'No coupons found', 'woocommerce' ),
454 'not_found_in_trash' => __( 'No coupons found in trash', 'woocommerce' ),
455 'parent' => __( 'Parent coupon', 'woocommerce' ),
456 'filter_items_list' => __( 'Filter coupons', 'woocommerce' ),
457 'items_list_navigation' => __( 'Coupons navigation', 'woocommerce' ),
458 'items_list' => __( 'Coupons list', 'woocommerce' ),
459 ),
460 'description' => __( 'This is where you can add new coupons that customers can use in your store.', 'woocommerce' ),
461 'public' => false,
462 'show_ui' => true,
463 'capability_type' => 'shop_coupon',
464 'map_meta_cap' => true,
465 'publicly_queryable' => false,
466 'exclude_from_search' => true,
467 'show_in_menu' => current_user_can( 'manage_woocommerce' ) ? 'woocommerce' : true,
468 'hierarchical' => false,
469 'rewrite' => false,
470 'query_var' => false,
471 'supports' => array( 'title' ),
472 'show_in_nav_menus' => false,
473 'show_in_admin_bar' => true,
474 )
475 )
476 );
477 }
478
479 do_action( 'woocommerce_after_register_post_type' );
480 }
481
482 /**
483 * Register our custom post statuses, used for order status.
484 */
485 public static function register_post_status() {
486
487 $order_statuses = apply_filters(
488 'woocommerce_register_shop_order_post_statuses',
489 array(
490 'wc-pending' => array(
491 'label' => _x( 'Pending payment', 'Order status', 'woocommerce' ),
492 'public' => false,
493 'exclude_from_search' => false,
494 'show_in_admin_all_list' => true,
495 'show_in_admin_status_list' => true,
496 /* translators: %s: number of orders */
497 'label_count' => _n_noop( 'Pending payment <span class="count">(%s)</span>', 'Pending payment <span class="count">(%s)</span>', 'woocommerce' ),
498 ),
499 'wc-processing' => array(
500 'label' => _x( 'Processing', 'Order status', 'woocommerce' ),
501 'public' => false,
502 'exclude_from_search' => false,
503 'show_in_admin_all_list' => true,
504 'show_in_admin_status_list' => true,
505 /* translators: %s: number of orders */
506 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'woocommerce' ),
507 ),
508 'wc-on-hold' => array(
509 'label' => _x( 'On hold', 'Order status', 'woocommerce' ),
510 'public' => false,
511 'exclude_from_search' => false,
512 'show_in_admin_all_list' => true,
513 'show_in_admin_status_list' => true,
514 /* translators: %s: number of orders */
515 'label_count' => _n_noop( 'On hold <span class="count">(%s)</span>', 'On hold <span class="count">(%s)</span>', 'woocommerce' ),
516 ),
517 'wc-completed' => array(
518 'label' => _x( 'Completed', 'Order status', 'woocommerce' ),
519 'public' => false,
520 'exclude_from_search' => false,
521 'show_in_admin_all_list' => true,
522 'show_in_admin_status_list' => true,
523 /* translators: %s: number of orders */
524 'label_count' => _n_noop( 'Completed <span class="count">(%s)</span>', 'Completed <span class="count">(%s)</span>', 'woocommerce' ),
525 ),
526 'wc-cancelled' => array(
527 'label' => _x( 'Cancelled', 'Order status', 'woocommerce' ),
528 'public' => false,
529 'exclude_from_search' => false,
530 'show_in_admin_all_list' => true,
531 'show_in_admin_status_list' => true,
532 /* translators: %s: number of orders */
533 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'woocommerce' ),
534 ),
535 'wc-refunded' => array(
536 'label' => _x( 'Refunded', 'Order status', 'woocommerce' ),
537 'public' => false,
538 'exclude_from_search' => false,
539 'show_in_admin_all_list' => true,
540 'show_in_admin_status_list' => true,
541 /* translators: %s: number of orders */
542 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'woocommerce' ),
543 ),
544 'wc-failed' => array(
545 'label' => _x( 'Failed', 'Order status', 'woocommerce' ),
546 'public' => false,
547 'exclude_from_search' => false,
548 'show_in_admin_all_list' => true,
549 'show_in_admin_status_list' => true,
550 /* translators: %s: number of orders */
551 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'woocommerce' ),
552 ),
553 )
554 );
555
556 foreach ( $order_statuses as $order_status => $values ) {
557 register_post_status( $order_status, $values );
558 }
559 }
560
561 /**
562 * Flush rules if the event is queued.
563 *
564 * @since 3.3.0
565 */
566 public static function maybe_flush_rewrite_rules() {
567 if ( 'yes' === get_option( 'woocommerce_queue_flush_rewrite_rules' ) ) {
568 update_option( 'woocommerce_queue_flush_rewrite_rules', 'no' );
569 self::flush_rewrite_rules();
570 }
571 }
572
573 /**
574 * Flush rewrite rules.
575 */
576 public static function flush_rewrite_rules() {
577 flush_rewrite_rules();
578 }
579
580 /**
581 * Disable Gutenberg for products.
582 *
583 * @param bool $can_edit Whether the post type can be edited or not.
584 * @param string $post_type The post type being checked.
585 * @return bool
586 */
587 public static function gutenberg_can_edit_post_type( $can_edit, $post_type ) {
588 return 'product' === $post_type ? false : $can_edit;
589 }
590
591 /**
592 * Add Product Support to Jetpack Omnisearch.
593 */
594 public static function support_jetpack_omnisearch() {
595 if ( class_exists( 'Jetpack_Omnisearch_Posts' ) ) {
596 new Jetpack_Omnisearch_Posts( 'product' );
597 }
598 }
599
600 /**
601 * Added product for Jetpack related posts.
602 *
603 * @param array $post_types Post types.
604 * @return array
605 */
606 public static function rest_api_allowed_post_types( $post_types ) {
607 $post_types[] = 'product';
608
609 return $post_types;
610 }
611 }
612
613 WC_Post_types::init();
614