$val){
if (($key != "All countries") && ($key != "Custom Feed")){
array_push ($channel_countries, $key);
}
}
return $channel_countries;
}
public function get_channels($country){
$channels = array();
$channel_configs = get_option ('channel_statics');
// Lets get the generic channels
foreach ($channel_configs as $key=>$val){
if($key == "Custom Feed" || $key == "All countries"){
$channels = array_merge ($channels, $val);
}
}
// Than get the relevant country channels
foreach ($channel_configs as $key=>$val){
if(preg_match("/-$country/i", $key)){
$channels = array_merge($channels, $val);
} elseif ($country == "$key"){
$channels = array_merge($channels, $val);
}
}
return $channels;
}
private function get_dynamic_attributes(){
global $wpdb;
$list = array();
$no_taxonomies = array("portfolio_category","portfolio_skills","portfolio_tags","nav_menu","post_format","slide-page","element_category","template_category","portfolio_category","portfolio_skills","portfolio_tags","faq_category","slide-page","category","post_tag","nav_menu","link_category","post_format","product_type","product_visibility","product_cat","product_shipping_class","product_tag");
$taxonomies = get_taxonomies();
$diff_taxonomies = array_diff($taxonomies, $no_taxonomies);
# get custom taxonomy values for a product
foreach($diff_taxonomies as $tax_diff){
$taxonomy_details = get_taxonomy( $tax_diff );
foreach($taxonomy_details as $kk => $vv){
if($kk == "name"){
$pa_short = $vv;
}
if($kk == "labels"){
foreach($vv as $kw => $kv){
if($kw == "singular_name"){
$attr_name = $pa_short;
$attr_name_clean = ucfirst($kv);
}
}
}
}
$list["$attr_name"] = $attr_name_clean;
}
return $list;
}
private function get_custom_attributes() {
global $wpdb;
$list = array();
if ( ! function_exists( 'woosea_get_meta_keys_for_post_type' ) ) :
function woosea_get_meta_keys_for_post_type( $post_type, $sample_size = 'modified' ) {
$meta_keys = array();
$add_woosea_basic = get_option ('add_woosea_basic');
if($add_woosea_basic == "yes"){
$posts = get_posts( array( 'post_type' => $post_type, 'limit' => $sample_size ) );
} else {
$posts = get_posts( array( 'post_type' => $post_type, 'numberposts' => -1 ) );
}
foreach ( $posts as $post ) {
$post_meta_keys = get_post_custom_keys( $post->ID );
if(empty($post_meta_keys)){
$post_meta_keys = array();
}
$meta_keys = array_merge( $meta_keys, $post_meta_keys );
}
// Use array_unique to remove duplicate meta_keys that we received from all posts
// Use array_values to reset the index of the array
return array_values( array_unique( $meta_keys ) );
}
endif;
$post_type = "product";
$data = woosea_get_meta_keys_for_post_type($post_type);
if (count($data)) {
foreach ($data as $key => $value) {
if (!preg_match("/_product_attributes/i",$value)){
$value_display = str_replace("_", " ",$value);
$list["custom_attributes_" . $value] = ucfirst($value_display);
} else {
$data = @$wpdb->get_results(
// $wpdb->prepare("
// SELECT
// meta.meta_id,
// meta.meta_value AS type
// FROM {$wpdb->prefix}postmeta AS meta,
// {$wpdb->prefix}posts AS posts
// WHERE meta.post_id = posts.id
// AND posts.post_type LIKE '%product%'
// AND meta.meta_key='_product_attributes' AND meta.meta_value NOT LIKE \"%{}\";")
$wpdb->prepare("
SELECT
meta.meta_id,
meta.meta_value AS type
FROM {$wpdb->prefix}postmeta AS meta,
{$wpdb->prefix}posts AS posts
WHERE meta.post_id = posts.id
AND posts.post_type LIKE '%s'
AND meta.meta_key='_product_attributes' AND meta.meta_value NOT LIKE \"%{}\"", array( '%product%' ))
);
if (count($data)) {
foreach ($data as $key => $value) {
$product_attr = unserialize($value->type);
if(!empty($product_attr)){
foreach ($product_attr as $key => $arr_value) {
$value_display = str_replace("_", " ",$arr_value['name']);
$list["custom_attributes_" . $key] = ucfirst($value_display);
}
}
}
}
}
}
return $list;
}
return false;
}
public function get_mapping_attributes_dropdown() {
$sitename = get_option('blogname');
$mapping_attributes = array(
"categories" => "Category",
"title" => "Product name",
);
/**
* Create dropdown with main attributes
*/
$dropdown = "";
$dropdown .= "";
$other_attributes = array(
"all_products" => "Map all products",
);
$dropdown .= "