HEX
Server: nginx/1.16.1
System: Linux VM-0-14-centos 4.18.0-348.7.1.el8_5.x86_64 #1 SMP Wed Dec 22 13:25:12 UTC 2021 x86_64
User: www (1000)
PHP: 8.3.31
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/www.sceybwg.com/wp-content/themes/Modular/extends/remove-comment/remove-comment.php
<?php
//禁用评论的邮件通知
add_filter( 'notify_post_author', '__return_false' );
add_filter( 'notify_moderator', '__return_false' );

//移除后台菜单
function remove_comments_menu() {
	//移除「评论」主菜单
	remove_menu_page('edit-comments.php');
	//移除评论子菜单项
	remove_submenu_page('edit.php', 'post-comments');
}
add_action('admin_menu', 'remove_comments_menu');

//禁用评论功能
function disable_comments_post_types_support() {
	$post_types = get_post_types();
	foreach ($post_types as $post_type) {
		if(post_type_supports($post_type, 'comments')) {
			remove_post_type_support($post_type, 'comments');
			remove_post_type_support($post_type, 'trackbacks');
		}
	}
}
add_action('init', 'disable_comments_post_types_support');

//移除文章编辑页面中的评论选项卡
function remove_comments_meta_box() {
	remove_meta_box('commentsdiv', 'post', 'normal'); //对于文章
	remove_meta_box('commentsdiv', 'page', 'normal'); //对于页面
}
add_action('admin_menu', 'remove_comments_meta_box');

//移除 WordPress 后台管理栏(Admin Bar)中的「评论」菜单项
function remove_admin_bar_comments() {
    global $wp_admin_bar;
    $wp_admin_bar->remove_menu('comments'); //移除评论菜单项
}
add_action('wp_before_admin_bar_render', 'remove_admin_bar_comments');

//禁止提交评论(防止被刷评论)
function disable_comment_post() {
    if (is_singular() && !is_admin()) {
        wp_die(__('评论功能已被禁用。')); // 显示提示信息并阻止评论提交
    }
}
add_action('pre_comment_on_post', 'disable_comment_post');