diff --git a/includes/admin/class-wc-admin-attributes.php b/includes/admin/class-wc-admin-attributes.php index bd8467c50ad..7033189829f 100644 --- a/includes/admin/class-wc-admin-attributes.php +++ b/includes/admin/class-wc-admin-attributes.php @@ -26,9 +26,9 @@ class WC_Admin_Attributes { $action = ''; // Action to perform: add, edit, delete or none. - if ( ! empty( $_POST['add_new_attribute'] ) ) { + if ( ! empty( $_POST['add_new_attribute'] ) ) { // WPCS: CSRF ok. $action = 'add'; - } elseif ( ! empty( $_POST['save_attribute'] ) && ! empty( $_GET['edit'] ) ) { + } elseif ( ! empty( $_POST['save_attribute'] ) && ! empty( $_GET['edit'] ) ) { // WPCS: CSRF ok. $action = 'edit'; } elseif ( ! empty( $_GET['delete'] ) ) { $action = 'delete'; @@ -65,11 +65,11 @@ class WC_Admin_Attributes { */ private static function get_posted_attribute() { $attribute = array( - 'attribute_label' => isset( $_POST['attribute_label'] ) ? wc_clean( stripslashes( $_POST['attribute_label'] ) ) : '', - 'attribute_name' => isset( $_POST['attribute_name'] ) ? wc_sanitize_taxonomy_name( stripslashes( $_POST['attribute_name'] ) ) : '', - 'attribute_type' => isset( $_POST['attribute_type'] ) ? wc_clean( $_POST['attribute_type'] ) : 'select', - 'attribute_orderby' => isset( $_POST['attribute_orderby'] ) ? wc_clean( $_POST['attribute_orderby'] ) : '', - 'attribute_public' => isset( $_POST['attribute_public'] ) ? 1 : 0, + 'attribute_label' => isset( $_POST['attribute_label'] ) ? wc_clean( wp_unslash( $_POST['attribute_label'] ) ) : '', // WPCS: input var ok, CSRF ok. + 'attribute_name' => isset( $_POST['attribute_name'] ) ? wc_sanitize_taxonomy_name( wp_unslash( $_POST['attribute_name'] ) ) : '', // WPCS: input var ok, CSRF ok, sanitization ok. + 'attribute_type' => isset( $_POST['attribute_type'] ) ? wc_clean( wp_unslash( $_POST['attribute_type'] ) ) : 'select', // WPCS: input var ok, CSRF ok. + 'attribute_orderby' => isset( $_POST['attribute_orderby'] ) ? wc_clean( wp_unslash( $_POST['attribute_orderby'] ) ) : '', // WPCS: input var ok, CSRF ok. + 'attribute_public' => isset( $_POST['attribute_public'] ) ? 1 : 0, // WPCS: input var ok, CSRF ok. ); if ( empty( $attribute['attribute_type'] ) ) { @@ -117,7 +117,7 @@ class WC_Admin_Attributes { * @return bool|WP_Error */ private static function process_edit_attribute() { - $attribute_id = absint( $_GET['edit'] ); + $attribute_id = isset( $_GET['edit'] ) ? absint( $_GET['edit'] ) : 0; check_admin_referer( 'woocommerce-save-attribute_' . $attribute_id ); $attribute = self::get_posted_attribute(); @@ -135,7 +135,7 @@ class WC_Admin_Attributes { return $id; } - echo '
' . __( 'Attribute updated successfully', 'woocommerce' ) . '
' . esc_html__( 'Attribute updated successfully', 'woocommerce' ) . '