回复评论邮件通知

就是回复别人的评论邮件通知别人,把代码放入主题的 functions.php 文件中即可。

/**
评论邮件通知
 */
function comment_mail_notify($comment_id) {
 $admin_notify = '1'; // admin 要不要收回复通知 ( '1'=要 ; '0'=不要 )
 $admin_email = get_bloginfo ('admin_email'); // $admin_email 可改为你指定的 e-mail.
 $comment = get_comment($comment_id);
 $comment_author_email = trim($comment->comment_author_email);
 $parent_id = $comment->comment_parent ? $comment->comment_parent : '';
 global $wpdb;
 if ($wpdb->query("Describe {$wpdb->comments} comment_mail_notify") == '')
 $wpdb->query("ALTER TABLE {$wpdb->comments} ADD COLUMN comment_mail_notify TINYINT NOT NULL DEFAULT 0;");
 if (($comment_author_email != $admin_email && isset($_POST['comment_mail_notify'])) || ($comment_author_email == $admin_email && $admin_notify == '1'))
 $wpdb->query("UPDATE {$wpdb->comments} SET comment_mail_notify='1' WHERE comment_ID='$comment_id'");
 $notify = $parent_id ? get_comment($parent_id)->comment_mail_notify : '0';
 $spam_confirmed = $comment->comment_approved;
 if ($parent_id != '' && $spam_confirmed != 'spam' && $notify == '1') {
 $wp_email = 'no-reply@' . preg_replace('#^www.#', '', strtolower($_SERVER['SERVER_NAME'])); // e-mail 发出点, no-reply 可改为可用的 e-mail.
 $to = trim(get_comment($parent_id)->comment_author_email);
 $subject = '您在 [' . get_option("blogname") . '] 的留言有了回复';
 $message = '
 <div>
 <p>' . trim(get_comment($parent_id)->comment_author) . ',您好!</p>
 <p>您曾在《' . get_the_title($comment->comment_post_ID) . '》的留言:<br /><br />'
 . trim(get_comment($parent_id)->comment_content) . '</p>
 <p>' . trim($comment->comment_author) . ' 给您的回复:<br /><br />'
 . trim($comment->comment_content) . '</p>
 <p>您可以点击 <a href="' . htmlspecialchars(get_comment_link($comment->comment_parent)). '" target="_blank">查看回复的完整內容</a></p>
 <p>感谢您对 <a href="' . get_option('home') . '" target="_blank">' . get_option('blogname') . '</a> 的关注,如您有任何疑问,欢迎在博客留言。</p>
 <p>(此邮件由系统自动发送,请勿回复。)</p>
 </div>';
 $from = "From: \"" . get_option('blogname') . "\" <$wp_email>";
 $headers = "$from\nContent-Type: text/html; charset=" . get_option('blog_charset') . "\n";
 wp_mail( $to, $subject, $message, $headers );
 }
}
add_action('comment_post', 'comment_mail_notify');
 
/* 自动加勾选栏 */
function add_checkbox() {
 echo '<input type="checkbox" name="comment_mail_notify" id="comment_mail_notify" value="comment_mail_notify" checked="checked" style="margin-left:20px;" /><label for="comment_mail_notify">有人回复时邮件通知我</label>';
}
add_action('comment_form', 'add_checkbox');




// 加载jquery开始,如果主题已加载不加这段。
function zm_jquery_script() {
	wp_enqueue_script( 'jquery' );
}
add_action( 'wp_enqueue_scripts', 'zm_jquery_script' );
// 加载jquery结束
function zm_mouse_cursor() { ?>
<!-- 必须的DIV -->
<div class="mouse-cursor cursor-outer"></div>
<div class="mouse-cursor cursor-inner"></div>
<!-- JS脚本 -->
<script>
jQuery(document).ready(function($){
	var myCursor = jQuery('.mouse-cursor');
	if (myCursor.length) {
		if ($('body')) {
			const e = document.querySelector('.cursor-inner'),
			t = document.querySelector('.cursor-outer');
			let n,
			i = 0,
			o = !1;
			window.onmousemove = function(s) {
				o || (t.style.transform = "translate(" + s.clientX + "px, " + s.clientY + "px)"),
				e.style.transform = "translate(" + s.clientX + "px, " + s.clientY + "px)",
				n = s.clientY,
				i = s.clientX
			},
			$('body').on("mouseenter", "a, .cursor-pointer",
			function() {
				e.classList.add('cursor-hover'),
				t.classList.add('cursor-hover')
			}),
			$('body').on("mouseleave", "a, .cursor-pointer",
			function() {
				$(this).is("a") && $(this).closest(".cursor-pointer").length || (e.classList.remove('cursor-hover'), t.classList.remove('cursor-hover'))
			}),
			e.style.visibility = "visible",
			t.style.visibility = "visible"
		}
	}
})
 
</script>
<!-- 样式 -->
<style>
.mouse-cursor {
	position: fixed;
	left: 0;
	top: 0;
	pointer-events: none;
	border-radius: 50%;
	-webkit-transform: translateZ(0);
	transform: translateZ(0);
	visibility: hidden
}
 
.cursor-inner {
	margin-left: -3px;
	margin-top: -3px;
	width: 6px;
	height: 6px;
	z-index: 10000001;
	background: #ffa9a4;
	-webkit-transition: width .3s ease-in-out,height .3s ease-in-out,margin .3s ease-in-out,opacity .3s ease-in-out;
	transition: width .3s ease-in-out,height .3s ease-in-out,margin .3s ease-in-out,opacity .3s ease-in-out
}
 
.cursor-inner.cursor-hover {
	margin-left: -18px;
	margin-top: -18px;
	width: 36px;
	height: 36px;
	background: #ffa9a4;
	opacity: .3
}
 
.cursor-outer {
	margin-left: -15px;
	margin-top: -15px;
	width: 30px;
	height: 30px;
	border: 2px solid #ffa9a4;
	-webkit-box-sizing: border-box;
	box-sizing: border-box;
	z-index: 10000000;
	opacity: .5;
	-webkit-transition: all .08s ease-out;
	transition: all .08s ease-out
}
 
.cursor-outer.cursor-hover {
	opacity: 0
}
 
.main-wrapper[data-magic-cursor=hide] .mouse-cursor {
	display: none;
	opacity: 0;
	visibility: hidden;
	position: absolute;
	z-index: -1111
}
</style>
<?php }
add_action( 'wp_footer', 'zm_mouse_cursor' );
瓜田的李

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

Captcha Code