diff --git a/functions.php b/functions.php index d6bd51d..eb95859 100644 --- a/functions.php +++ b/functions.php @@ -7,9 +7,8 @@ * @package Sakura */ -define( 'SAKURA_VERSION', '3.3.1' ); +define( 'SAKURA_VERSION', '3.3.2' ); define( 'BUILD_VERSION', '3' ); -define( 'JSDELIVR_VERSION', '3.6.7' ); //ini_set('display_errors', true); //error_reporting(E_ALL); @@ -203,7 +202,9 @@ function sakura_scripts() { 'ajaxurl' => admin_url('admin-ajax.php'), 'order' => get_option('comment_order'), // ajax comments 'formpostion' => 'bottom', // ajax comments 默认为bottom,如果你的表单在顶部则设置为top。 - 'reply_link_version' => $reply_link_version + 'reply_link_version' => $reply_link_version, + 'api' => esc_url_raw( rest_url() ), + 'nonce' => wp_create_nonce( 'wp_rest' ) )); } add_action( 'wp_enqueue_scripts', 'sakura_scripts' ); @@ -385,19 +386,19 @@ if(!function_exists('akina_comment_format')){
comment_author_email, '24', '', get_comment_author() ); ?> comment_author_email,$comment->user_id); ?>
+comment_author_email, '24', '', get_comment_author() ); ?> comment_author_email,$comment->user_id); ?>
'. $year . __("","sakura"). /*年*/'
'; //输出年份 + $output .= '
'. $year . __(" ","year","sakura"). /*年*/'
'; //输出年份 } if ($mon != $mon_tmp) { $mon = $mon_tmp; @@ -1640,4 +1630,71 @@ function sakura_comment_notify($comment_id){ } add_action('comment_post', 'sakura_comment_notify'); -//code end \ No newline at end of file +//侧栏小工具 +if (akina_option('sakura_widget')) { + if (function_exists('register_sidebar')) { + register_sidebar(array( + 'name' => __('Sidebar'),//侧栏 + 'id' => 'sakura_widget', + 'before_widget' => '',
+ 'after_widget' => ' ',
+ 'before_title' => ' '
+ ));
+ }
+}
+
+// 评论Markdown解析
+function markdown_parser($incoming_comment) {
+ global $wpdb,$comment_markdown_content;
+ $re = '/```([\s\S]*?)```[\s]*|`{1,2}[^`](.*?)`{1,2}|\[.*?\]\([\s\S]*?\)/m';
+ if(preg_replace($re,'temp',$incoming_comment['comment_content']) != strip_tags(preg_replace($re,'temp',$incoming_comment['comment_content']))){
+ siren_ajax_comment_err('评论只支持Markdown啦,见谅╮( ̄▽ ̄)╭
', + 'after_title' => '
Markdown Supported while Forbidden'); + return( $incoming_comment ); + } + $myCustomer = $wpdb->get_row("SELECT * FROM wp_comments"); + //Add column if not present. + if (!isset($myCustomer->say_state)) { + $wpdb->query("ALTER TABLE wp_comments ADD comment_markdown text"); + } + $comment_markdown_content = $incoming_comment['comment_content']; + include 'inc/Parsedown.php'; + $Parsedown = new Parsedown(); + $incoming_comment['comment_content'] = $Parsedown->text($incoming_comment['comment_content']); + return $incoming_comment; +} +add_filter('preprocess_comment' , 'markdown_parser'); + +//保存Markdown评论 +function save_markdown_comment($comment_ID, $comment_approved) { + global $wpdb,$comment_markdown_content; + $comment = get_comment($comment_ID); + $comment_content = $comment_markdown_content; + //store markdow content + $wpdb->query("UPDATE wp_comments SET comment_markdown='".$comment_content."' WHERE comment_ID='".$comment_ID."';"); +} +add_action('comment_post', 'save_markdown_comment', 10, 2); + +//打开评论HTML标签限制 +function allow_more_tag_in_comment() { + global $allowedtags; + $allowedtags['pre'] = array('class'=>array()); + $allowedtags['code'] = array('class'=>array()); + $allowedtags['h1'] = array('class'=>array()); + $allowedtags['h2'] = array('class'=>array()); + $allowedtags['h3'] = array('class'=>array()); + $allowedtags['h4'] = array('class'=>array()); + $allowedtags['h5'] = array('class'=>array()); + $allowedtags['ul'] = array('class'=>array()); + $allowedtags['ol'] = array('class'=>array()); + $allowedtags['li'] = array('class'=>array()); + $allowedtags['td'] = array('class'=>array()); + $allowedtags['th'] = array('class'=>array()); + $allowedtags['tr'] = array('class'=>array()); + $allowedtags['table'] = array('class'=>array()); + $allowedtags['thead'] = array('class'=>array()); + $allowedtags['tbody'] = array('class'=>array()); + $allowedtags['span'] = array('class'=>array()); +} +add_action('pre_comment_on_post', 'allow_more_tag_in_comment'); +//code end diff --git a/header.php b/header.php index 8f05888..96109ef 100644 --- a/header.php +++ b/header.php @@ -77,7 +77,7 @@ window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)} -> +> Plz rename the theme folder name as Sakura!
请将主题文件夹名改为 Sakura!
The theme requires PHP\'s curl support! Please turn on in `php.ini` or contact your hosting provider.