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0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / includes / wc-attribute-functions.php
woocommerce / includes Last commit date
abstracts 9 years ago admin 9 years ago api 9 years ago cli 9 years ago data-stores 9 years ago emails 9 years ago gateways 9 years ago interfaces 9 years ago legacy 9 years ago libraries 9 years ago log-handlers 9 years ago payment-tokens 9 years ago shipping 9 years ago shortcodes 9 years ago theme-support 9 years ago vendor 9 years ago walkers 9 years ago widgets 9 years ago class-wc-ajax.php 9 years ago class-wc-api.php 9 years ago class-wc-auth.php 9 years ago class-wc-autoloader.php 9 years ago class-wc-background-emailer.php 9 years ago class-wc-background-updater.php 9 years ago class-wc-breadcrumb.php 9 years ago class-wc-cache-helper.php 9 years ago class-wc-cart.php 9 years ago class-wc-checkout.php 9 years ago class-wc-cli.php 9 years ago class-wc-comments.php 9 years ago class-wc-countries.php 9 years ago class-wc-coupon.php 9 years ago class-wc-customer-download.php 9 years ago class-wc-customer.php 9 years ago class-wc-data-exception.php 9 years ago class-wc-data-store.php 9 years ago class-wc-datetime.php 9 years ago class-wc-deprecated-action-hooks.php 9 years ago class-wc-deprecated-filter-hooks.php 9 years ago class-wc-download-handler.php 9 years ago class-wc-emails.php 9 years ago class-wc-embed.php 9 years ago class-wc-form-handler.php 9 years ago class-wc-frontend-scripts.php 9 years ago class-wc-geo-ip.php 9 years ago class-wc-geolocation.php 9 years ago class-wc-https.php 9 years ago class-wc-install.php 9 years ago class-wc-integrations.php 9 years ago class-wc-legacy-api.php 9 years ago class-wc-log-levels.php 9 years ago class-wc-logger.php 9 years ago class-wc-order-factory.php 9 years ago class-wc-order-item-coupon.php 9 years ago class-wc-order-item-fee.php 9 years ago class-wc-order-item-meta.php 9 years ago class-wc-order-item-product.php 9 years ago class-wc-order-item-shipping.php 9 years ago class-wc-order-item-tax.php 9 years ago class-wc-order-item.php 9 years ago class-wc-order-refund.php 9 years ago class-wc-order.php 9 years ago class-wc-payment-gateways.php 9 years ago class-wc-payment-tokens.php 9 years ago class-wc-post-data.php 9 years ago class-wc-post-types.php 9 years ago class-wc-product-attribute.php 9 years ago class-wc-product-download.php 9 years ago class-wc-product-external.php 9 years ago class-wc-product-factory.php 9 years ago class-wc-product-grouped.php 9 years ago class-wc-product-simple.php 9 years ago class-wc-product-variable.php 9 years ago class-wc-product-variation.php 9 years ago class-wc-query.php 9 years ago class-wc-register-wp-admin-settings.php 9 years ago class-wc-session-handler.php 9 years ago class-wc-shipping-rate.php 9 years ago class-wc-shipping-zone.php 9 years ago class-wc-shipping-zones.php 9 years ago class-wc-shipping.php 9 years ago class-wc-shortcodes.php 9 years ago class-wc-structured-data.php 9 years ago class-wc-tax.php 9 years ago class-wc-template-loader.php 9 years ago class-wc-tracker.php 9 years ago class-wc-validation.php 9 years ago class-wc-webhook.php 9 years ago wc-account-functions.php 9 years ago wc-attribute-functions.php 9 years ago wc-cart-functions.php 9 years ago wc-conditional-functions.php 9 years ago wc-core-functions.php 9 years ago wc-coupon-functions.php 9 years ago wc-deprecated-functions.php 9 years ago wc-formatting-functions.php 9 years ago wc-notice-functions.php 9 years ago wc-order-functions.php 9 years ago wc-order-item-functions.php 9 years ago wc-page-functions.php 9 years ago wc-product-functions.php 9 years ago wc-rest-functions.php 9 years ago wc-stock-functions.php 9 years ago wc-template-functions.php 9 years ago wc-template-hooks.php 9 years ago wc-term-functions.php 9 years ago wc-update-functions.php 9 years ago wc-user-functions.php 9 years ago wc-webhook-functions.php 9 years ago wc-widget-functions.php 9 years ago
wc-attribute-functions.php
324 lines
1 <?php
2 /**
3 * WooCommerce Attribute Functions
4 *
5 * @author WooThemes
6 * @category Core
7 * @package WooCommerce/Functions
8 * @version 2.1.0
9 */
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit; // Exit if accessed directly
13 }
14
15 /**
16 * Gets text attributes from a string.
17 *
18 * @since 2.4
19 * @return array
20 */
21 function wc_get_text_attributes( $raw_attributes ) {
22 return array_filter( array_map( 'trim', explode( WC_DELIMITER, html_entity_decode( $raw_attributes, ENT_QUOTES, get_bloginfo( 'charset' ) ) ) ), 'wc_get_text_attributes_filter_callback' );
23 }
24
25 /**
26 * See if an attribute is actually valid.
27 * @since 3.0.0
28 * @param string $value
29 * @return bool
30 */
31 function wc_get_text_attributes_filter_callback( $value ) {
32 return '' !== $value;
33 }
34
35 /**
36 * Implode an array of attributes using WC_DELIMITER.
37 * @since 3.0.0
38 * @param array $attributes
39 * @return string
40 */
41 function wc_implode_text_attributes( $attributes ) {
42 return implode( ' ' . WC_DELIMITER . ' ', $attributes );
43 }
44
45 /**
46 * Get attribute taxonomies.
47 *
48 * @return array of objects
49 */
50 function wc_get_attribute_taxonomies() {
51 if ( false === ( $attribute_taxonomies = get_transient( 'wc_attribute_taxonomies' ) ) ) {
52 global $wpdb;
53
54 $attribute_taxonomies = $wpdb->get_results( "SELECT * FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies order by attribute_name ASC;" );
55
56 set_transient( 'wc_attribute_taxonomies', $attribute_taxonomies );
57 }
58
59 return (array) array_filter( apply_filters( 'woocommerce_attribute_taxonomies', $attribute_taxonomies ) );
60 }
61
62 /**
63 * Get a product attribute name.
64 *
65 * @param string $attribute_name Attribute name.
66 * @return string
67 */
68 function wc_attribute_taxonomy_name( $attribute_name ) {
69 return 'pa_' . wc_sanitize_taxonomy_name( $attribute_name );
70 }
71
72 /**
73 * Get the attribute name used when storing values in post meta.
74 *
75 * @param string $attribute_name Attribute name.
76 * @since 2.6.0
77 * @return string
78 */
79 function wc_variation_attribute_name( $attribute_name ) {
80 return 'attribute_' . sanitize_title( $attribute_name );
81 }
82
83 /**
84 * Get a product attribute name by ID.
85 *
86 * @since 2.4.0
87 * @param int $attribute_id Attribute ID.
88 * @return string Return an empty string if attribute doesn't exist.
89 */
90 function wc_attribute_taxonomy_name_by_id( $attribute_id ) {
91 global $wpdb;
92
93 $attribute_name = $wpdb->get_var( $wpdb->prepare( "
94 SELECT attribute_name
95 FROM {$wpdb->prefix}woocommerce_attribute_taxonomies
96 WHERE attribute_id = %d
97 ", $attribute_id ) );
98
99 if ( $attribute_name && ! is_wp_error( $attribute_name ) ) {
100 return wc_attribute_taxonomy_name( $attribute_name );
101 }
102
103 return '';
104 }
105
106 /**
107 * Get a product attribute ID by name.
108 *
109 * @since 2.6.0
110 * @param string $name Attribute name.
111 * @return int
112 */
113 function wc_attribute_taxonomy_id_by_name( $name ) {
114 $name = str_replace( 'pa_', '', $name );
115 $taxonomies = wp_list_pluck( wc_get_attribute_taxonomies(), 'attribute_id', 'attribute_name' );
116
117 return isset( $taxonomies[ $name ] ) ? (int) $taxonomies[ $name ] : 0;
118 }
119
120 /**
121 * Get a product attributes label.
122 *
123 * @param string $name
124 * @param object $product object Optional
125 * @return string
126 */
127 function wc_attribute_label( $name, $product = '' ) {
128 global $wpdb;
129
130 if ( taxonomy_is_product_attribute( $name ) ) {
131 $name = wc_sanitize_taxonomy_name( str_replace( 'pa_', '', $name ) );
132 $all_labels = wp_list_pluck( wc_get_attribute_taxonomies(), 'attribute_label', 'attribute_name' );
133 $label = isset( $all_labels[ $name ] ) ? $all_labels[ $name ] : $name;
134 } elseif ( $product ) {
135 if ( $product->is_type( 'variation' ) ) {
136 $product = wc_get_product( $product->get_parent_id() );
137 }
138 // Attempt to get label from product, as entered by the user.
139 if ( ( $attributes = $product->get_attributes() ) && isset( $attributes[ sanitize_title( $name ) ] ) ) {
140 $label = $attributes[ sanitize_title( $name ) ]->get_name();
141 } else {
142 $label = $name;
143 }
144 } else {
145 $label = $name;
146 }
147
148 return apply_filters( 'woocommerce_attribute_label', $label, $name, $product );
149 }
150
151 /**
152 * Get a product attributes orderby setting.
153 *
154 * @param mixed $name
155 * @return string
156 */
157 function wc_attribute_orderby( $name ) {
158 global $wc_product_attributes, $wpdb;
159
160 $name = str_replace( 'pa_', '', sanitize_title( $name ) );
161
162 if ( isset( $wc_product_attributes[ 'pa_' . $name ] ) ) {
163 $orderby = $wc_product_attributes[ 'pa_' . $name ]->attribute_orderby;
164 } else {
165 $orderby = $wpdb->get_var( $wpdb->prepare( "SELECT attribute_orderby FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_name = %s;", $name ) );
166 }
167
168 return apply_filters( 'woocommerce_attribute_orderby', $orderby, $name );
169 }
170
171 /**
172 * Get an array of product attribute taxonomies.
173 *
174 * @return array
175 */
176 function wc_get_attribute_taxonomy_names() {
177 $taxonomy_names = array();
178 $attribute_taxonomies = wc_get_attribute_taxonomies();
179 if ( ! empty( $attribute_taxonomies ) ) {
180 foreach ( $attribute_taxonomies as $tax ) {
181 $taxonomy_names[] = wc_attribute_taxonomy_name( $tax->attribute_name );
182 }
183 }
184 return $taxonomy_names;
185 }
186
187 /**
188 * Get attribute types.
189 *
190 * @since 2.4.0
191 * @return array
192 */
193 function wc_get_attribute_types() {
194 return (array) apply_filters( 'product_attributes_type_selector', array(
195 'select' => __( 'Select', 'woocommerce' ),
196 'text' => __( 'Text', 'woocommerce' ),
197 ) );
198 }
199
200 /**
201 * Get attribute type label.
202 *
203 * @since 3.0.0
204 * @param string $type Attribute type slug.
205 * @return string
206 */
207 function wc_get_attribute_type_label( $type ) {
208 $types = wc_get_attribute_types();
209
210 return isset( $types[ $type ] ) ? $types[ $type ] : ucfirst( $type );
211 }
212
213 /**
214 * Check if attribute name is reserved.
215 * https://codex.wordpress.org/Function_Reference/register_taxonomy#Reserved_Terms.
216 *
217 * @since 2.4.0
218 * @param string $attribute_name
219 * @return bool
220 */
221 function wc_check_if_attribute_name_is_reserved( $attribute_name ) {
222 // Forbidden attribute names
223 $reserved_terms = array(
224 'attachment',
225 'attachment_id',
226 'author',
227 'author_name',
228 'calendar',
229 'cat',
230 'category',
231 'category__and',
232 'category__in',
233 'category__not_in',
234 'category_name',
235 'comments_per_page',
236 'comments_popup',
237 'cpage',
238 'day',
239 'debug',
240 'error',
241 'exact',
242 'feed',
243 'hour',
244 'link_category',
245 'm',
246 'minute',
247 'monthnum',
248 'more',
249 'name',
250 'nav_menu',
251 'nopaging',
252 'offset',
253 'order',
254 'orderby',
255 'p',
256 'page',
257 'page_id',
258 'paged',
259 'pagename',
260 'pb',
261 'perm',
262 'post',
263 'post__in',
264 'post__not_in',
265 'post_format',
266 'post_mime_type',
267 'post_status',
268 'post_tag',
269 'post_type',
270 'posts',
271 'posts_per_archive_page',
272 'posts_per_page',
273 'preview',
274 'robots',
275 's',
276 'search',
277 'second',
278 'sentence',
279 'showposts',
280 'static',
281 'subpost',
282 'subpost_id',
283 'tag',
284 'tag__and',
285 'tag__in',
286 'tag__not_in',
287 'tag_id',
288 'tag_slug__and',
289 'tag_slug__in',
290 'taxonomy',
291 'tb',
292 'term',
293 'type',
294 'w',
295 'withcomments',
296 'withoutcomments',
297 'year',
298 );
299
300 return in_array( $attribute_name, $reserved_terms );
301 }
302
303 /**
304 * Callback for array filter to get visible only.
305 *
306 * @since 3.0.0
307 * @param WC_Product $product
308 * @return bool
309 */
310 function wc_attributes_array_filter_visible( $attribute ) {
311 return $attribute && is_a( $attribute, 'WC_Product_Attribute' ) && $attribute->get_visible() && ( ! $attribute->is_taxonomy() || taxonomy_exists( $attribute->get_name() ) );
312 }
313
314 /**
315 * Callback for array filter to get variation attributes only.
316 *
317 * @since 3.0.0
318 * @param WC_Product $product
319 * @return bool
320 */
321 function wc_attributes_array_filter_variation( $attribute ) {
322 return $attribute && is_a( $attribute, 'WC_Product_Attribute' ) && $attribute->get_variation();
323 }
324