insert( $wpdb->prefix . "jigoshop_attribute_taxonomies", array( 'attribute_name' => $attribute_name, 'attribute_label' => $attribute_label, 'attribute_type' => $attribute_type ), array( '%s', '%s' ) );
update_option('jigowatt_update_rewrite_rules', '1');
wp_safe_redirect( get_admin_url() . 'edit.php?post_type=product&page=jigoshop_attributes' );
exit;
else :
print_r('
'.__('That attribute already exists, no additions were made.', 'jigoshop' ).'
');
endif;
elseif (isset($_POST['save_attribute']) && $_POST['save_attribute'] && isset($_GET['edit'])) :
$edit = absint($_GET['edit']);
if ($edit>0) :
$attribute_type = $_POST['attribute_type'];
$attribute_label = (string) $_POST['attribute_label'];
$wpdb->update( $wpdb->prefix . "jigoshop_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() . 'edit.php?post_type=product&page=jigoshop_attributes' );
exit;
elseif (isset($_GET['delete'])) :
$delete = absint($_GET['delete']);
if ($delete>0) :
$att_name = $wpdb->get_var("SELECT attribute_name FROM " . $wpdb->prefix . "jigoshop_attribute_taxonomies WHERE attribute_id = '$delete'");
if ($att_name && $wpdb->query("DELETE FROM " . $wpdb->prefix . "jigoshop_attribute_taxonomies WHERE attribute_id = '$delete'")) :
$taxonomy = 'pa_'.sanitize_title($att_name);
// Old taxonomy prefix left in for backwards compatibility
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() . 'edit.php?post_type=product&page=jigoshop_attributes' );
exit;
endif;
endif;
endif;
if (isset($_GET['edit']) && $_GET['edit'] > 0) :
jigoshop_edit_attribute();
else :
jigoshop_add_attribute();
endif;
}
/**
* Edit Attribute admin panel
*
* Shows the interface for changing an attributes type between select, multiselect and text
*
* @since 1.0
* @usedby jigoshop_attributes()
*/
function jigoshop_edit_attribute() {
global $wpdb;
$edit = absint($_GET['edit']);
$att_type = $wpdb->get_var("SELECT attribute_type FROM " . $wpdb->prefix . "jigoshop_attribute_taxonomies WHERE attribute_id = '$edit'");
$att_label = $wpdb->get_var("SELECT attribute_label FROM " . $wpdb->prefix . "jigoshop_attribute_taxonomies WHERE attribute_id = '$edit'");
?>
|
|
|
|
attribute_name;
if ( isset( $tax->attribute_label ) ) { $att_title = $tax->attribute_label; }
?>
attribute_name; ?>
|
|
attribute_type ) ); ?> |
attribute_name))) :
$terms_array = array();
$terms = get_terms( 'pa_'.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;
?> |
|
|