diff --git a/includes/admin/class-wc-admin-taxonomies.php b/includes/admin/class-wc-admin-taxonomies.php index 226b6375bfa..34e4812e28b 100644 --- a/includes/admin/class-wc-admin-taxonomies.php +++ b/includes/admin/class-wc-admin-taxonomies.php @@ -22,6 +22,7 @@ class WC_Admin_Taxonomies { * Constructor */ public function __construct() { + global $wc_product_attributes; // Category/term ordering add_action( 'create_term', array( $this, 'create_term' ), 5, 3 ); @@ -41,6 +42,10 @@ class WC_Admin_Taxonomies { add_action( 'product_cat_pre_add_form', array( $this, 'product_cat_description' ) ); add_action( 'product_shipping_class_pre_add_form', array( $this, 'shipping_class_description' ) ); + foreach ( array_keys( $wc_product_attributes ) as $attribute ) { + add_action( $attribute . '_pre_add_form', array( $this, 'product_attribute_description' ) ); + } + // Maintain hierarchy of terms add_filter( 'wp_terms_checklist_args', array( $this, 'disable_checked_ontop' ) ); } @@ -53,7 +58,6 @@ class WC_Admin_Taxonomies { * @param mixed $taxonomy */ public function create_term( $term_id, $tt_id = '', $taxonomy = '' ) { - if ( $taxonomy != 'product_cat' && ! taxonomy_is_product_attribute( $taxonomy ) ) { return; } @@ -69,15 +73,13 @@ class WC_Admin_Taxonomies { * @param mixed $term_id */ public function delete_term( $term_id ) { - - $term_id = (int) $term_id; - - if ( ! $term_id ) { - return; - } - global $wpdb; - $wpdb->query( "DELETE FROM {$wpdb->woocommerce_termmeta} WHERE `woocommerce_term_id` = " . $term_id ); + + $term_id = absint( $term_id ); + + if ( $term_id ) { + $wpdb->delete( $wpdb->woocommerce_termmeta, array( 'woocommerce_term_id' => $term_id ), array( '%d' ) ); + } } /** @@ -272,6 +274,13 @@ class WC_Admin_Taxonomies { echo wpautop( __( 'Shipping classes can be used to group products of similar type. These groups can then be used by certain shipping methods to provide different rates to different products.', 'woocommerce' ) ); } + /** + * Description for shipping class page to aid users. + */ + public function product_attribute_description() { + echo wpautop( __( 'Attribute terms can be assigned to products and variations.

Note: Deleting a term will remove it from all products and variations to which it has been assigned. Recreating a term will not automatically assign it back to products.', 'woocommerce' ) ); + } + /** * Thumbnail column added to category admin. *