attribute_taxonomy_name($attribute_name) )) : $wpdb->insert( $wpdb->prefix . "woocommerce_attribute_taxonomies", array( 'attribute_name' => $attribute_name, 'attribute_label' => $attribute_label, 'attribute_type' => $attribute_type ), array( '%s', '%s' ) ); wp_safe_redirect( get_admin_url() . 'admin.php?page=woocommerce_attributes' ); exit; endif; elseif (isset($_POST['save_attribute']) && $_POST['save_attribute'] && isset($_GET['edit'])) : $edit = absint($_GET['edit']); check_admin_referer( 'woocommerce-save-attribute_' . $edit ); if ($edit>0) : $attribute_type = $_POST['attribute_type']; $attribute_label = (string) $_POST['attribute_label']; $wpdb->update( $wpdb->prefix . "woocommerce_attribute_taxonomies", array( 'attribute_type' => $attribute_type, 'attribute_label' => $attribute_label ), array( 'attribute_id' => $_GET['edit'] ), array( '%s', '%s' ) ); endif; wp_safe_redirect( get_admin_url() . 'admin.php?page=woocommerce_attributes' ); exit; elseif (isset($_GET['delete'])) : check_admin_referer( 'woocommerce-delete-attribute_' . absint( $_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 = $woocommerce->attribute_taxonomy_name($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=woocommerce_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 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'"); $att_label = $wpdb->get_var("SELECT attribute_label FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_id = '$edit'"); ?>
attribute_name; ?> | attribute_label); ?> | attribute_type); ?> | attribute_taxonomy_name($tax->attribute_name))) : $terms_array = array(); $terms = get_terms( $woocommerce->attribute_taxonomy_name($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; ?> |