From c025d6b6ff0a9537d430e75042f074385f590fba Mon Sep 17 00:00:00 2001 From: spirit Date: Sun, 17 Nov 2019 12:02:50 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E7=99=BB=E9=99=86?= =?UTF-8?q?=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/login.css | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/inc/login.css b/inc/login.css index 0d02126..4412e1c 100644 --- a/inc/login.css +++ b/inc/login.css @@ -66,9 +66,10 @@ color: #676767 !important} background: none; box-shadow: none; margin-top: 10px; + border: none; } -#login form p { +#login form p,#login form .user-pass-wrap { font-family:"Microsoft Yahei"; position:relative; padding:0px 35px; @@ -116,6 +117,18 @@ color: #676767 !important} border: 1px solid #FF5656; } +.login .button.wp-hide-pw{ + height: 46px; + outline: none; + box-shadow: none; + border: none; + opacity: .8; +} + +.login .button.wp-hide-pw .dashicons{ + right: 1rem; +} + #login .form-send .bot { width:100%; border-bottom:1px solid #ccc; From 8f648d6819eb27596f09d8e41d12935094424383 Mon Sep 17 00:00:00 2001 From: spirit Date: Sun, 17 Nov 2019 17:00:40 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=AF=84=E8=AE=BAMarkdown=E8=A7=A3?= =?UTF-8?q?=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions.php | 49 +++++++++++++++++++++++++++++++++++++++++++++++ inc/Parsedown.php | 18 +++++++++++++++-- 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/functions.php b/functions.php index 7c7ef87..4de01d5 100644 --- a/functions.php +++ b/functions.php @@ -1655,4 +1655,53 @@ if (akina_option('sakura_widget')) { )); } } + +// 评论Markdown解析 +function markdown_parser($incoming_comment) { + global $wpdb,$comment_markdown_content; + $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/inc/Parsedown.php b/inc/Parsedown.php index 87d612a..a34b44f 100644 --- a/inc/Parsedown.php +++ b/inc/Parsedown.php @@ -17,7 +17,7 @@ class Parsedown { # ~ - const version = '1.7.1'; + const version = '1.7.3'; # ~ @@ -429,7 +429,21 @@ class Parsedown if (isset($matches[1])) { - $class = 'language-'.$matches[1]; + /** + * https://www.w3.org/TR/2011/WD-html5-20110525/elements.html#classes + * Every HTML element may have a class attribute specified. + * The attribute, if specified, must have a value that is a set + * of space-separated tokens representing the various classes + * that the element belongs to. + * [...] + * The space characters, for the purposes of this specification, + * are U+0020 SPACE, U+0009 CHARACTER TABULATION (tab), + * U+000A LINE FEED (LF), U+000C FORM FEED (FF), and + * U+000D CARRIAGE RETURN (CR). + */ + $language = substr($matches[1], 0, strcspn($matches[1], " \t\n\f\r")); + + $class = 'language-'.$language; $Element['attributes'] = array( 'class' => $class, From 6c6aab900b7ade92d62c1cc04f2bbe100b985316 Mon Sep 17 00:00:00 2001 From: spirit Date: Sun, 17 Nov 2019 17:05:24 +0800 Subject: [PATCH 3/3] Markdown Supported while Forbidden --- functions.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/functions.php b/functions.php index 4de01d5..76c5290 100644 --- a/functions.php +++ b/functions.php @@ -1659,6 +1659,11 @@ if (akina_option('sakura_widget')) { // 评论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啦,见谅╮( ̄▽ ̄)╭
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)) {