From 221b4672d9fd704c4be1f7313c1c10ff14bbdb92 Mon Sep 17 00:00:00 2001 From: Caleb Burks <19caleb95@gmail.com> Date: Fri, 9 Feb 2018 17:31:56 -0500 Subject: [PATCH] Use wc_has_custom_attribute_types() --- includes/admin/class-wc-admin-attributes.php | 14 ++++++++------ includes/wc-attribute-functions.php | 12 ++++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/includes/admin/class-wc-admin-attributes.php b/includes/admin/class-wc-admin-attributes.php index 41b16c988a5..ce79f083643 100644 --- a/includes/admin/class-wc-admin-attributes.php +++ b/includes/admin/class-wc-admin-attributes.php @@ -221,9 +221,7 @@ class WC_Admin_Attributes { * `product_attributes_type_selector` filter. If there is only the default type registered, * this setting will be hidden. */ - $attribute_types = wc_get_attribute_types(); - - if ( 1 < count( $attribute_types ) || ! array_key_exists( 'select', $attribute_types ) ) { + if ( wc_has_custom_attribute_types() ) { ?> @@ -294,6 +292,9 @@ class WC_Admin_Attributes { + + + @@ -309,6 +310,9 @@ class WC_Admin_Attributes {
|
attribute_name ); ?> + + attribute_type ) ); ?> attribute_public ? esc_html__( '(Public)', 'woocommerce' ) : ''; ?> + attribute_orderby ) { case 'name' : @@ -403,9 +407,7 @@ class WC_Admin_Attributes { * `product_attributes_type_selector` filter. If there is only the default type registered, * this setting will be hidden. */ - $attribute_types = wc_get_attribute_types(); - - if ( 1 < count( $attribute_types ) || ! array_key_exists( 'select', $attribute_types ) ) { + if ( wc_has_custom_attribute_types() ) { ?>
diff --git a/includes/wc-attribute-functions.php b/includes/wc-attribute-functions.php index 9fae15240be..250b46cc8e1 100644 --- a/includes/wc-attribute-functions.php +++ b/includes/wc-attribute-functions.php @@ -197,6 +197,18 @@ function wc_get_attribute_types() { ) ); } +/** + * Check if there are custom attribute types. + * + * @since 3.3.2 + * @return bool True if there are custom types, otherwise false. + */ +function wc_has_custom_attribute_types() { + $types = wc_get_attribute_types(); + + return 1 < count( $types ) || ! array_key_exists( 'select', $types ); +} + /** * Get attribute type label. *