<?php
global $ashu_option;

if(is_home()){
	$keywords = $ashu_option['general']['home_keyword']; //首页描述信息
	$description = $ashu_option['general']['home_desc'];//首页关键词
}elseif(is_single() || is_page() ){
	$description = get_post_meta($post->ID,'_seo_description',true);
	$keywords = get_post_meta($post->ID,'_seo_keywords',true); //获取自定义关键词
	
	if($keywords == ''){
		$aaa=wp_get_post_tags($post->ID);
		$key_arry = array();
		foreach($aaa as $bbb)
		$key_arry[] = $bbb->name;

		$keywords = implode(',',$key_arry);
	}
	
	if($keywords == ''){
		$keywords = $ashu_option['general']['home_keyword'];
	}
	if($description == ''){
		$description = str_replace("\n","",strip_tags($post->post_content));
		$description = str_replace("\r","",$description);
		$description = str_replace("\t","",$description);
		$description = mb_substr( $description,0,100,'UTF-8');
	}
}elseif( is_tax('mall') ){
	$currentterm = get_queried_object();
	$description = get_term_meta($currentterm->term_id , '_seo_description',true);
	$keywords = get_term_meta($currentterm->term_id , '_seo_keywords',true);
	
	if($description == ''){
		$description = str_replace("\n","",strip_tags(term_description()));
	$description = str_replace("\r","",$description);
	$description = str_replace("\t","",$description);
	$description = mb_substr( $description,0,100,'UTF-8');
	}
	
	if($description == ''){
		$description = $ashu_option['general']['home_desc']; //首页描述信息
	}
	if($keywords == ''){
		$keywords = $ashu_option['general']['home_keyword'];//首页关键词
	}
}elseif( is_tax('shop')){
	$currentterm = get_queried_object();
	$description = get_term_meta($currentterm->term_id , '_seo_description',true);
	$keywords = get_term_meta($currentterm->term_id , '_seo_keywords',true);
	
	if($description == ''){
		$description = str_replace("\n","",strip_tags(term_description()));
	$description = str_replace("\r","",$description);
	$description = str_replace("\t","",$description);
	$description = mb_substr( $description,0,100,'UTF-8');
	}
	
	if($description == ''){
		$description = $ashu_option['general']['home_desc']; //首页描述信息
	}
	if($keywords == ''){
		$keywords = $ashu_option['general']['home_keyword'];//首页关键词
	}
}elseif( is_tax('detail_tag') ){
	$currentterm = get_queried_object();
	$description = get_term_meta($currentterm->term_id , '_seo_description',true);
	$keywords = get_term_meta($currentterm->term_id , '_seo_keywords',true);
	
	if($description == ''){
	$description = str_replace("\n","",strip_tags(term_description()));
	$description = str_replace("\r","",$description);
	$description = str_replace("\t","",$description);
	$description = mb_substr( $description,0,100,'UTF-8');
	}
	
	if($description == ''){
		$description = $ashu_option['general']['home_desc']; //首页描述信息
	}
	if($keywords == ''){
		$keywords = $ashu_option['general']['home_keyword'];//首页关键词
	}
}elseif( is_post_type_archive('detail') ){
	$description = $ashu_option['general']['home_desc']; //首页描述信息
	$keywords = $ashu_option['general']['home_keyword'];//首页关键词
}elseif( is_post_type_archive('notice') ){
	$description = $ashu_option['general']['home_desc']; //首页描述信息
	$keywords = $ashu_option['general']['home_keyword'];//首页关键词
}elseif( is_category() ){
	$currentterm = get_queried_object();
	$description = get_term_meta($currentterm->term_id , '_seo_description',true);
	$keywords = get_term_meta($currentterm->term_id , '_seo_keywords',true);
	
	if($description == ''){
		$description = str_replace("\n","",strip_tags(term_description()));
	$description = str_replace("\r","",$description);
	$description = str_replace("\t","",$description);
	$description = mb_substr( $description,0,100,'UTF-8');
	}
	
	if($description == ''){
		$description = $ashu_option['general']['home_desc']; //首页描述信息
	}
	if($keywords == ''){
		$keywords = $ashu_option['general']['home_keyword'];//首页关键词
	}
}else{
	$keywords = $ashu_option['general']['home_keyword']; //首页描述信息
	$description = $ashu_option['general']['home_desc'];//首页关键词
}
?>