Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #22 from smeric/master
Browse files Browse the repository at this point in the history
Disallow comments pages direct access
  • Loading branch information
bueltge committed Feb 23, 2015
2 parents c8bf9ab + 3773e81 commit 84228e0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion remove-comments-absolute.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,16 @@ public function __return_closed() {
* Remove meta boxes on edit pages
* Remove support on all post types for comments
* Remove menu-entries
* Disallow comments pages direct access
*
* @access public
* @since 0.0.1
* @return void
*/
public function remove_comments() {

global $pagenow;

// int values
foreach ( array( 'comments_notify', 'default_pingback_flag' ) as $option ) {
add_filter( 'pre_option_' . $option, '__return_zero' );
Expand All @@ -190,7 +193,13 @@ public function remove_comments() {
remove_post_type_support( $post_type, 'trackbacks' );
}
}

// all comments pages
$comment_pages = array( 'comment.php', 'edit-comments.php', 'moderation.php', 'options-discussion.php' );
if ( in_array( $pagenow, $comment_pages ) ) {
wp_die( __( 'Comments are disabled on this site.', 'remove_comments_absolute' ), '', array( 'response' => 403 ) );
exit;
}

// remove dashboard meta box for recents comments
remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
}
Expand Down

0 comments on commit 84228e0

Please sign in to comment.