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