fix: some syntax errors

pull/287/head
Seaton Jiang 2020-08-04 09:44:30 +08:00
parent 00941a00a8
commit 4a8dc6674b
1 changed files with 8 additions and 6 deletions

View File

@ -29,20 +29,21 @@ add_filter('wp_title', 'title', 10, 2);
function keywords() function keywords()
{ {
global $post; global $post;
$keywords = '';
if (is_home()) { if (is_home()) {
$keywords = kratos_option('seo_keywords'); $keywords = kratos_option('seo_keywords');
} elseif (is_single()) { } elseif (is_single()) {
$keywords = get_post_meta($post->ID, "seo_keywords_value", true); $keywords = get_post_meta($post->ID, "seo_keywords_value", true);
if($keywords == '') { if ($keywords == '') {
$tags = wp_get_post_tags($post->ID); $tags = wp_get_post_tags($post->ID);
foreach ($tags as $tag ) { foreach ($tags as $tag) {
$keywords = $keywords . $tag->name . ", "; $keywords = $keywords . $tag->name . ", ";
} }
$keywords = rtrim($keywords, ', '); $keywords = rtrim($keywords, ', ');
} }
} elseif (is_page()) { } elseif (is_page()) {
$keywords = get_post_meta($post->ID, "seo_keywords_value", true); $keywords = get_post_meta($post->ID, "seo_keywords_value", true);
if($keywords == '') { if ($keywords == '') {
$keywords = kratos_option('seo_keywords'); $keywords = kratos_option('seo_keywords');
} }
} else { } else {
@ -55,6 +56,7 @@ function keywords()
function description() function description()
{ {
global $post; global $post;
$description = '';
if (is_home()) { if (is_home()) {
$description = kratos_option('seo_description'); $description = kratos_option('seo_description');
} elseif (is_single()) { } elseif (is_single()) {
@ -63,7 +65,7 @@ function description()
$description = get_the_excerpt(); $description = get_the_excerpt();
} }
if ($description == '') { if ($description == '') {
$description = str_replace("\n","",mb_strimwidth(strip_tags($post->post_content), 0, 200, "", 'utf-8')); $description = str_replace("\n", "", mb_strimwidth(strip_tags($post->post_content), 0, 200, "", 'utf-8'));
} }
} elseif (is_category()) { } elseif (is_category()) {
$description = category_description(); $description = category_description();