Skip to content

Commit

Permalink
WooCommerce conversion and update
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejolley committed Aug 10, 2011
1 parent 8e8613b commit 0425a68
Show file tree
Hide file tree
Showing 149 changed files with 10,398 additions and 23,580 deletions.
93 changes: 42 additions & 51 deletions admin/jigoshop-admin-attributes.php → admin/admin-attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@
/**
* Functions used for the attributes section in WordPress Admin
*
* The attributes section lets users add custom attributes to assign to products - they can also be used in the layered nav widgets.
* The attributes section lets users add custom attributes to assign to products - they can also be used in the layered nav widget.
*
* @author Jigowatt
* @author WooThemes
* @category Admin
* @package JigoShop
* @package WooCommerce
*/

/**
* Attributes admin panel
*
* Shows the created attributes and lets you add new ones.
* The added attributes are stored in the database and can be used for layered navigation.
*
* @since 1.0
* @usedby jigoshop_admin_menu2()
*/
function jigoshop_attributes() {
function woocommerce_attributes() {

global $wpdb;

Expand All @@ -30,9 +27,9 @@ function jigoshop_attributes() {

if ($attribute_name && $attribute_type && !taxonomy_exists('product_attribute_'.strtolower(sanitize_title($attribute_name)))) :

$wpdb->insert( $wpdb->prefix . "jigoshop_attribute_taxonomies", array( 'attribute_name' => $attribute_name, 'attribute_type' => $attribute_type ), array( '%s', '%s' ) );
$wpdb->insert( $wpdb->prefix . "woocommerce_attribute_taxonomies", array( 'attribute_name' => $attribute_name, 'attribute_type' => $attribute_type ), array( '%s', '%s' ) );

update_option('jigowatt_update_rewrite_rules', '1');
update_option('woocommerce_update_rewrite_rules', '1');

wp_safe_redirect( get_admin_url() . 'admin.php?page=attributes' );
exit;
Expand All @@ -47,7 +44,7 @@ function jigoshop_attributes() {

$attribute_type = $_POST['attribute_type'];

$wpdb->update( $wpdb->prefix . "jigoshop_attribute_taxonomies", array( 'attribute_type' => $attribute_type ), array( 'attribute_id' => $_GET['edit'] ), array( '%s' ) );
$wpdb->update( $wpdb->prefix . "woocommerce_attribute_taxonomies", array( 'attribute_type' => $attribute_type ), array( 'attribute_id' => $_GET['edit'] ), array( '%s' ) );

endif;

Expand All @@ -60,9 +57,9 @@ function jigoshop_attributes() {

if ($delete>0) :

$att_name = $wpdb->get_var("SELECT attribute_name FROM " . $wpdb->prefix . "jigoshop_attribute_taxonomies WHERE attribute_id = '$delete'");
$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 . "jigoshop_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));

Expand All @@ -85,9 +82,9 @@ function jigoshop_attributes() {
endif;

if (isset($_GET['edit']) && $_GET['edit'] > 0) :
jigoshop_edit_attribute();
woocommerce_edit_attribute();
else :
jigoshop_add_attribute();
woocommerce_add_attribute();
endif;

}
Expand All @@ -96,40 +93,37 @@ function jigoshop_attributes() {
* 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() {
function woocommerce_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_type = $wpdb->get_var("SELECT attribute_type FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_id = '$edit'");
?>
<div class="wrap jigoshop">
<div class="icon32 icon32-attributes" id="icon-jigoshop"><br/></div>
<h2><?php _e('Attributes','jigoshop') ?></h2>
<div class="wrap woocommerce">
<div class="icon32 icon32-attributes" id="icon-woocommerce"><br/></div>
<h2><?php _e('Attributes', 'woothemes') ?></h2>
<br class="clear" />
<div id="col-container">
<div id="col-left">
<div class="col-wrap">
<div class="form-wrap">
<h3><?php _e('Edit Attribute','jigoshop') ?></h3>
<p><?php _e('Attribute taxonomy names cannot be changed; you may only change an attributes type.','jigoshop') ?></p>
<h3><?php _e('Edit Attribute', 'woothemes') ?></h3>
<p><?php _e('Attribute taxonomy names cannot be changed; you may only change an attributes type.', 'woothemes') ?></p>
<form action="admin.php?page=attributes&amp;edit=<?php echo $edit; ?>" method="post">

<div class="form-field">
<label for="attribute_type"><?php _e('Attribute type', 'jigoshop'); ?></label>
<label for="attribute_type"><?php _e('Attribute type', 'woothemes'); ?></label>
<select name="attribute_type" id="attribute_type" style="width: 100%;">
<option value="select" <?php if ($att_type=='select') echo 'selected="selected"'; ?>><?php _e('Select','jigoshop') ?></option>
<option value="multiselect" <?php if ($att_type=='multiselect') echo 'selected="selected"'; ?>><?php _e('Multiselect','jigoshop') ?></option>
<option value="text" <?php if ($att_type=='text') echo 'selected="selected"'; ?>><?php _e('Text','jigoshop') ?></option>
<option value="select" <?php if ($att_type=='select') echo 'selected="selected"'; ?>><?php _e('Select', 'woothemes') ?></option>
<option value="multiselect" <?php if ($att_type=='multiselect') echo 'selected="selected"'; ?>><?php _e('Multiselect', 'woothemes') ?></option>
<option value="text" <?php if ($att_type=='text') echo 'selected="selected"'; ?>><?php _e('Text', 'woothemes') ?></option>
</select>
</div>

<p class="submit"><input type="submit" name="save_attribute" id="submit" class="button" value="<?php _e('Save Attribute', 'jigoshop'); ?>"></p>
<p class="submit"><input type="submit" name="save_attribute" id="submit" class="button" value="<?php _e('Save Attribute', 'woothemes'); ?>"></p>
</form>
</div>
</div>
Expand All @@ -144,37 +138,34 @@ function jigoshop_edit_attribute() {
* Add Attribute admin panel
*
* Shows the interface for adding new attributes
*
* @since 1.0
* @usedby jigoshop_attributes()
*/
function jigoshop_add_attribute() {
function woocommerce_add_attribute() {
?>
<div class="wrap jigoshop">
<div class="icon32 icon32-attributes" id="icon-jigoshop"><br/></div>
<h2><?php _e('Attributes','jigoshop') ?></h2>
<div class="wrap woocommerce">
<div class="icon32 icon32-attributes" id="icon-woocommerce"><br/></div>
<h2><?php _e('Attributes', 'woothemes') ?></h2>
<br class="clear" />
<div id="col-container">
<div id="col-right">
<div class="col-wrap">
<table class="widefat fixed" style="width:100%">
<thead>
<tr>
<th scope="col"><?php _e('Name','jigoshop') ?></th>
<th scope="col"><?php _e('Type','jigoshop') ?></th>
<th scope="col"><?php _e('Terms','jigoshop') ?></th>
<th scope="col"><?php _e('Name', 'woothemes') ?></th>
<th scope="col"><?php _e('Type', 'woothemes') ?></th>
<th scope="col"><?php _e('Terms', 'woothemes') ?></th>
</tr>
</thead>
<tbody>
<?php
$attribute_taxonomies = jigoshop::$attribute_taxonomies;
$attribute_taxonomies = woocommerce::$attribute_taxonomies;
if ( $attribute_taxonomies ) :
foreach ($attribute_taxonomies as $tax) :
?><tr>

<td><a href="edit-tags.php?taxonomy=product_attribute_<?php echo strtolower(sanitize_title($tax->attribute_name)); ?>&amp;post_type=product"><?php echo $tax->attribute_name; ?></a>

<div class="row-actions"><span class="edit"><a href="<?php echo add_query_arg('edit', $tax->attribute_id, 'admin.php?page=attributes') ?>"><?php _e('Edit', 'jigoshop'); ?></a> | </span><span class="delete"><a class="delete" href="<?php echo add_query_arg('delete', $tax->attribute_id, 'admin.php?page=attributes') ?>"><?php _e('Delete', 'jigoshop'); ?></a></span></div>
<div class="row-actions"><span class="edit"><a href="<?php echo add_query_arg('edit', $tax->attribute_id, 'admin.php?page=attributes') ?>"><?php _e('Edit', 'woothemes'); ?></a> | </span><span class="delete"><a class="delete" href="<?php echo add_query_arg('delete', $tax->attribute_id, 'admin.php?page=attributes') ?>"><?php _e('Delete', 'woothemes'); ?></a></span></div>
</td>
<td><?php echo ucwords($tax->attribute_type); ?></td>
<td><?php
Expand All @@ -196,7 +187,7 @@ function jigoshop_add_attribute() {
</tr><?php
endforeach;
else :
?><tr><td colspan="5"><?php _e('No attributes currently exist.','jigoshop') ?></td></tr><?php
?><tr><td colspan="5"><?php _e('No attributes currently exist.', 'woothemes') ?></td></tr><?php
endif;
?>
</tbody>
Expand All @@ -206,28 +197,28 @@ function jigoshop_add_attribute() {
<div id="col-left">
<div class="col-wrap">
<div class="form-wrap">
<h3><?php _e('Add New Attribute','jigoshop') ?></h3>
<p><?php _e('Attributes let you define extra product data, such as size or colour. You can use these attributes in the shop sidebar using the "layered nav" widgets. Please note: you cannot rename an attribute later on.','jigoshop') ?></p>
<h3><?php _e('Add New Attribute', 'woothemes') ?></h3>
<p><?php _e('Attributes let you define extra product data, such as size or colour. You can use these attributes in the shop sidebar using the "layered nav" widgets. Please note: you cannot rename an attribute later on.', 'woothemes') ?></p>
<form action="admin.php?page=attributes" method="post">
<div style="width:47%; float:left; margin:0 1% 0 0;">
<div class="form-field">
<label for="attribute_name"><?php _e('Attribute Name', 'jigoshop'); ?></label>
<label for="attribute_name"><?php _e('Attribute Name', 'woothemes'); ?></label>
<input name="attribute_name" id="attribute_name" type="text" value="" />
</div>
</div>
<div style="width:47%; float:left; margin:0 1% 0 0;">
<div class="form-field">
<label for="attribute_type"><?php _e('Attribute type', 'jigoshop'); ?></label>
<label for="attribute_type"><?php _e('Attribute type', 'woothemes'); ?></label>
<select name="attribute_type" id="attribute_type" style="width: 100%;">
<option value="select"><?php _e('Select','jigoshop') ?></option>
<option value="multiselect"><?php _e('Multiselect','jigoshop') ?></option>
<option value="text"><?php _e('Text','jigoshop') ?></option>
<option value="select"><?php _e('Select', 'woothemes') ?></option>
<option value="multiselect"><?php _e('Multiselect', 'woothemes') ?></option>
<option value="text"><?php _e('Text', 'woothemes') ?></option>
</select>
</div>
</div>
<div class="clear"></div>

<p class="submit"><input type="submit" name="add_new_attribute" id="submit" class="button" value="<?php _e('Add Attribute', 'jigoshop'); ?>"></p>
<p class="submit"><input type="submit" name="add_new_attribute" id="submit" class="button" value="<?php _e('Add Attribute', 'woothemes'); ?>"></p>
</form>
</div>
</div>
Expand All @@ -237,7 +228,7 @@ function jigoshop_add_attribute() {
/* <![CDATA[ */

jQuery('a.delete').click(function(){
var answer = confirm ("<?php _e('Are you sure you want to delete this?', 'jigoshop'); ?>");
var answer = confirm ("<?php _e('Are you sure you want to delete this?', 'woothemes'); ?>");
if (answer) return true;
return false;
});
Expand Down
Loading

0 comments on commit 0425a68

Please sign in to comment.