insert( $wpdb->prefix . "woocommerce_attribute_taxonomies", array( 'attribute_name' => $attribute_name, 'attribute_type' => $attribute_type ), array( '%s', '%s' ) ); update_option('woocommerce_update_rewrite_rules', '1'); wp_safe_redirect( get_admin_url() . 'admin.php?page=attributes' ); exit; endif; elseif (isset($_POST['save_attribute']) && $_POST['save_attribute'] && isset($_GET['edit'])) : $edit = absint($_GET['edit']); if ($edit>0) : $attribute_type = $_POST['attribute_type']; $wpdb->update( $wpdb->prefix . "woocommerce_attribute_taxonomies", array( 'attribute_type' => $attribute_type ), array( 'attribute_id' => $_GET['edit'] ), array( '%s' ) ); endif; wp_safe_redirect( get_admin_url() . 'admin.php?page=attributes' ); exit; elseif (isset($_GET['delete'])) : $delete = absint($_GET['delete']); if ($delete>0) : $att_name = $wpdb->get_var("SELECT attribute_name FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_id = '$delete'"); if ($att_name && $wpdb->query("DELETE FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_id = '$delete'")) : $taxonomy = 'product_attribute_'.strtolower(sanitize_title($att_name)); if (taxonomy_exists($taxonomy)) : $terms = get_terms($taxonomy, 'orderby=name&hide_empty=0'); foreach ($terms as $term) { wp_delete_term( $term->term_id, $taxonomy ); } endif; wp_safe_redirect( get_admin_url() . 'admin.php?page=attributes' ); exit; endif; endif; endif; if (isset($_GET['edit']) && $_GET['edit'] > 0) : woocommerce_edit_attribute(); else : woocommerce_add_attribute(); endif; } /** * Edit Attribute admin panel * * Shows the interface for changing an attributes type between select, multiselect and text */ function woocommerce_edit_attribute() { global $wpdb; $edit = absint($_GET['edit']); $att_type = $wpdb->get_var("SELECT attribute_type FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_id = '$edit'"); ?>




attribute_name; ?>
|
attribute_type); ?> attribute_name)))) : $terms_array = array(); $terms = get_terms( 'product_attribute_'.strtolower(sanitize_title($tax->attribute_name)), 'orderby=name&hide_empty=0' ); if ($terms) : foreach ($terms as $term) : $terms_array[] = $term->name; endforeach; echo implode(', ', $terms_array); else : echo ''; endif; else : echo ''; endif; ?>