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