Merge pull request #135 from spirit1431007/pr-branch

Fix
This commit is contained in:
Mashiro 2019-11-17 17:06:38 +08:00 committed by GitHub
commit 329bd0bc0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 84 additions and 3 deletions

View File

@ -1655,4 +1655,58 @@ 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啦见谅╮( ̄▽ ̄)╭<br>Markdown Supported while <i class="fa fa-code" aria-hidden="true"></i> 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 //code end

View File

@ -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])) 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( $Element['attributes'] = array(
'class' => $class, 'class' => $class,

View File

@ -66,9 +66,10 @@ color: #676767 !important}
background: none; background: none;
box-shadow: none; box-shadow: none;
margin-top: 10px; margin-top: 10px;
border: none;
} }
#login form p { #login form p,#login form .user-pass-wrap {
font-family:"Microsoft Yahei"; font-family:"Microsoft Yahei";
position:relative; position:relative;
padding:0px 35px; padding:0px 35px;
@ -116,6 +117,18 @@ color: #676767 !important}
border: 1px solid #FF5656; 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 { #login .form-send .bot {
width:100%; width:100%;
border-bottom:1px solid #ccc; border-bottom:1px solid #ccc;