WordPress.org

Make WordPress Core

Ticket #11695: comment-rss-security.php

File comment-rss-security.php, 989 bytes (added by palotasb, 6 years ago)

Plugin replaces the content of comments on private posts with the text ("Enter your password to view comments").

Line 
1<?php
2/**
3 * @package Comment RSS Security
4 * @author Palotas, Boldizsar
5 * @version 0.1
6 */
7/*
8Plugin Name: Comment RSS Security
9Plugin URI: http://boldizsar.palotas.eu/blog/
10Description: Plugin that enhances the default security behaviour of WordPress. Disables showing comments related to private posts in RSS.
11Author: Palotas, Boldizsar
12Version: 0.1
13Author URI: http://boldizsar.palotas.eu/blog/
14*/
15
16function palotasb_comment_security($content) {
17        global $comment;
18       
19        $post = get_post($comment->comment_post_ID);
20       
21        if (
22                isset($post->post_status) &&
23                'private' == $post->post_status
24                && !(
25                        function_exists('current_user_can') &&
26                        (current_user_can('read_private_posts') || current_user_can('read_private_pages'))
27                )
28        )
29                $content = apply_filters("palotasb_comment_security_private", "<em>" . __("Enter your password to view comments") . "</em>");
30       
31        return $content;
32}
33
34add_filter("get_comment_text", "palotasb_comment_security");
35
36?>