public static function woocp_product_featured_tab_woo_2_0($tabs = array())
 {
     global $product, $post;
     global $woo_compare_product_page_tab;
     $compare_featured_tab = trim($woo_compare_product_page_tab['compare_featured_tab']);
     if ($compare_featured_tab == '') {
         $compare_featured_tab = __('Technical Details', 'woo_cp');
     }
     $show_compare_featured_tab = false;
     $product_id = $post->ID;
     $variations_list = WC_Compare_Functions::get_variations($product_id);
     if (is_array($variations_list) && count($variations_list) > 0) {
         foreach ($variations_list as $variation_id) {
             if (WC_Compare_Functions::check_product_activate_compare($variation_id) && WC_Compare_Functions::check_product_have_cat($variation_id)) {
                 $compare_category = get_post_meta($variation_id, '_woo_compare_category', true);
                 $compare_fields = WC_Compare_Categories_Fields_Data::get_results("cat_id='" . $compare_category . "'", 'cf.field_order ASC');
                 if (is_array($compare_fields) && count($compare_fields) > 0) {
                     $show_compare_featured_tab = true;
                     break;
                 }
             }
         }
     } elseif (WC_Compare_Functions::check_product_activate_compare($product_id) && WC_Compare_Functions::check_product_have_cat($product_id)) {
         $compare_category = get_post_meta($product_id, '_woo_compare_category', true);
         $compare_fields = WC_Compare_Categories_Fields_Data::get_results("cat_id='" . $compare_category . "'", 'cf.field_order ASC');
         if (is_array($compare_fields) && count($compare_fields) > 0) {
             $show_compare_featured_tab = true;
         }
     }
     if ($show_compare_featured_tab) {
         $tabs['compare-featured'] = array('title' => esc_attr(stripslashes($compare_featured_tab)), 'priority' => $woo_compare_product_page_tab['auto_compare_featured_tab'], 'callback' => array('WC_Compare_Hook_Filter', 'woocp_product_featured_panel_woo_2_0'));
     }
     return $tabs;
 }
</span></a>
                        <div style="clear:both;"></div>
                    	<div class="woo_compare_print_msg"><?php 
_e('Refine slections to 3 products and print!', 'woo_cp');
?>
</div>
                    </div>
                </div>
            	<div style="clear:both;"></div>
                <div class="popup_woo_compare_widget_loader" style="display:none;"><img src="<?php 
echo WOOCP_IMAGES_URL;
?>
/ajax-loader.gif" border=0 /></div>
                <div class="compare_popup_wrap">
                    <?php 
echo WC_Compare_Functions::get_compare_list_html_popup();
?>
                </div>
        </div>
        </div>
        <?php 
$woocp_compare_events = wp_create_nonce("woocp-compare-events");
?>
        <script type="text/javascript">
			jQuery(document).ready(function($) {
						var ajax_url = "<?php 
echo admin_url('admin-ajax.php');
?>
";
						$("#woo_compare_print").live("click", function(){
							$(".compare_print_container").printElement({
    public static function admin_screen()
    {
        ?>
	<style>
		.chzn-container{margin-right:2px;}
		.field_title{width:205px; padding:0 8px 0 10px; float:left;}
		.help_tip{cursor: help;line-height: 1;margin: -4px 0 0 5px;padding: 0;vertical-align: middle;}
		.compare_set_1{width:46%; float:left; margin-right:5%; margin-bottom:15px;}
		.compare_set_2{width:46%; float:left; margin-bottom:15px;}
		.ui-state-highlight{background:#F6F6F6; height:24px; padding:8px 0 0; border:1px dotted #DDD; margin-bottom:20px;}
		ul.compare_orders{float:left; margin:0; width:100%}
		ul.compare_orders li{padding-top:8px; border-top:1px solid #DFDFDF; margin:5px 0; line-height:20px;}
		ul.compare_orders li.first_record{border-top:none; padding-top:0;}
		ul.compare_orders .compare_sort{float:left; width:60px;}
		.c_field_name{padding-left:20px; background:url(<?php 
        echo WOOCP_IMAGES_URL;
        ?>
/icon_sort.png) no-repeat 0 center;}
		.c_openclose_table{cursor:pointer;}
		.c_openclose_none{width:16px; height:16px; display:inline-block;}
		.c_close_table{background:url(<?php 
        echo get_option('siteurl');
        ?>
/wp-admin/images/arrows.png) no-repeat center 0px; width:16px; height:16px; display:inline-block;}
		.c_open_table{background:url(<?php 
        echo get_option('siteurl');
        ?>
/wp-admin/images/arrows.png) no-repeat center -35px; width:16px; height:16px; display:inline-block;}
		ul.compare_orders .c_field_type{width:120px; float:left;}
		ul.compare_orders .c_field_manager{background:url(<?php 
        echo WOOCP_IMAGES_URL;
        ?>
/icon_fields.png) no-repeat 0 0; width:16px; height:16px; display:inline-block;}
		.tablenav-pages{float:right;}
		.c_field_edit, .c_field_delete{cursor:pointer;}
		.widefat th input {
			vertical-align:middle;
			padding:3px 8px;
			margin:auto;
		}
		.widefat th, .widefat td {
			overflow: inherit !important;	
		}
		.chzn-container-multi .chzn-choices {
			min-height:100px;	
		}

		ul.feature_compare_orders .compare_sort{margin-right:10px; float:none; width:auto;}
		ul.feature_compare_orders .c_field_name{margin-right:10px;padding:5px 0 5px 20px; float:none; width:auto;}
		ul.feature_compare_orders .c_field_action{float:right;}
		ul.feature_compare_orders .c_field_type{float:right; margin-right:10px; width:70px;}
		
		.icon32-compare-product {
			background:url(<?php 
        echo WOOCP_IMAGES_URL;
        ?>
/a3-plugins.png) no-repeat left top !important;
		}
		@media screen and ( max-width: 782px ) {
			.a3rev_manager_panel_container table {
				width:100% !important;	
			}
			.a3rev_manager_panel_container td.search_features_td {
				text-align:left !important;	
			}
		}
	</style>
	<script>
		(function($){
			$(function(){
				$("#field_type").change( function() {
					var field_type = $(this).val();
					if(field_type == 'checkbox' || field_type == 'radio' || field_type == 'drop-down' || field_type == 'multi-select'){
						$("#field_value").slideDown();
					}else{
						$("#field_value").slideUp();
					}
				});
				$('#toggle1').click(function(){
					if($('#toggle1').is(':checked')){
						$(".list_fields").attr("checked", "checked");
						$(".toggle2").attr("checked", "checked");
					}else{
						$(".list_fields").removeAttr("checked");
						$(".toggle2").removeAttr("checked");
					}
				});
				$('#toggle2').click(function(){
					if($('#toggle2').is(':checked')){
						$(".list_fields").attr("checked", "checked");
						$(".toggle1").attr("checked", "checked");
					}else{
						$(".list_fields").removeAttr("checked");
						$(".toggle1").removeAttr("checked");
					}
				});
			});
		})(jQuery);
		function confirmation(text) {
			var answer = confirm(text)
			if (answer){
				return true;
			}else{
				return false;
			}
		}		
	</script>
        <div id="htmlForm">
        <div style="clear:both"></div>
		<div class="wrap a3rev_panel_container a3rev_manager_panel_container">
        <div id="a3_plugin_panel_container"><div id="a3_plugin_panel_fields">
        <?php 
        echo WC_Compare_Fields_Class::init_features_actions();
        echo WC_Compare_Categories_Class::init_categories_actions();
        ?>
		<?php 
        if (isset($_REQUEST['act']) && $_REQUEST['act'] == 'add-new') {
            WC_Compare_Categories_Class::woocp_categories_manager();
            WC_Compare_Fields_Class::woocp_features_manager();
        } else {
            if (isset($_REQUEST['act']) && $_REQUEST['act'] == 'cat-edit') {
                WC_Compare_Categories_Class::woocp_categories_manager();
            } else {
                if (isset($_REQUEST['act']) && $_REQUEST['act'] == 'field-edit') {
                    WC_Compare_Fields_Class::woocp_features_manager();
                } else {
                    if (isset($_REQUEST['s_feature'])) {
                        WC_Compare_Fields_Class::features_search_area();
                    } else {
                        WC_Compare_Fields_Class::features_search_area();
                        WC_Compare_Fields_Class::woocp_features_orders();
                    }
                }
            }
        }
        ?>
        </div><div id="a3_plugin_panel_upgrade_area"><div id="a3_plugin_panel_extensions"><?php 
        echo WC_Compare_Functions::plugin_pro_notice();
        ?>
</div></div></div>
        </div>
        </div>
		<?php 
    }
Exemple #4
0
function woo_cp_lite_upgrade_plugin()
{
    // Upgrade to 2.0.0
    if (version_compare(get_option('a3rev_woocp_pro_version'), '2.0.0') === -1) {
        include WOOCP_DIR . '/includes/updates/compare-update-2.0.0.php';
        update_option('a3rev_woocp_pro_version', '2.0.0');
    }
    // Upgrade to 2.0.1
    if (version_compare(get_option('a3rev_woocp_pro_version'), '2.0.1') === -1) {
        include WOOCP_DIR . '/includes/updates/compare-update-2.0.1.php';
        update_option('a3rev_woocp_pro_version', '2.0.1');
    }
    // Upgrade to 2.0.6
    if (version_compare(get_option('a3rev_woocp_pro_version'), '2.0.6') === -1) {
        include WOOCP_DIR . '/includes/updates/compare-update-2.0.6.php';
        update_option('a3rev_woocp_pro_version', '2.0.6');
    }
    // Upgrade to 2.1.0
    if (version_compare(get_option('a3rev_woocp_pro_version'), '2.1.0') === -1) {
        include WOOCP_DIR . '/includes/updates/compare-update-2.1.0.php';
        update_option('a3rev_woocp_pro_version', '2.1.0');
    }
    // Upgrade to 2.1.8
    if (version_compare(get_option('a3rev_woocp_pro_version'), '2.1.8') === -1) {
        include WOOCP_DIR . '/includes/updates/compare-update-2.1.8.php';
        WC_Compare_Functions::lite_upgrade_version_2_1_8();
        update_option('a3rev_woocp_pro_version', '2.1.8');
        update_option('a3rev_woocp_lite_version', '2.1.8');
    }
    // Upgrade to 2.1.9.3
    if (version_compare(get_option('a3rev_woocp_lite_version'), '2.1.9.3') === -1) {
        include WOOCP_DIR . '/includes/updates/compare-update-2.1.9.3.php';
        update_option('a3rev_woocp_lite_version', '2.1.9.3');
    }
    // Upgrade to 2.2.0
    if (version_compare(get_option('a3rev_woocp_lite_version'), '2.2.0') === -1) {
        // Build sass
        global $wc_compare_less;
        $wc_compare_less->plugin_build_sass();
        update_option('a3rev_woocp_lite_version', '2.2.0');
    }
    update_option('a3rev_woocp_pro_version', '2.4.1');
    update_option('a3rev_woocp_lite_version', '2.2.0');
}
    public static function features_search_area()
    {
        global $wpdb;
        ?>
    	<div class="icon32 icon32-compare-product" id="icon32-compare-product"><br></div>
        <h2><?php 
        _e('Categories & Features', 'woo_cp');
        ?>
 <a href="admin.php?page=woo-compare-features&act=add-new" class="add-new-h2"><?php 
        _e('Add New', 'woo_cp');
        ?>
</a></h2>
        <div style="clear:both;height:12px"></div>
        <form method="get" action="admin.php?page=woo-compare-features" name="compare_search_features">
            <input type="hidden" name="page" value="woo-compare-features"  />
            <input type="hidden" name="tab" value="features"  />
        <?php 
        $s_feature = '';
        if (isset($_REQUEST['s_feature']) && trim($_REQUEST['s_feature']) != '') {
            $s_feature = trim(stripslashes($_REQUEST['s_feature']));
        }
        ?>
        	<table class="form-table" style="width:535px;">
                <tbody>
                	<tr valign="top">
                    	<th class="titledesc" scope="rpw" style="padding-left:0;"><input type="text" name="s_feature" id="s_feature" value="<?php 
        echo $s_feature;
        ?>
" style="min-width:300px" /></th>
                        <td class="forminp search_features_td" style="padding-right:0; text-align:right;"><input type="submit" id="search_features" name="" value="<?php 
        _e('Search Features', 'woo_cp');
        ?>
" class="button"></td>
                    </tr>
                </tbody>
            </table>
        <?php 
        if (isset($_REQUEST['s_feature'])) {
            $p = 1;
            $rows = 25;
            if (isset($_REQUEST['pp'])) {
                $p = $_REQUEST['pp'];
            }
            if (isset($_REQUEST['rows'])) {
                $rows = $_REQUEST['rows'];
            }
            $start = ($p - 1) * $rows;
            $end = $start + $rows;
            $div = 5;
            $keyword = trim(stripslashes($_REQUEST['s_feature']));
            $link = add_query_arg(array('pp' => '', 'rows' => $rows, 's_feature' => $keyword));
            $character = 'latin1';
            if ($wpdb->has_cap('collation')) {
                if (!empty($wpdb->charset)) {
                    $character = "{$wpdb->charset}";
                }
            }
            $where = "LOWER( CONVERT( field_name USING " . $character . ") ) LIKE '%" . strtolower(trim($_REQUEST['s_feature'])) . "%'";
            $total = WC_Compare_Data::get_count($where);
            if ($end > $total) {
                $end = $total;
            }
            $items = WC_Compare_Data::get_results($where, 'field_name ASC', $start . ',' . $rows);
            $innerPage = WC_Compare_Functions::printPage($link, $total, $p, $div, $rows, false);
            ?>
            <h3><?php 
            _e('Found', 'woo_cp');
            ?>
 <?php 
            echo $total;
            ?>
 <?php 
            _e('feature(s)', 'woo_cp');
            ?>
</h3>
            <?php 
            if ($total > 0) {
                ?>
        	<table cellspacing="0" class="widefat post fixed" style="width:535px;">
            	<thead>
                	<tr>
                        <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 ($items as $field_data) {
                    ?>
                	<tr>
                        <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>
                <tfoot>
					<tr>
						<th class="manage-column column-title" colspan="3" style="padding:2px 7px">
                    		<div class="tablenav">
                                <span class="search_item_title"><?php 
                _e('Show', 'woo_cp');
                ?>
:</span>
                                <select name="rows" class="number_items">
                            <?php 
                $number_items_array = array('15' => '15', '25' => '25', '50' => '50', '75' => '75', '100' => '100', '200' => '200', '1000000' => 'All');
                foreach ($number_items_array as $key => $value) {
                    if ($key == $rows) {
                        echo "<option selected='selected' value='{$key}'>{$value}</option>";
                    } else {
                        echo "<option value='{$key}'>{$value}</option>";
                    }
                }
                ?>
                                </select>
                                <input type="submit" class="button" value="<?php 
                _e('Go', 'woo_cp');
                ?>
" name="" id="search_items" />
                                <div class="tablenav-pages"><span class="displaying-num"><?php 
                _e('Displaying', 'woo_cp');
                ?>
 <?php 
                echo $start + 1;
                ?>
 - <?php 
                echo $end;
                ?>
 <?php 
                _e('of', 'woo_cp');
                ?>
 <?php 
                echo $total;
                ?>
</span><?php 
                echo $innerPage;
                ?>
</div>
                            </div>
						</th>
					</tr>
				</tfoot>
            </table>
            <?php 
            }
        }
        ?>
        </form>
    <?php 
    }
    /**
     * Edit Compare Feature field.
     *
     * @access public
     * @param mixed $term Term (category) being edited
     * @param mixed $taxonomy Taxonomy of the term being edited
     */
    public function edit_feature_fields($term_id)
    {
        ob_start();
        ?>
        <div class="a3rev_panel_container">
        	<div class="a3_wc_compare_plugin_meta_upgrade_area_box">
        	<?php 
        global $wc_compare_admin_init;
        $wc_compare_admin_init->upgrade_top_message(true);
        ?>
            <h3><?php 
        _e('Attribute Comparison Data', 'woo_cp');
        ?>
</h3>
            <input type="hidden" name="have_compare_feature_field" value="yes"  />
            <table class="form-table">
                <tbody>
                	<tr class="form-field">
                        <th scope="row" valign="top">
                        <div class="help_tip a3-plugin-ui-icon a3-plugin-ui-help-icon" data-tip="<?php 
        _e("Attribute can be assigned to any Product Category that is activated for Product Comparisons. Attributes show on the comparison table as the Comparable Product Attributes.", 'woo_cp');
        ?>
"></div>
                        <label for="field_type"><?php 
        _e('Select Categories', 'woo_cp');
        ?>
</label> 
                        </th>
                        <td>
                            <?php 
        $compare_cats = WC_Compare_Functions::get_all_compare_cats();
        ?>
							<select multiple="multiple" name="field_cats[]" data-placeholder="<?php 
        _e('Select Compare Categories', 'woo_cp');
        ?>
" style="width:95%;" class="chzn-select">
							<?php 
        if (is_array($compare_cats) && count($compare_cats) > 0) {
            foreach ($compare_cats as $cat) {
                ?>
									<option value="<?php 
                echo $cat->term_id;
                ?>
"><?php 
                echo esc_html($cat->name);
                ?>
</option>
								<?php 
            }
        }
        ?>
							</select>
                        </td>
                    </tr>
                    <tr class="form-field">
                        <th scope="row" valign="top">
                        <div class="help_tip a3-plugin-ui-icon a3-plugin-ui-help-icon" data-tip="<?php 
        _e("Use these fields to determine how this Attribute with display its compare data. Text input fields are for adding custom compare data and ignore the Attribute Terms or set to show the Attributes Terms as single or multi select Compare data options that are quick and easy to set for each product.", 'woo_cp');
        ?>
"></div>
                        <label for="field_type"><?php 
        _e('Attribute and Terms Compare data Input type', 'woo_cp');
        ?>
</label> 
                        </th>
                        <td>
                            <select name="field_type" id="field_type" class="chzn-select" style="width:95%">
							<?php 
        foreach ($this->default_types as $type => $type_name) {
            ?>
                            	<option value="<?php 
            echo $type;
            ?>
"><?php 
            echo $type_name['name'] . ' - ' . $type_name['description'];
            ?>
</option>
                            <?php 
        }
        ?>
                            </select>
                        </td>
                    </tr>
                    <tr class="form-field">
                        <th scope="row" valign="top">
                        <div class="help_tip a3-plugin-ui-icon a3-plugin-ui-help-icon" data-tip="<?php 
        _e("e.g kgs, mm, lbs, cm, inches - the unit of measurement shows after the Attribute name in (brackets). If you leave this blank you will just see the Attribute name.", 'woo_cp');
        ?>
"></div>
                        <label for="field_unit"><?php 
        _e('Attribute Unit of Measurement', 'woo_cp');
        ?>
</label> 
                        </th>
                        <td>
                            <input type="text" name="field_unit" id="field_unit" value="" />
                        </td>
                    </tr>
                </tbody>
            </table>
        	</div>
        </div>
		<?php 
        $ouput = ob_get_clean();
        $ouput = addslashes(str_replace(array("\r\n", "\r", "\n"), "", $ouput));
        return $ouput;
    }
 /**
  * Get compare list on popup
  */
 public static function get_compare_list_html_popup()
 {
     global $woo_compare_comparison_page_global_settings, $woo_compare_page_style, $woo_compare_table_style, $woo_compare_table_content_style, $woo_compare_addtocart_style, $woo_compare_viewcart_style;
     global $woo_compare_product_prices_style;
     $current_db_version = get_option('woocommerce_db_version', null);
     $compare_list = WC_Compare_Functions::get_compare_list();
     $woo_compare_basket_icon = get_option('woo_compare_basket_icon');
     if (trim($woo_compare_basket_icon) == '') {
         $woo_compare_basket_icon = WOOCP_IMAGES_URL . '/compare_remove.png';
     }
     $html = '';
     $product_cats = array();
     $products_fields = array();
     $products_prices = array();
     $custom_class = '';
     $add_to_cart_text = $woo_compare_addtocart_style['addtocart_link_text'];
     $add_to_cart_button_class = 'add_to_cart_link_type';
     if (is_array($compare_list) && count($compare_list) > 0) {
         $html .= '<div id="compare-wrapper"><div class="compare-products">';
         $html .= '<table id="product_comparison" class="compare_popup_table" border="1" bordercolor="' . $woo_compare_table_style['table_border_colour'] . '" cellpadding="5" cellspacing="0" width="">';
         $html .= '<tbody><tr class="row_1 row_product_detail"><th class="column_first first_row"><div class="column_first_wide">&nbsp;';
         $html .= '</div></th>';
         $i = 0;
         foreach ($compare_list as $product_id) {
             $product_cat = get_post_meta($product_id, '_woo_compare_category', true);
             $products_fields[$product_id] = WC_Compare_Categories_Fields_Data::get_fieldid_results($product_cat);
             if ($product_cat > 0) {
                 $product_cats[] = $product_cat;
             }
             $i++;
             if (version_compare($current_db_version, '2.0', '<') && null !== $current_db_version) {
                 $current_product = new WC_Product($product_id);
             } elseif (version_compare(WC()->version, '2.2.0', '<')) {
                 $current_product = get_product($product_id);
             } else {
                 $current_product = wc_get_product($product_id);
             }
             $product_name = WC_Compare_Functions::get_variation_name($product_id);
             $product_price = $current_product->get_price_html();
             /**
              * Add code check show or hide price and add to cart button support for Woo Catalog Visibility Options plugin
              */
             $show_add_to_cart = true;
             if (class_exists('WC_CVO_Visibility_Options')) {
                 global $wc_cvo;
                 /**
                  * Check show or hide price
                  */
                 if ($wc_cvo->setting('wc_cvo_prices') == 'secured' && !catalog_visibility_user_has_access() || $wc_cvo->setting('wc_cvo_prices') == 'disabled') {
                     $product_price = '';
                 }
                 /**
                  * Check show or hide add to cart button
                  */
                 if ($wc_cvo->setting('wc_cvo_atc') == 'secured' && !catalog_visibility_user_has_access() || $wc_cvo->setting('wc_cvo_atc') == 'disabled') {
                     $show_add_to_cart = false;
                 }
             }
             $products_prices[$product_id] = $product_price;
             $image_src = WC_Compare_Functions::get_post_thumbnail($product_id, 220, 180);
             if (trim($image_src) == '') {
                 $image_src = '<img alt="' . $product_name . '" src="' . (version_compare($current_db_version, '2.1.0', '<') && null !== $current_db_version ? woocommerce_placeholder_img_src() : wc_placeholder_img_src()) . '" />';
             }
             $html .= '<td class="first_row column_' . $i . '"><div class="td-spacer"><div class="woo_compare_popup_remove_product_container"><a class="woo_compare_popup_remove_product" rel="' . $product_id . '" style="cursor:pointer;">Remove <img src="' . $woo_compare_basket_icon . '" border=0 /></a></div>';
             $html .= '<div class="compare_image_container">' . $image_src . '</div>';
             $html .= '<div class="compare_product_name">' . $product_name . '</div>';
             $html .= '<div class="compare_price">' . $products_prices[$product_id] . '</div>';
             if ($show_add_to_cart && $current_product->is_in_stock() && trim($products_prices[$product_id]) != '') {
                 if ($current_product->product_type != 'external') {
                     $cart_url = add_query_arg('add-to-cart', $product_id, get_option('siteurl') . '/?post_type=product');
                 } else {
                     if ($current_product->product_type == 'external') {
                         if (version_compare($current_db_version, '2.0', '<') && null !== $current_db_version) {
                             $cart_url = get_post_meta($product_id, '_product_url', true);
                             $add_to_cart_text_external = get_post_meta($product_id, '_button_text', true);
                             $add_to_cart_text_external ? $add_to_cart_text_external : __('Buy product', 'woo_cp');
                         } else {
                             $cart_url = $current_product->product_url;
                             $add_to_cart_text_external = $current_product->get_button_text();
                         }
                     }
                 }
                 switch (get_post_type($product_id)) {
                     case "product_variation":
                         $class = 'is_variation';
                         $cart_url = WC_Compare_Functions::get_product_url($product_id);
                         break;
                     default:
                         $class = 'simple';
                         break;
                 }
                 $html .= '<div class="compare_add_cart">';
                 if ($current_product->product_type == 'external') {
                     $html .= sprintf('<a href="%s" rel="nofollow" class="button add_to_cart_button %s product_type_%s %s" target="_blank">%s</a>', $cart_url, $add_to_cart_button_class, $class, $custom_class, $add_to_cart_text_external);
                 } else {
                     $html .= sprintf('<a href="%s" data-product_id="%s" class="button add_to_cart_button %s product_type_%s %s" target="_blank">%s</a>', $cart_url, $product_id, $add_to_cart_button_class, $class, $custom_class, $add_to_cart_text);
                 }
                 $html .= '<a class="virtual_added_to_cart" href="#">&nbsp;</a>';
                 $html .= '</div>';
             }
             $html .= '</div></td>';
         }
         $html .= '</tr>';
         $product_cats = implode(",", $product_cats);
         $compare_fields = WC_Compare_Categories_Fields_Data::get_results('cat_id IN(' . $product_cats . ')', 'cf.cat_id ASC, cf.field_order ASC');
         if (is_array($compare_fields) && count($compare_fields) > 0) {
             $j = 1;
             foreach ($compare_fields as $field_data) {
                 $j++;
                 $html .= '<tr class="row_' . $j . '">';
                 if (trim($field_data->field_unit) != '') {
                     $html .= '<th class="column_first"><div class="compare_value">' . stripslashes($field_data->field_name) . ' (' . trim(stripslashes($field_data->field_unit)) . ')</div></th>';
                 } else {
                     $html .= '<th class="column_first"><div class="compare_value">' . stripslashes($field_data->field_name) . '</div></th>';
                 }
                 $i = 0;
                 foreach ($compare_list as $product_id) {
                     $i++;
                     $empty_cell_class = '';
                     $empty_text_class = '';
                     if (in_array($field_data->id, $products_fields[$product_id])) {
                         $field_value = get_post_meta($product_id, '_woo_compare_' . $field_data->field_key, true);
                         if (is_serialized($field_value)) {
                             $field_value = maybe_unserialize($field_value);
                         }
                         if (is_array($field_value) && count($field_value) > 0) {
                             $field_value = implode(', ', $field_value);
                         } elseif (is_array($field_value) && count($field_value) < 0) {
                             $field_value = $woo_compare_table_content_style['empty_text'];
                         }
                         if (trim($field_value) == '') {
                             $field_value = $woo_compare_table_content_style['empty_text'];
                         }
                     } else {
                         $field_value = $woo_compare_table_content_style['empty_text'];
                     }
                     if ($field_value == $woo_compare_table_content_style['empty_text']) {
                         $empty_cell_class = 'empty_cell';
                         $empty_text_class = 'empty_text';
                     }
                     $html .= '<td class="column_' . $i . ' ' . $empty_cell_class . '"><div class="td-spacer ' . $empty_text_class . ' compare_' . $field_data->field_key . '">' . $field_value . '</div></td>';
                 }
                 $html .= '</tr>';
                 if ($j == 2) {
                     $j = 0;
                 }
             }
             $j++;
             if ($j > 2) {
                 $j = 1;
             }
             $html .= '<tr class="row_' . $j . ' row_end"><th class="column_first">&nbsp;</th>';
             $i = 0;
             foreach ($compare_list as $product_id) {
                 $i++;
                 $html .= '<td class="column_' . $i . '">';
                 $html .= '<div class="td-spacer compare_price">' . $products_prices[$product_id] . '</div>';
                 $html .= '</td>';
             }
         }
         $html .= '</tbody></table>';
         $html .= '</div></div>';
     } else {
         $html .= '<div class="no_compare_list">' . $woo_compare_page_style['no_product_message_text'] . '</div>';
     }
     return $html;
 }
<?php

if (!defined('ABSPATH')) {
    exit;
}
// Exit if accessed directly
WC_Compare_Functions::create_page(esc_sql('product-comparison'), '', __('Product Comparison', 'woo_cp'), '[product_comparison_page]');
    public static function woocp_products_manager()
    {
        $compare_product_message = '';
        $paged = isset($_POST['paged']) ? $_POST['paged'] : 1;
        $rp = isset($_POST['rp']) ? $_POST['rp'] : 10;
        $cp_show_variations = isset($_POST['cp_show_variations']) ? $_POST['cp_show_variations'] : 0;
        $sortname = isset($_POST['sortname']) ? $_POST['sortname'] : 'title';
        $sortorder = isset($_POST['sortorder']) ? $_POST['sortorder'] : 'asc';
        $query = isset($_POST['query']) ? $_POST['query'] : '';
        $qtype = isset($_POST['qtype']) ? $_POST['qtype'] : '';
        if (isset($_REQUEST['bt_update_product_features'])) {
            if (isset($_REQUEST['productid']) && $_REQUEST['productid'] > 0) {
                $post_id = $_REQUEST['productid'];
                $post_status = get_post_status($post_id);
                $post_type = get_post_type($post_id);
                if (($post_type == 'product' || $post_type == 'product_variation') && $post_status != false) {
                    if (isset($_REQUEST['_woo_deactivate_compare_feature']) && $_REQUEST['_woo_deactivate_compare_feature'] == 'no') {
                        update_post_meta($post_id, '_woo_deactivate_compare_feature', 'no');
                    } else {
                        update_post_meta($post_id, '_woo_deactivate_compare_feature', 'yes');
                    }
                    $compare_category = $_REQUEST['_woo_compare_category'];
                    update_post_meta($post_id, '_woo_compare_category', $compare_category);
                    if ($compare_category > 0) {
                        $category_data = WC_Compare_Categories_Data::get_row($compare_category);
                        if ($category_data != NULL) {
                            update_post_meta($post_id, '_woo_compare_category_name', stripslashes($category_data->category_name));
                        }
                        $compare_fields = WC_Compare_Categories_Fields_Data::get_results("cat_id='" . $compare_category . "'", 'cf.field_order ASC');
                        if (is_array($compare_fields) && count($compare_fields) > 0) {
                            foreach ($compare_fields as $field_data) {
                                if (isset($_REQUEST['_woo_compare_' . $field_data->field_key])) {
                                    update_post_meta($post_id, '_woo_compare_' . $field_data->field_key, $_REQUEST['_woo_compare_' . $field_data->field_key]);
                                }
                            }
                        }
                    } else {
                        update_post_meta($post_id, '_woo_compare_category_name', '');
                    }
                }
                $compare_product_message = '<div class="updated" id="result_msg"><p>' . __('Compare Product Feature Fields Successfully updated.', 'woo_cp') . '.</p></div>';
            }
        }
        ?>
<style>
	.update_message{padding:10px; background-color:#FFFFCC;border:1px solid #DDDDDD;margin-bottom:15px;}
	body .flexigrid div.sDiv{display:block;}
	.flexigrid div.sDiv .sDiv2 select{display:none;}
	.flexigrid div.sDiv .cp_search, .flexigrid div.sDiv .cp_reset{cursor:pointer;}
	.edit_product_compare{cursor:pointer; text-decoration:underline; color:#06F;}
	.icon32-compare-product {
		background:url(<?php 
        echo WOOCP_IMAGES_URL;
        ?>
/a3-plugins.png) no-repeat left top !important;
	}
	.pro_feature_fields {
		padding:0 10px 10px 10px;	
	}
</style>
<div id="htmlForm">
<div style="clear:both"></div>
<div class="wrap a3rev_panel_container a3rev_manager_panel_container">
	<div id="a3_plugin_panel_container"><div id="a3_plugin_panel_fields">
	<div class="icon32 icon32-compare-product" id="icon32-compare-product"><br></div>
	<h2><?php 
        _e('WooCommerce Compare Products Manager', 'woo_cp');
        ?>
</h2>
    <?php 
        echo $compare_product_message;
        ?>
    <div style="clear:both; margin-bottom:20px;"></div>
    <div class="pro_feature_fields">
    <?php 
        global $wc_compare_admin_init;
        $wc_compare_admin_init->upgrade_top_message(true);
        ?>
    <table id="woocp_products_manager" style="display:none"></table>
    </div>
    <?php 
        $woocp_products_manager = wp_create_nonce("woocp-products-manager");
        ?>
    <script type="text/javascript">
		function alert_upgrade(text) {
			var answer = confirm(text)
			if (answer){
				window.open("<?php 
        echo WOOCP_AUTHOR_URI;
        ?>
", '_blank')
			}else{
				return false;
			}
		}
	(function($){
		$(function(){
			$("#woocp_products_manager").flexigrid({
				url: '<?php 
        echo admin_url('admin-ajax.php', 'relative') . '?action=woocp_get_products&security=' . $woocp_products_manager;
        ?>
',
				dataType: 'json',
				width: 'auto',
				resizable: false,
				colModel : [
					{display: '<?php 
        _e("No", 'woo_cp');
        ?>
', name : 'number', width : 20, sortable : false, align: 'right'},
					{display: '<?php 
        _e("Product Name", 'woo_cp');
        ?>
', name : 'title', width : 200, sortable : true, align: 'left'},
					{display: '<?php 
        _e("Product Category", 'woo_cp');
        ?>
', name : 'cat', width : 110, sortable : false, align: 'left'},
					{display: '<?php 
        _e("Compare Category", 'woo_cp');
        ?>
', name : '_woo_compare_category_name', width : 110, sortable : true, align: 'left'},
					{display: '<?php 
        _e("Activated / Deactivated", 'woo_cp');
        ?>
', name : '_woo_deactivate_compare_feature', width : 110, sortable : false, align: 'center'},
					{display: '<?php 
        _e("Edit", 'woo_cp');
        ?>
', name : 'edit', width : 30, sortable : false, align: 'center'}
					],
				searchitems : [
					{display: '<?php 
        _e("Product Name", 'woo_cp');
        ?>
', name : 'title', isdefault: true}
					],
				sortname: "title",
				sortorder: "asc",
				usepager: true,
				title: '<?php 
        _e("Products", 'woo_cp');
        ?>
',
				findtext: '<?php 
        _e("Find Product Name", 'woo_cp');
        ?>
',
				useRp: true,
				rp: <?php 
        echo $rp;
        ?>
, //results per page
				newp: <?php 
        echo $paged;
        ?>
,
				page: <?php 
        echo $paged;
        ?>
,
				query: '<?php 
        echo $query;
        ?>
',
				qtype: '<?php 
        echo $qtype;
        ?>
',
				sortname: '<?php 
        echo $sortname;
        ?>
',
				sortorder: '<?php 
        echo $sortorder;
        ?>
',
				rpOptions: [10, 15, 20, 30, 50, 100], //allowed per-page values
				showToggleBtn: false, //show or hide column toggle popup
				showTableToggleBtn: false,
				height: 'auto',
				variations: '<?php 
        echo $cp_show_variations;
        ?>
'
			});
			$(document).on("click", ".edit_product_compare", function(ev){
				return alert_upgrade('<?php 
        _e('Please upgrade to the Pro Version to activate Products express Compare feature manager', 'woo_cp');
        ?>
');
			});
		});
	})(jQuery);
	</script>
</div><div id="a3_plugin_panel_upgrade_area"><div id="a3_plugin_panel_extensions"><?php 
        echo WC_Compare_Functions::plugin_pro_notice();
        ?>
</div></div></div>
</div>
</div>
<?php 
    }