diff --git a/inc/theme-setting.php b/inc/theme-setting.php index 95ad8d7..23b3e47 100644 --- a/inc/theme-setting.php +++ b/inc/theme-setting.php @@ -49,7 +49,7 @@ function keywords() } else { $keywords = single_tag_title('', false); } - return trim(strip_tags($keywords)); + return trim(esc_attr(strip_tags($keywords))); } // Description 配置 @@ -77,7 +77,7 @@ function description() $description = kratos_option('seo_description'); } } - return trim(strip_tags($description)); + return trim(esc_attr(strip_tags($description))); } // robots.txt 配置 diff --git a/inc/theme-widgets.php b/inc/theme-widgets.php index 11ce4b4..94b93cb 100644 --- a/inc/theme-widgets.php +++ b/inc/theme-widgets.php @@ -50,11 +50,11 @@ function most_comm_posts($days = 30, $nums = 6) if (!empty($result)) { foreach ($result as $topten) { $postid = $topten->ID; - $title = $topten->post_title; + $title = esc_attr(strip_tags($topten->post_title)); $commentcount = $topten->comment_count; if ($commentcount >= 0) { $output .= ''; - $output .= strip_tags($title); + $output .= $title; $output .= ''; } } @@ -109,10 +109,10 @@ function string_cut($string, $sublen, $start = 0, $code = 'UTF-8') { function latest_comments($list_number=5, $cut_length=50) { - global $wpdb,$output; - $comments = $wpdb->get_results("SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, comment_author_url, comment_author_email, comment_content AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = '1' AND (comment_type = '' OR comment_type = 'comment') AND user_id != '1' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT $list_number"); + global $wpdb, $output; + $comments = $wpdb->get_results("SELECT comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_content FROM {$wpdb->comments} LEFT OUTER JOIN {$wpdb->posts} ON {$wpdb->comments}.comment_post_ID = {$wpdb->posts}.ID WHERE comment_approved = '1' AND (comment_type = '' OR comment_type = 'comment') AND user_id != '1' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT {$list_number}"); foreach ($comments as $comment) { - $output .= ' '; + $output .= ' '; } return $output; } @@ -397,7 +397,7 @@ class widget_posts extends WP_Widget
@@ -511,4 +511,4 @@ function register_widgets() register_widget('widget_posts'); register_widget('widget_comments'); } -add_action('widgets_init', 'register_widgets'); \ No newline at end of file +add_action('widgets_init', 'register_widgets');