public static function woocp_features_orders() { $unavaliable_fields = WC_Compare_Categories_Fields_Data::get_unavaliable_field_results('field_name ASC'); if (is_array($unavaliable_fields) && count($unavaliable_fields) > 0) { $un_i = 0; ?> <h3 id="#un_assigned"><?php _e('Un-Assigned Features (Assign to a Category to activate)', 'woo_cp'); ?> </h3> <form action="admin.php?page=woo-compare-features" method="post" name="form_delete_fields" id="form_delete_fields" style="margin-bottom:30px;"> <table cellspacing="0" class="widefat post fixed" style="width:535px;"> <thead> <tr> <th width="25" class="manage-column" scope="col" style="white-space: nowrap;"><input id="toggle1" class="toggle" type="checkbox" style="margin:0;" /></th> <th width="30" class="manage-column" scope="col" style="white-space: nowrap;"><?php _e('No', 'woo_cp'); ?> </th> <th class="manage-column" scope="col"><?php _e('Feature Name', 'woo_cp'); ?> </th> <th width="90" class="manage-column" scope="col" style="text-align:right"><?php _e('Type', 'woo_cp'); ?> </th> <th width="100" class="manage-column" scope="col" style="text-align:right"></th> </tr> </thead> <tbody> <?php foreach ($unavaliable_fields as $field_data) { $un_i++; ?> <tr> <td><input class="list_fields" type="checkbox" name="un_fields[]" value="<?php echo $field_data->id; ?> " /></td> <td><?php echo $un_i; ?> </td> <td><?php echo stripslashes($field_data->field_name); ?> </td> <td align="right"><?php echo WC_Compare_Fields_Class::$default_types[$field_data->field_type]['name']; ?> </td> <td align="right"><a href="admin.php?page=woo-compare-features&act=field-edit&field_id=<?php echo $field_data->id; ?> " class="c_field_edit" title="<?php _e('Edit', 'woo_cp'); ?> " ><?php _e('Edit', 'woo_cp'); ?> </a> | <a href="admin.php?page=woo-compare-features&act=field-delete&field_id=<?php echo $field_data->id; ?> " class="c_field_delete" onclick="javascript:return confirmation('<?php _e('Are you sure you want to delete', 'woo_cp'); ?> #<?php echo htmlspecialchars($field_data->field_name); ?> ');" title="<?php _e('Delete', 'woo_cp'); ?> " ><?php _e('Delete', 'woo_cp'); ?> </a></td> </tr> <?php } ?> </tbody> </table> <div style="margin-top:10px;"><input type="submit" name="bt_delete" id="bt_delete" class="button button-primary" value="<?php _e('Delete', 'woo_cp'); ?> " onclick="if (confirm('<?php _e('Are you sure about deleting this?', 'woo_cp'); ?> ')) return true; else return false" /></div> </form> <?php } $compare_cats = WC_Compare_Categories_Data::get_results('', 'category_order ASC'); if (is_array($compare_cats) && count($compare_cats) > 0) { ?> <h3><?php _e('Manage Compare Categories and Features', 'woo_cp'); ?> </h3> <p><?php _e('Use drag and drop to change Category order and Feature order within Categories.', 'woo_cp'); ?> </p> <div class="updated below-h2 update_feature_order_message" style="display:none"><p></p></div> <div style="clear:both"></div> <ul style="margin:0; padding:0;" class="sorttable"> <?php foreach ($compare_cats as $cat) { $compare_fields = WC_Compare_Categories_Fields_Data::get_results("cat_id='" . $cat->id . "'", 'cf.field_order ASC'); ?> <li id="recordsArray_<?php echo $cat->id; ?> "> <input type="hidden" name="compare_orders_<?php echo $cat->id; ?> " class="compare_category_id" value="<?php echo $cat->id; ?> " /> <table cellspacing="0" class="widefat post fixed sorttable" id="compare_orders_<?php echo $cat->id; ?> " style="width:535px; margin-bottom:20px;"> <thead> <tr> <th width="25" style="white-space: nowrap;"><span class="c_field_name"> </span></th> <th><strong><?php echo stripslashes($cat->category_name); ?> </strong> :</th> <th width="90"></th> <th width="100" style="text-align:right; font-size:12px;white-space: nowrap;"><a href="admin.php?page=woo-compare-features&act=cat-edit&category_id=<?php echo $cat->id; ?> " class="c_field_edit" title="<?php _e('Edit', 'woo_cp'); ?> "><?php _e('Edit', 'woo_cp'); ?> </a> | <a href="admin.php?page=woo-compare-features&act=cat-delete&category_id=<?php echo $cat->id; ?> " title="<?php _e('Delete', 'woo_cp'); ?> " class="c_field_delete" onclick="javascript:return confirmation('<?php _e('Are you sure you want to delete', 'woo_cp'); ?> #<?php echo htmlspecialchars($cat->category_name); ?> ');"><?php _e('Delete', 'woo_cp'); ?> </a><?php if (is_array($compare_fields) && count($compare_fields) > 0) { ?> | <span class="c_openclose_table c_close_table" id="expand_<?php echo $cat->id; ?> "> </span><?php } else { ?> | <span class="c_openclose_none"> </span><?php } ?> </th> </tr> </thead> <tbody class="expand_<?php echo $cat->id; ?> "> <?php if (is_array($compare_fields) && count($compare_fields) > 0) { $i = 0; foreach ($compare_fields as $field_data) { $i++; ?> <tr id="recordsArray_<?php echo $field_data->id; ?> " style="display:none"> <td><span class="compare_sort"><?php echo $i; ?> </span>.</td> <td><div class="c_field_name"><?php echo stripslashes($field_data->field_name); ?> </div></td> <td align="right"><?php echo WC_Compare_Fields_Class::$default_types[$field_data->field_type]['name']; ?> </td> <td align="right"><a href="admin.php?page=woo-compare-features&act=field-edit&field_id=<?php echo $field_data->id; ?> " class="c_field_edit" title="<?php _e('Edit', 'woo_cp'); ?> " ><?php _e('Edit', 'woo_cp'); ?> </a> | <a href="admin.php?page=woo-compare-features&act=field-delete&field_id=<?php echo $field_data->id; ?> &cat_id=<?php echo $cat->id; ?> " class="c_field_delete" onclick="javascript:return confirmation('<?php _e('Are you sure you want to remove', 'woo_cp'); ?> #<?php echo htmlspecialchars($field_data->field_name); ?> <?php _e('from', 'woo_cp'); ?> #<?php echo htmlspecialchars($cat->category_name); ?> ');" title="<?php _e('Remove', 'woo_cp'); ?> " ><?php _e('Remove', 'woo_cp'); ?> </a></td> </tr> <?php } } else { echo '<tr><td colspan="4">' . __('You have not assigned any Features to this category yet. No Hurry!', 'woo_cp') . '</td></tr>'; } ?> </tbody> </table> </li> <?php } ?> </ul> <?php wp_enqueue_script('jquery-ui-sortable'); ?> <?php $woocp_update_order = wp_create_nonce("woocp-update-order"); ?> <?php $woocp_update_cat_order = wp_create_nonce("woocp-update-cat-order"); ?> <script type="text/javascript"> (function($){ $(function(){ $(".c_openclose_table").click( function() { if ( $(this).hasClass('c_close_table') ) { $(this).removeClass("c_close_table"); $(this).addClass("c_open_table"); $("tbody."+$(this).attr('id')+" tr").css('display', ''); } else { $(this).removeClass("c_open_table"); $(this).addClass("c_close_table"); $("tbody."+$(this).attr('id')+" tr").css('display', 'none'); } }); var fixHelper = function(e, ui) { ui.children().each(function() { $(this).width($(this).width()); }); return ui; }; $(".sorttable tbody").sortable({ helper: fixHelper, placeholder: "ui-state-highlight", opacity: 0.8, cursor: 'move', update: function() { var cat_id = $(this).parent('table').siblings(".compare_category_id").val(); var order = $(this).sortable("serialize") + '&action=woocp_update_orders&security=<?php echo $woocp_update_order; ?> &cat_id='+cat_id; $.post("<?php echo admin_url('admin-ajax.php', 'relative'); ?> ", order, function(theResponse){ $(".update_feature_order_message p").html(theResponse); $(".update_feature_order_message").show(); $("#compare_orders_"+cat_id).find(".compare_sort").each(function(index){ $(this).html(index+1); }); }); } }); $("ul.sorttable").sortable({ placeholder: "ui-state-highlight", opacity: 0.8, cursor: 'move', update: function() { var order = $(this).sortable("serialize") + '&action=woocp_update_cat_orders&security=<?php echo $woocp_update_cat_order; ?> '; $.post("<?php echo admin_url('admin-ajax.php', 'relative'); ?> ", order, function(theResponse){ $(".update_feature_order_message p").html(theResponse).show(); $(".update_feature_order_message").show(); }); } }); }); })(jQuery); </script> <?php } }
public static function woo_variations_compare_feature_box($post_id) { $deactivate_compare_feature = get_post_meta($post_id, '_woo_deactivate_compare_feature', true); $compare_category = get_post_meta($post_id, '_woo_compare_category', true); ?> <br /> <input id='deactivate_compare_feature_<?php echo $post_id; ?> ' type='checkbox' value='no' <?php if ($deactivate_compare_feature == 'no') { echo 'checked="checked"'; } else { echo ''; } ?> class="deactivate_compare_feature" name='variable_woo_deactivate_compare_feature[<?php echo $post_id; ?> ]' style="float:none; width:auto; display:inline-block;" /> <label style="display:inline-block" for='deactivate_compare_feature_<?php echo $post_id; ?> ' class='small'><?php _e("Activate Compare Feature for this Product", 'woo_cp'); ?> </label> <div class="compare_feature_activate_form" style=" <?php if ($deactivate_compare_feature == 'yes') { echo 'display:none;'; } ?> "> <p><label style="display:inline-block" for='variable_woo_compare_category_<?php echo $post_id; ?> ' class='small'><?php _e("Select a Compare Category for this Product", 'woo_cp'); ?> </label> : <select name="variable_woo_compare_category[<?php echo $post_id; ?> ]" class="variable_compare_category" id="variable_woo_compare_category_<?php echo $post_id; ?> " style="width:200px;" rel="<?php echo $post_id; ?> "> <option value="0"><?php _e('Select...', 'woo_cp'); ?> </option> <?php $compare_cats = WC_Compare_Categories_Data::get_results('', 'category_order ASC'); if (is_array($compare_cats) && count($compare_cats) > 0) { foreach ($compare_cats as $cat_data) { if ($compare_category == $cat_data->id) { echo '<option selected="selected" value="' . $cat_data->id . '">' . stripslashes($cat_data->category_name) . '</option>'; } else { echo '<option value="' . $cat_data->id . '">' . stripslashes($cat_data->category_name) . '</option>'; } } } ?> </select> <img id="variable_compare_widget_loader_<?php echo $post_id; ?> " style="display:none;" src="<?php echo WOOCP_IMAGES_URL; ?> /ajax-loader.gif" border=0 /> </p> <div id="variable_compare_cat_fields_<?php echo $post_id; ?> "><?php WC_Compare_MetaBox::woo_variation_show_field_of_cat($post_id, $compare_category); ?> </div> </div> <?php }