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