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 }
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 }