From 8d5e6a8fa534692723da0d49b189a708d4626bf4 Mon Sep 17 00:00:00 2001 From: spirit Date: Wed, 30 Oct 2019 20:14:04 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=AF=84=E8=AE=BA=E5=9B=9E=E5=A4=8D?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E9=80=9A=E7=9F=A5=E5=8F=AF=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comments.php | 3 ++- functions.php | 10 +++++++++- options.php | 9 ++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/comments.php b/comments.php index 01f8df4..6228e4d 100644 --- a/comments.php +++ b/comments.php @@ -52,6 +52,7 @@ if(comments_open()){ if(akina_option('norobot')) $robot_comments = ''; $private_ms = akina_option('open_private_message') ? '' : ''; + $mail_notify = akina_option('mail_notify') ? '' : ''; $args = array( 'id_form' => 'commentform', 'id_submit' => 'submit', @@ -93,7 +94,7 @@ 'email' => '', 'url' => - '' . $robot_comments . $private_ms , + '' . $robot_comments . $private_ms . $mail_notify , 'qq' => '' ) diff --git a/functions.php b/functions.php index 1e90aab..f44da8a 100644 --- a/functions.php +++ b/functions.php @@ -870,7 +870,8 @@ function comment_mail_notify($comment_id){ $comment = get_comment($comment_id); $parent_id = $comment->comment_parent ? $comment->comment_parent : ''; $spam_confirmed = $comment->comment_approved; - if(($parent_id != '') && ($spam_confirmed != 'spam')){ + $mail_notify = akina_option('mail_notify') ? get_comment_meta($parent_id,'mail_notify',false) : false; + if(($parent_id != '') && ($spam_confirmed != 'spam') && (!$mail_notify)){ $wp_email = $mail_user_name . '@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])); $to = trim(get_comment($parent_id)->comment_author_email); $subject = '你在 [' . get_option("blogname") . '] 的留言有了回应'; @@ -1691,4 +1692,11 @@ if(akina_option('live_search')){ } ); } +//评论回复 +function sakura_comment_notify($comment_id){ + if ( !$_POST['mail-notify'] ) + update_comment_meta($comment_id,'mail_notify','false'); +} +add_action('comment_post', 'spirit_comment_notify'); + //code end diff --git a/options.php b/options.php index c6c9e33..41f1daa 100644 --- a/options.php +++ b/options.php @@ -1055,6 +1055,13 @@ function optionsframework_options() { 'std' => 'bibi', 'type' => 'text'); + $options[] = array( + 'name' => __('邮件回复通知', 'options_framework_theme'), + 'desc' => __('WordPress默认会使用邮件通知用户评论收到回复,开启此项允许用户设置自己的评论收到回复时是否使用邮件通知', 'options_framework_theme'), + 'id' => 'mail_notify', + 'std' => '0', + 'type' => 'checkbox'); + $options[] = array( 'name' => __('允许私密评论', 'options_framework_theme'), 'desc' => __('允许用户设置自己的评论对其他人不可见', 'options_framework_theme'), @@ -1091,4 +1098,4 @@ function optionsframework_options() { 'type' => 'text'); return $options; -} \ No newline at end of file +} From a1f8da856986230ba710d133988b356a0f32b72a Mon Sep 17 00:00:00 2001 From: spirit Date: Wed, 30 Oct 2019 20:17:35 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E5=9B=9E=E5=A4=8D=E9=80=9A=E7=9F=A5=E5=8F=AF=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions.php | 3 ++- options.php | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/functions.php b/functions.php index f44da8a..f6fad8c 100644 --- a/functions.php +++ b/functions.php @@ -871,7 +871,8 @@ function comment_mail_notify($comment_id){ $parent_id = $comment->comment_parent ? $comment->comment_parent : ''; $spam_confirmed = $comment->comment_approved; $mail_notify = akina_option('mail_notify') ? get_comment_meta($parent_id,'mail_notify',false) : false; - if(($parent_id != '') && ($spam_confirmed != 'spam') && (!$mail_notify)){ + $admin_notify = akina_option('admin_notify') ? '1' : (get_comment($parent_id)->comment_author_email != get_bloginfo('admin_email') ? '1' : '0'); + if(($parent_id != '') && ($spam_confirmed != 'spam') && ($admin_notify != '0') && (!$mail_notify)){ $wp_email = $mail_user_name . '@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])); $to = trim(get_comment($parent_id)->comment_author_email); $subject = '你在 [' . get_option("blogname") . '] 的留言有了回应'; diff --git a/options.php b/options.php index 41f1daa..58fbe2f 100644 --- a/options.php +++ b/options.php @@ -1062,6 +1062,13 @@ function optionsframework_options() { 'std' => '0', 'type' => 'checkbox'); + $options[] = array( + 'name' => __('邮件回复通知管理员', 'options_framework_theme'), + 'desc' => __('当管理员评论收到回复时是否使用邮件通知', 'options_framework_theme'), + 'id' => 'admin_notify', + 'std' => '0', + 'type' => 'checkbox'); + $options[] = array( 'name' => __('允许私密评论', 'options_framework_theme'), 'desc' => __('允许用户设置自己的评论对其他人不可见', 'options_framework_theme'), From bfca98e339ac58550f8e710d75ff0d498a5f43f3 Mon Sep 17 00:00:00 2001 From: spirit Date: Wed, 30 Oct 2019 20:24:58 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=BF=98=E6=94=B9=E5=90=8D=E4=BA=86-=5F-?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions.php b/functions.php index f6fad8c..b5a0dde 100644 --- a/functions.php +++ b/functions.php @@ -1698,6 +1698,6 @@ function sakura_comment_notify($comment_id){ if ( !$_POST['mail-notify'] ) update_comment_meta($comment_id,'mail_notify','false'); } -add_action('comment_post', 'spirit_comment_notify'); +add_action('comment_post', 'sakura_comment_notify'); //code end