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3.2.1 6.3.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 weeks ago admin 4 weeks ago blocks 10 months ago cli 7 months ago customizer 3 months ago data-stores 3 weeks ago emails 3 weeks ago export 1 year ago gateways 2 months ago import 2 months ago integrations 4 weeks ago interfaces 3 months ago legacy 3 months ago libraries 1 year ago log-handlers 1 year ago payment-tokens 5 years ago product-usage 1 year ago queue 3 months ago react-admin 3 months ago rest-api 4 weeks ago shipping 2 months ago shortcodes 2 months ago theme-support 2 years ago tracks 3 months ago traits 5 years ago walkers 5 years ago wccom-site 4 weeks ago widgets 4 weeks ago class-wc-ajax.php 4 weeks ago class-wc-auth.php 1 year ago class-wc-autoloader.php 7 months ago class-wc-background-emailer.php 4 weeks 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 4 months ago class-wc-breadcrumb.php 3 months ago class-wc-cache-helper.php 4 weeks ago class-wc-cart-fees.php 2 years ago class-wc-cart-session.php 2 months ago class-wc-cart-totals.php 10 months ago class-wc-cart.php 2 months ago class-wc-checkout.php 4 weeks ago class-wc-cli.php 9 months ago class-wc-comments.php 3 months ago class-wc-countries.php 4 weeks ago class-wc-coupon.php 4 weeks ago class-wc-customer-download-log.php 5 years ago class-wc-customer-download.php 1 year ago class-wc-customer.php 4 weeks 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 2 months ago class-wc-discounts.php 10 months ago class-wc-download-handler.php 1 year ago class-wc-emails.php 3 weeks ago class-wc-embed.php 1 year ago class-wc-form-handler.php 2 months ago class-wc-frontend-scripts.php 4 weeks ago class-wc-geo-ip.php 7 months ago class-wc-geolite-integration.php 6 years ago class-wc-geolocation.php 4 weeks ago class-wc-https.php 2 years ago class-wc-install.php 3 weeks ago class-wc-integrations.php 5 years ago class-wc-log-levels.php 2 years ago class-wc-logger.php 3 months ago class-wc-meta-data.php 4 years ago class-wc-order-factory.php 4 weeks ago class-wc-order-item-coupon.php 4 years ago class-wc-order-item-fee.php 4 months ago class-wc-order-item-meta.php 4 years ago class-wc-order-item-product.php 4 weeks ago class-wc-order-item-shipping.php 4 months ago class-wc-order-item-tax.php 4 years ago class-wc-order-item.php 4 months ago class-wc-order-query.php 3 months ago class-wc-order-refund.php 1 year ago class-wc-order.php 3 weeks ago class-wc-payment-gateways.php 4 weeks ago class-wc-payment-tokens.php 3 years ago class-wc-post-data.php 4 weeks ago class-wc-post-types.php 4 weeks 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 3 months ago class-wc-product-download.php 3 months ago class-wc-product-external.php 1 year ago class-wc-product-factory.php 2 months ago class-wc-product-grouped.php 2 months ago class-wc-product-query.php 3 months ago class-wc-product-simple.php 10 months ago class-wc-product-variable.php 2 months ago class-wc-product-variation.php 1 year ago class-wc-query.php 4 weeks 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 2 months ago class-wc-shipping-rate.php 11 months ago class-wc-shipping-zone.php 5 years ago class-wc-shipping-zones.php 6 months ago class-wc-shipping.php 4 weeks ago class-wc-shortcodes.php 1 year ago class-wc-structured-data.php 4 weeks ago class-wc-tax.php 4 weeks ago class-wc-template-loader.php 6 months ago class-wc-tracker.php 7 months ago class-wc-validation.php 2 years ago class-wc-webhook.php 4 weeks ago class-woocommerce.php 3 weeks ago wc-account-functions.php 6 months ago wc-attribute-functions.php 4 weeks ago wc-brands-functions.php 1 year ago wc-cart-functions.php 4 months ago wc-conditional-functions.php 10 months ago wc-core-functions.php 4 weeks ago wc-coupon-functions.php 4 months ago wc-deprecated-functions.php 3 months ago wc-formatting-functions.php 6 months ago wc-interactivity-api-functions.php 4 weeks ago wc-notice-functions.php 4 months ago wc-order-functions.php 3 weeks ago wc-order-item-functions.php 3 years ago wc-order-step-logger-functions.php 3 months ago wc-page-functions.php 3 weeks ago wc-product-functions.php 4 weeks ago wc-rest-functions.php 6 months ago wc-stock-functions.php 6 months ago wc-template-functions.php 4 weeks ago wc-template-hooks.php 9 months ago wc-term-functions.php 4 weeks ago wc-update-functions.php 3 weeks ago wc-user-functions.php 4 weeks ago wc-webhook-functions.php 4 weeks ago wc-widget-functions.php 5 years ago
class-wc-post-types.php
791 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 register_taxonomy(
216 'pos_product_visibility',
217 /**
218 * Filter the post types that the POS product visibility taxonomy is attached to.
219 *
220 * @since 10.5.0
221 * @param array $post_types Array of post types.
222 */
223 apply_filters( 'woocommerce_taxonomy_objects_pos_product_visibility', array( 'product', 'product_variation' ) ),
224 /**
225 * Filter the arguments for the POS product visibility taxonomy.
226 *
227 * @since 10.5.0
228 * @param array $args Array of taxonomy arguments.
229 */
230 apply_filters(
231 'woocommerce_taxonomy_args_pos_product_visibility',
232 array(
233 'hierarchical' => false,
234 'show_ui' => false,
235 'show_in_nav_menus' => false,
236 'query_var' => false,
237 'rewrite' => false,
238 'public' => false,
239 'label' => _x( 'POS Product visibility', 'Taxonomy name', 'woocommerce' ),
240 )
241 )
242 );
243
244 global $wc_product_attributes;
245
246 $wc_product_attributes = array();
247 $attribute_taxonomies = wc_get_attribute_taxonomies();
248
249 if ( $attribute_taxonomies ) {
250 foreach ( $attribute_taxonomies as $tax ) {
251 $name = wc_attribute_taxonomy_name( $tax->attribute_name );
252
253 if ( $name ) {
254 $tax->attribute_public = absint( isset( $tax->attribute_public ) ? $tax->attribute_public : 1 );
255 $label = ! empty( $tax->attribute_label ) ? $tax->attribute_label : $tax->attribute_name;
256 $wc_product_attributes[ $name ] = $tax;
257 $taxonomy_data = array(
258 'hierarchical' => false,
259 'update_count_callback' => '_update_post_term_count',
260 'labels' => array(
261 /* translators: %s: attribute name */
262 'name' => sprintf( _x( 'Product %s', 'Product Attribute', 'woocommerce' ), $label ),
263 'singular_name' => $label,
264 /* translators: %s: attribute name */
265 'search_items' => sprintf( __( 'Search %s', 'woocommerce' ), $label ),
266 /* translators: %s: attribute name */
267 'all_items' => sprintf( __( 'All %s', 'woocommerce' ), $label ),
268 /* translators: %s: attribute name */
269 'parent_item' => sprintf( __( 'Parent %s', 'woocommerce' ), $label ),
270 /* translators: %s: attribute name */
271 'parent_item_colon' => sprintf( __( 'Parent %s:', 'woocommerce' ), $label ),
272 /* translators: %s: attribute name */
273 'edit_item' => sprintf( __( 'Edit %s', 'woocommerce' ), $label ),
274 /* translators: %s: attribute name */
275 'update_item' => sprintf( __( 'Update %s', 'woocommerce' ), $label ),
276 /* translators: %s: attribute name */
277 'add_new_item' => sprintf( __( 'Add new %s', 'woocommerce' ), $label ),
278 /* translators: %s: attribute name */
279 'new_item_name' => sprintf( __( 'New %s', 'woocommerce' ), $label ),
280 /* translators: %s: attribute name */
281 'not_found' => sprintf( __( 'No &quot;%s&quot; found', 'woocommerce' ), $label ),
282 /* translators: %s: attribute name */
283 'back_to_items' => sprintf( __( '&larr; Back to "%s" attributes', 'woocommerce' ), $label ),
284 ),
285 'show_ui' => true,
286 'show_in_quick_edit' => false,
287 'show_in_menu' => false,
288 'meta_box_cb' => false,
289 'query_var' => 1 === $tax->attribute_public,
290 'rewrite' => false,
291 'sort' => false,
292 'public' => 1 === $tax->attribute_public,
293 'show_in_nav_menus' => 1 === $tax->attribute_public && apply_filters( 'woocommerce_attribute_show_in_nav_menus', false, $name ),
294 'capabilities' => array(
295 'manage_terms' => 'manage_product_terms',
296 'edit_terms' => 'edit_product_terms',
297 'delete_terms' => 'delete_product_terms',
298 'assign_terms' => 'assign_product_terms',
299 ),
300 );
301
302 if ( 1 === $tax->attribute_public && sanitize_title( $tax->attribute_name ) ) {
303 $taxonomy_data['rewrite'] = array(
304 'slug' => trailingslashit( $permalinks['attribute_rewrite_slug'] ) . urldecode( sanitize_title( $tax->attribute_name ) ),
305 'with_front' => false,
306 'hierarchical' => true,
307 );
308 }
309
310 register_taxonomy( $name, apply_filters( "woocommerce_taxonomy_objects_{$name}", array( 'product' ) ), apply_filters( "woocommerce_taxonomy_args_{$name}", $taxonomy_data ) );
311 }
312 }
313 }
314
315 do_action( 'woocommerce_after_register_taxonomy' );
316 }
317
318 /**
319 * Register core post types.
320 */
321 public static function register_post_types() {
322 if ( ! is_blog_installed() || post_type_exists( 'product' ) ) {
323 return;
324 }
325
326 do_action( 'woocommerce_register_post_type' );
327
328 $permalinks = wc_get_permalink_structure();
329 $supports = array( 'title', 'editor', 'excerpt', 'thumbnail', 'custom-fields', 'publicize', 'wpcom-markdown' );
330
331 if ( 'yes' === get_option( 'woocommerce_enable_reviews', 'yes' ) ) {
332 $supports[] = 'comments';
333 }
334
335 $shop_page_id = wc_get_page_id( 'shop' );
336
337 if ( wc_current_theme_supports_woocommerce_or_fse() ) {
338 $has_archive = $shop_page_id && get_post( $shop_page_id ) ? urldecode( get_page_uri( $shop_page_id ) ) : 'shop';
339 } else {
340 $has_archive = false;
341 }
342
343 // If theme support changes, we may need to flush permalinks since some are changed based on this flag.
344 // Skip this check in WP-CLI and cron contexts: themes may not be loaded (e.g. --skip-themes),
345 // which would incorrectly record theme support as "no" and corrupt rewrite rules on the frontend.
346 if ( ! ( defined( 'WP_CLI' ) && WP_CLI ) && ! wp_doing_cron() ) {
347 $theme_support = wc_current_theme_supports_woocommerce_or_fse() ? 'yes' : 'no';
348 if ( get_option( 'current_theme_supports_woocommerce' ) !== $theme_support && update_option( 'current_theme_supports_woocommerce', $theme_support ) ) {
349 update_option( 'woocommerce_queue_flush_rewrite_rules', 'yes' );
350 }
351 }
352
353 register_post_type(
354 'product',
355 apply_filters(
356 'woocommerce_register_post_type_product',
357 array(
358 'labels' => array(
359 'name' => __( 'Products', 'woocommerce' ),
360 'singular_name' => __( 'Product', 'woocommerce' ),
361 'all_items' => __( 'All Products', 'woocommerce' ),
362 'menu_name' => _x( 'Products', 'Admin menu name', 'woocommerce' ),
363 'add_new' => __( 'Add New', 'woocommerce' ),
364 'add_new_item' => __( 'Add new product', 'woocommerce' ),
365 'edit' => __( 'Edit', 'woocommerce' ),
366 'edit_item' => __( 'Edit product', 'woocommerce' ),
367 'new_item' => __( 'New product', 'woocommerce' ),
368 'view_item' => __( 'View product', 'woocommerce' ),
369 'view_items' => __( 'View products', 'woocommerce' ),
370 'search_items' => __( 'Search products', 'woocommerce' ),
371 'not_found' => __( 'No products found', 'woocommerce' ),
372 'not_found_in_trash' => __( 'No products found in trash', 'woocommerce' ),
373 'parent' => __( 'Parent product', 'woocommerce' ),
374 'featured_image' => __( 'Product image', 'woocommerce' ),
375 'set_featured_image' => __( 'Set product image', 'woocommerce' ),
376 'remove_featured_image' => __( 'Remove product image', 'woocommerce' ),
377 'use_featured_image' => __( 'Use as product image', 'woocommerce' ),
378 'insert_into_item' => __( 'Insert into product', 'woocommerce' ),
379 'uploaded_to_this_item' => __( 'Uploaded to this product', 'woocommerce' ),
380 'filter_items_list' => __( 'Filter products', 'woocommerce' ),
381 'items_list_navigation' => __( 'Products navigation', 'woocommerce' ),
382 'items_list' => __( 'Products list', 'woocommerce' ),
383 'item_link' => __( 'Product Link', 'woocommerce' ),
384 'item_link_description' => __( 'A link to a product.', 'woocommerce' ),
385 ),
386 'description' => __( 'This is where you can browse products in this store.', 'woocommerce' ),
387 'public' => true,
388 'show_ui' => true,
389 'menu_icon' => 'dashicons-archive',
390 'capability_type' => 'product',
391 'map_meta_cap' => true,
392 'publicly_queryable' => true,
393 'exclude_from_search' => false,
394 'hierarchical' => false, // Hierarchical causes memory issues - WP loads all records!
395 'rewrite' => $permalinks['product_rewrite_slug'] ? array(
396 'slug' => $permalinks['product_rewrite_slug'],
397 'with_front' => false,
398 'feeds' => true,
399 ) : false,
400 'query_var' => true,
401 'supports' => $supports,
402 'has_archive' => $has_archive,
403 'show_in_nav_menus' => true,
404 'show_in_rest' => true,
405 )
406 )
407 );
408
409 // Register the product form post type when the feature is enabled.
410 if ( Features::is_enabled( 'product-editor-template-system' ) ) {
411 register_post_type(
412 'product_form',
413 /**
414 * Allow developers to customize the product form post type registration arguments.
415 *
416 * @since 9.1.0
417 * @param array $args The default post type registration arguments.
418 */
419 apply_filters(
420 'woocommerce_register_post_type_product_form',
421 array(
422 'labels'
423 => array(
424 'name' => __( 'Product Forms', 'woocommerce' ),
425 'singular_name' => __( 'Product Form', 'woocommerce' ),
426 'all_items' => __( 'All Product Form', 'woocommerce' ),
427 'menu_name' => _x( 'Product Forms', 'Admin menu name', 'woocommerce' ),
428 'add_new' => __( 'Add New', 'woocommerce' ),
429 'add_new_item' => __( 'Add new product form', 'woocommerce' ),
430 'edit' => __( 'Edit', 'woocommerce' ),
431 'edit_item' => __( 'Edit product form', 'woocommerce' ),
432 'new_item' => __( 'New product form', 'woocommerce' ),
433 'view_item' => __( 'View product form', 'woocommerce' ),
434 'view_items' => __( 'View product forms', 'woocommerce' ),
435 'search_items' => __( 'Search product forms', 'woocommerce' ),
436 'not_found' => __( 'No product forms found', 'woocommerce' ),
437 'not_found_in_trash' => __( 'No product forms found in trash', 'woocommerce' ),
438 'parent' => __( 'Parent product form', 'woocommerce' ),
439 'featured_image' => __( 'Product form image', 'woocommerce' ),
440 'set_featured_image' => __( 'Set product form image', 'woocommerce' ),
441 'remove_featured_image' => __( 'Remove product form image', 'woocommerce' ),
442 'use_featured_image' => __( 'Use as product form image', 'woocommerce' ),
443 'insert_into_item' => __( 'Insert into product form', 'woocommerce' ),
444 'uploaded_to_this_item' => __( 'Uploaded to this product form', 'woocommerce' ),
445 'filter_items_list' => __( 'Filter product forms', 'woocommerce' ),
446 'items_list_navigation' => __( 'Product forms navigation', 'woocommerce' ),
447 'items_list' => __( 'Product forms list', 'woocommerce' ),
448 'item_link' => __( 'Product form Link', 'woocommerce' ),
449 'item_link_description' => __( 'A link to a product form.', 'woocommerce' ),
450 ),
451 'description' => __( 'This is where you can set up product forms for various product types in your dashboard.', 'woocommerce' ),
452 'public' => true,
453 'menu_icon' => 'dashicons-forms',
454 'capability_type' => 'product',
455 'map_meta_cap' => true,
456 'publicly_queryable' => true,
457 'hierarchical' => false, // Hierarchical causes memory issues - WP loads all records!
458 'rewrite' => $permalinks['product_rewrite_slug'] ? array(
459 'slug' => $permalinks['product_rewrite_slug'],
460 'with_front' => false,
461 'feeds' => true,
462 ) : false,
463 'query_var' => true,
464 'supports' => $supports,
465 'has_archive' => $has_archive,
466 'show_in_rest' => true,
467 'show_ui' => true,
468 'show_in_menu' => true,
469 'exclude_from_search' => true,
470 'show_in_nav_menus' => false,
471 )
472 )
473 );
474 }
475
476 register_post_type(
477 'product_variation',
478 apply_filters(
479 'woocommerce_register_post_type_product_variation',
480 array(
481 'label' => __( 'Variations', 'woocommerce' ),
482 'public' => false,
483 'hierarchical' => false,
484 'supports' => false,
485 'capability_type' => 'product',
486 'rewrite' => false,
487 )
488 )
489 );
490
491 wc_register_order_type(
492 'shop_order',
493 apply_filters(
494 'woocommerce_register_post_type_shop_order',
495 array(
496 'labels' => array(
497 'name' => __( 'Orders', 'woocommerce' ),
498 'singular_name' => _x( 'Order', 'shop_order post type singular name', 'woocommerce' ),
499 'add_new' => __( 'Add order', 'woocommerce' ),
500 'add_new_item' => __( 'Add new order', 'woocommerce' ),
501 'edit' => __( 'Edit', 'woocommerce' ),
502 'edit_item' => __( 'Edit order', 'woocommerce' ),
503 'new_item' => __( 'New order', 'woocommerce' ),
504 'view_item' => __( 'View order', 'woocommerce' ),
505 'search_items' => __( 'Search orders', 'woocommerce' ),
506 'not_found' => __( 'No orders found', 'woocommerce' ),
507 'not_found_in_trash' => __( 'No orders found in trash', 'woocommerce' ),
508 'parent' => __( 'Parent orders', 'woocommerce' ),
509 'menu_name' => _x( 'Orders', 'Admin menu name', 'woocommerce' ),
510 'filter_items_list' => __( 'Filter orders', 'woocommerce' ),
511 'items_list_navigation' => __( 'Orders navigation', 'woocommerce' ),
512 'items_list' => __( 'Orders list', 'woocommerce' ),
513 ),
514 'description' => __( 'This is where store orders are stored.', 'woocommerce' ),
515 'public' => false,
516 'show_ui' => true,
517 'capability_type' => 'shop_order',
518 'map_meta_cap' => true,
519 'publicly_queryable' => false,
520 'exclude_from_search' => true,
521 'show_in_menu' => current_user_can( 'edit_others_shop_orders' ) ? 'woocommerce' : true,
522 'hierarchical' => false,
523 'show_in_nav_menus' => false,
524 'rewrite' => false,
525 'query_var' => false,
526 'supports' => array( 'title', 'comments', 'custom-fields' ),
527 'has_archive' => false,
528 )
529 )
530 );
531
532 wc_register_order_type(
533 'shop_order_refund',
534 apply_filters(
535 'woocommerce_register_post_type_shop_order_refund',
536 array(
537 'label' => __( 'Refunds', 'woocommerce' ),
538 'capability_type' => 'shop_order',
539 'public' => false,
540 'hierarchical' => false,
541 'supports' => false,
542 'add_order_meta_boxes' => false,
543 'exclude_from_order_count' => true,
544 'exclude_from_order_views' => false,
545 'exclude_from_order_reports' => false,
546 'exclude_from_order_sales_reports' => true,
547 'class_name' => 'WC_Order_Refund',
548 'rewrite' => false,
549 )
550 )
551 );
552
553 if ( 'yes' === get_option( 'woocommerce_enable_coupons' ) ) {
554 register_post_type(
555 'shop_coupon',
556 apply_filters(
557 'woocommerce_register_post_type_shop_coupon',
558 array(
559 'labels' => array(
560 'name' => __( 'Coupons', 'woocommerce' ),
561 'singular_name' => __( 'Coupon', 'woocommerce' ),
562 'menu_name' => _x( 'Coupons', 'Admin menu name', 'woocommerce' ),
563 'add_new' => __( 'Add coupon', 'woocommerce' ),
564 'add_new_item' => __( 'Add new coupon', 'woocommerce' ),
565 'edit' => __( 'Edit', 'woocommerce' ),
566 'edit_item' => __( 'Edit coupon', 'woocommerce' ),
567 'new_item' => __( 'New coupon', 'woocommerce' ),
568 'view_item' => __( 'View coupon', 'woocommerce' ),
569 'search_items' => __( 'Search coupons', 'woocommerce' ),
570 'not_found' => __( 'No coupons found', 'woocommerce' ),
571 'not_found_in_trash' => __( 'No coupons found in trash', 'woocommerce' ),
572 'parent' => __( 'Parent coupon', 'woocommerce' ),
573 'filter_items_list' => __( 'Filter coupons', 'woocommerce' ),
574 'items_list_navigation' => __( 'Coupons navigation', 'woocommerce' ),
575 'items_list' => __( 'Coupons list', 'woocommerce' ),
576 ),
577 'description' => __( 'This is where you can add new coupons that customers can use in your store.', 'woocommerce' ),
578 'public' => false,
579 'show_ui' => true,
580 'capability_type' => 'shop_coupon',
581 'map_meta_cap' => true,
582 'publicly_queryable' => false,
583 'exclude_from_search' => true,
584 'show_in_menu' => current_user_can( 'edit_others_shop_orders' ) ? 'woocommerce' : true,
585 'hierarchical' => false,
586 'rewrite' => false,
587 'query_var' => false,
588 'supports' => array( 'title' ),
589 'show_in_nav_menus' => false,
590 'show_in_admin_bar' => true,
591 )
592 )
593 );
594 }
595
596 do_action( 'woocommerce_after_register_post_type' );
597 }
598
599 /**
600 * Customize taxonomies update messages.
601 *
602 * @param array $messages The list of available messages.
603 * @since 4.4.0
604 * @return bool
605 */
606 public static function updated_term_messages( $messages ) {
607 $messages['product_cat'] = array(
608 0 => '',
609 1 => __( 'Category added.', 'woocommerce' ),
610 2 => __( 'Category deleted.', 'woocommerce' ),
611 3 => __( 'Category updated.', 'woocommerce' ),
612 4 => __( 'Category not added.', 'woocommerce' ),
613 5 => __( 'Category not updated.', 'woocommerce' ),
614 6 => __( 'Categories deleted.', 'woocommerce' ),
615 );
616
617 $messages['product_tag'] = array(
618 0 => '',
619 1 => __( 'Tag added.', 'woocommerce' ),
620 2 => __( 'Tag deleted.', 'woocommerce' ),
621 3 => __( 'Tag updated.', 'woocommerce' ),
622 4 => __( 'Tag not added.', 'woocommerce' ),
623 5 => __( 'Tag not updated.', 'woocommerce' ),
624 6 => __( 'Tags deleted.', 'woocommerce' ),
625 );
626
627 $wc_product_attributes = array();
628 $attribute_taxonomies = wc_get_attribute_taxonomies();
629
630 if ( $attribute_taxonomies ) {
631 foreach ( $attribute_taxonomies as $tax ) {
632 $name = wc_attribute_taxonomy_name( $tax->attribute_name );
633
634 if ( $name ) {
635 $label = ! empty( $tax->attribute_label ) ? $tax->attribute_label : $tax->attribute_name;
636
637 $messages[ $name ] = array(
638 0 => '',
639 /* translators: %s: taxonomy label */
640 1 => sprintf( _x( '%s added', 'taxonomy term messages', 'woocommerce' ), $label ),
641 /* translators: %s: taxonomy label */
642 2 => sprintf( _x( '%s deleted', 'taxonomy term messages', 'woocommerce' ), $label ),
643 /* translators: %s: taxonomy label */
644 3 => sprintf( _x( '%s updated', 'taxonomy term messages', 'woocommerce' ), $label ),
645 /* translators: %s: taxonomy label */
646 4 => sprintf( _x( '%s not added', 'taxonomy term messages', 'woocommerce' ), $label ),
647 /* translators: %s: taxonomy label */
648 5 => sprintf( _x( '%s not updated', 'taxonomy term messages', 'woocommerce' ), $label ),
649 /* translators: %s: taxonomy label */
650 6 => sprintf( _x( '%s deleted', 'taxonomy term messages', 'woocommerce' ), $label ),
651 );
652 }
653 }
654 }
655
656 return $messages;
657 }
658
659 /**
660 * Register our custom post statuses, used for order status.
661 */
662 public static function register_post_status() {
663
664 $order_statuses = apply_filters(
665 'woocommerce_register_shop_order_post_statuses',
666 array(
667 OrderInternalStatus::PENDING => array(
668 'label' => _x( 'Pending payment', 'Order status', 'woocommerce' ),
669 'public' => false,
670 'exclude_from_search' => false,
671 'show_in_admin_all_list' => true,
672 'show_in_admin_status_list' => true,
673 /* translators: %s: number of orders */
674 'label_count' => _n_noop( 'Pending payment <span class="count">(%s)</span>', 'Pending payment <span class="count">(%s)</span>', 'woocommerce' ),
675 ),
676 OrderInternalStatus::PROCESSING => array(
677 'label' => _x( 'Processing', 'Order status', 'woocommerce' ),
678 'public' => false,
679 'exclude_from_search' => false,
680 'show_in_admin_all_list' => true,
681 'show_in_admin_status_list' => true,
682 /* translators: %s: number of orders */
683 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'woocommerce' ),
684 ),
685 OrderInternalStatus::ON_HOLD => array(
686 'label' => _x( 'On hold', 'Order status', 'woocommerce' ),
687 'public' => false,
688 'exclude_from_search' => false,
689 'show_in_admin_all_list' => true,
690 'show_in_admin_status_list' => true,
691 /* translators: %s: number of orders */
692 'label_count' => _n_noop( 'On hold <span class="count">(%s)</span>', 'On hold <span class="count">(%s)</span>', 'woocommerce' ),
693 ),
694 OrderInternalStatus::COMPLETED => array(
695 'label' => _x( 'Completed', 'Order status', 'woocommerce' ),
696 'public' => false,
697 'exclude_from_search' => false,
698 'show_in_admin_all_list' => true,
699 'show_in_admin_status_list' => true,
700 /* translators: %s: number of orders */
701 'label_count' => _n_noop( 'Completed <span class="count">(%s)</span>', 'Completed <span class="count">(%s)</span>', 'woocommerce' ),
702 ),
703 OrderInternalStatus::CANCELLED => array(
704 'label' => _x( 'Cancelled', 'Order status', 'woocommerce' ),
705 'public' => false,
706 'exclude_from_search' => false,
707 'show_in_admin_all_list' => true,
708 'show_in_admin_status_list' => true,
709 /* translators: %s: number of orders */
710 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'woocommerce' ),
711 ),
712 OrderInternalStatus::REFUNDED => array(
713 'label' => _x( 'Refunded', 'Order status', 'woocommerce' ),
714 'public' => false,
715 'exclude_from_search' => false,
716 'show_in_admin_all_list' => true,
717 'show_in_admin_status_list' => true,
718 /* translators: %s: number of orders */
719 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'woocommerce' ),
720 ),
721 OrderInternalStatus::FAILED => array(
722 'label' => _x( 'Failed', 'Order status', 'woocommerce' ),
723 'public' => false,
724 'exclude_from_search' => false,
725 'show_in_admin_all_list' => true,
726 'show_in_admin_status_list' => true,
727 /* translators: %s: number of orders */
728 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'woocommerce' ),
729 ),
730 )
731 );
732
733 foreach ( $order_statuses as $order_status => $values ) {
734 register_post_status( $order_status, $values );
735 }
736 }
737
738 /**
739 * Flush rules if the event is queued.
740 *
741 * @since 3.3.0
742 */
743 public static function maybe_flush_rewrite_rules() {
744 if ( 'yes' === get_option( 'woocommerce_queue_flush_rewrite_rules' ) ) {
745 update_option( 'woocommerce_queue_flush_rewrite_rules', 'no' );
746 self::flush_rewrite_rules();
747 }
748 }
749
750 /**
751 * Flush rewrite rules.
752 */
753 public static function flush_rewrite_rules() {
754 flush_rewrite_rules();
755 }
756
757 /**
758 * Disable Gutenberg for products.
759 *
760 * @param bool $can_edit Whether the post type can be edited or not.
761 * @param string $post_type The post type being checked.
762 * @return bool
763 */
764 public static function gutenberg_can_edit_post_type( $can_edit, $post_type ) {
765 return 'product' === $post_type ? false : $can_edit;
766 }
767
768 /**
769 * Add Product Support to Jetpack Omnisearch.
770 */
771 public static function support_jetpack_omnisearch() {
772 if ( class_exists( 'Jetpack_Omnisearch_Posts' ) ) {
773 new Jetpack_Omnisearch_Posts( 'product' );
774 }
775 }
776
777 /**
778 * Added product for Jetpack related posts.
779 *
780 * @param array $post_types Post types.
781 * @return array
782 */
783 public static function rest_api_allowed_post_types( $post_types ) {
784 $post_types[] = 'product';
785
786 return $post_types;
787 }
788 }
789
790 WC_Post_types::init();
791