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