-
Notifications
You must be signed in to change notification settings - Fork 0
/
EPFL_disable_comments.php
69 lines (56 loc) · 1.79 KB
/
EPFL_disable_comments.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/*
* Plugin Name: EPFL Disable Comments
* Plugin URI:
* Description: Must-use plugin to disable comments
* Version: 0.4
* Author: Lucien Chaboudez (https://people.epfl.ch/lucien.chaboudez)
*/
// Remove "comment" shortcut from admin menu (on the left)
// See wp-theme-2018/disable_comments.php for a full-featured version
function epfl_dis_com_remove_menu()
{
remove_menu_page( 'edit-comments.php' );
}
add_action( 'admin_menu', 'epfl_dis_com_remove_menu' );
// Disable widget showing last comments
function epfl_dis_com_disable_rc_widget()
{
unregister_widget( 'WP_Widget_Recent_Comments' );
}
add_action( 'widgets_init', 'epfl_dis_com_disable_rc_widget' );
function epfl_dis_com_filter_wp_headers( $headers )
{
unset( $headers['X-Pingback'] );
return $headers;
}
add_filter( 'wp_headers', 'epfl_dis_com_filter_wp_headers');
function epfl_dis_com_filter_query()
{
if( is_comment_feed() )
{
wp_die( __( 'Comments are closed.' ), '', array( 'response' => 403 ) );
}
}
add_action( 'template_redirect', 'epfl_dis_com_filter_query', 9 );
// Remove "comment" icon from admin bar
function epfl_dis_com_filter_admin_bar()
{
if( is_admin_bar_showing() )
{
remove_action( 'admin_bar_menu', 'wp_admin_bar_comments_menu', 60 );
}
}
add_action( 'template_redirect', 'epfl_dis_com_filter_admin_bar' );
add_action( 'admin_init', 'epfl_dis_com_filter_admin_bar' );
// Deactivate comment form on all elements (posts, medias, ...)
function epfl_dis_com_on_all( $open, $post_id ) {
return false;
}
add_filter( 'comments_open', 'epfl_dis_com_on_all', 10 , 2 );
function epfl_dis_com_deregister_script()
{
wp_deregister_script( 'comment-reply' );
}
add_filter('wp_enqueue_scripts', 'epfl_dis_com_deregister_script');
remove_action( 'wp_head', 'feed_links_extra', 3 );