Changeset 1491269
- Timestamp:
- 09/06/2016 04:19:38 PM (10 years ago)
- Location:
- anonymous-comments
- Files:
-
- 9 added
- 2 edited
-
tags/0.2 (added)
-
tags/0.2/anonymous_comments.php (added)
-
tags/0.2/code (added)
-
tags/0.2/code/config (added)
-
tags/0.2/code/config/class-anonymous_comments_config.php (added)
-
tags/0.2/code/display (added)
-
tags/0.2/code/display/class-anonymous_comments_display.php (added)
-
tags/0.2/readme.txt (added)
-
trunk/anonymous_comments.php (modified) (1 diff)
-
trunk/code/display/class-anonymous_comments_display.php (modified) (3 diffs)
-
trunk/readme.txt (added)
Legend:
- Unmodified
- Added
- Removed
-
anonymous-comments/trunk/anonymous_comments.php
r1449875 r1491269 4 4 Plugin Name: Anonymous Comment 5 5 Description: Allows a page to have anonymous comments 6 Version: 0. 16 Version: 0.2 7 7 Author: pgogy 8 8 Author URI: http://www.pgogywebstuff.com -
anonymous-comments/trunk/code/display/class-anonymous_comments_display.php
r1449875 r1491269 4 4 5 5 public function __construct() { 6 add_filter('get_comment_author', array($this, 'author') );7 add_filter('get_avatar', array($this, 'avatar'), 1 , 5);8 add_filter(' comment_url', array($this, 'url'));9 add_filter('comment_email', array($this, 'email') );6 add_filter('get_comment_author', array($this, 'author'), 10, 3); 7 add_filter('get_avatar', array($this, 'avatar'), 10 , 5); 8 add_filter('get_comment_author_url', array($this, 'url'),10,3); 9 add_filter('comment_email', array($this, 'email'), 10, 3); 10 10 add_action('comment_form', array($this, 'additional')); 11 11 } 12 12 13 13 function additional(){ 14 echo "<p>" . __("All comments to this site are anonymous") . "</p>"; 14 global $post; 15 if(get_post_meta($post->ID, "anonymous_comments",true)!==""){ 16 echo "<p>" . __("All comments to this post are anonymous") . "</p>"; 17 } 15 18 } 16 19 17 function email( $email ) { 18 if(is_single()){ 19 global $post,$comment; 20 21 if(get_post_meta($post->ID, "anonymous_comments")!==""){ 22 23 if(get_current_user_id()!=0){ 24 if(get_post_meta($post->ID, "anonymous_comments")!==""){ 25 if(get_post_meta($post->ID, "admin_bypass_anonymous_comments")!==""){ 26 return $email; 27 } 28 } 20 function email( $email, $comment_ID, $comment ) { 21 22 if(is_admin()){ 23 if (defined('DOING_AJAX')){ 24 if(!DOING_AJAX) { 25 return $author; 29 26 } 30 31 if($comment->user_id==$post->post_author){ 32 if(get_post_meta($post->ID, "show_author_anonymous_comments")!==""){ 27 } 28 } 29 30 global $post,$comment; 31 32 if(get_post_meta($post->ID, "anonymous_comments",true)!==""){ 33 34 if(get_current_user_id()!=0){ 35 if(get_post_meta($post->ID, "anonymous_comments",true)!==""){ 36 if(get_post_meta($post->ID, "admin_bypass_anonymous_comments",true)!==""){ 33 37 return $email; 34 38 } 35 39 } 36 37 return "";38 39 40 } 40 41 42 if($comment->user_id==$post->post_author){ 43 if(get_post_meta($post->ID, "show_author_anonymous_comments",true)!==""){ 44 return $email; 45 } 46 } 47 48 return ""; 49 41 50 } 51 42 52 } 43 53 44 function url( $url ) { 45 if(is_single()){ 46 global $post,$comment; 54 function url( $url, $comment_ID, $comment) { 55 56 if(is_admin()){ 57 if (defined('DOING_AJAX')){ 58 if(!DOING_AJAX) { 59 return $author; 60 } 61 } 62 } 63 64 global $post,$comment; 47 65 48 if(get_post_meta($post->ID, "anonymous_comments")!==""){ 49 50 if(get_current_user_id()!=0){ 51 if(get_post_meta($post->ID, "anonymous_comments")!==""){ 52 if(get_post_meta($post->ID, "admin_bypass_anonymous_comments")!==""){ 53 return $url; 54 } 55 } 56 } 57 58 if($comment->user_id==$post->post_author){ 59 if(get_post_meta($post->ID, "show_author_anonymous_comments")!==""){ 66 if(get_post_meta($post->ID, "anonymous_comments",true)!==""){ 67 68 if(get_current_user_id()!=0){ 69 if(get_post_meta($post->ID, "anonymous_comments",true)!==""){ 70 if(get_post_meta($post->ID, "admin_bypass_anonymous_comments",true)!==""){ 60 71 return $url; 61 72 } 62 73 } 63 64 return "";65 66 74 } 67 75 76 if($comment->user_id==$post->post_author){ 77 if(get_post_meta($post->ID, "show_author_anonymous_comments",true)!==""){ 78 return $url; 79 } 80 } 81 82 return ""; 83 68 84 } 85 69 86 } 70 87 71 88 function avatar( $avatar, $id_or_email, $size, $default, $alt ) { 72 89 73 if(is_single()){ 74 global $post,$comment; 90 if(is_admin()){ 91 if (defined('DOING_AJAX')){ 92 if(!DOING_AJAX) { 93 return $author; 94 } 95 } 96 } 97 98 global $post,$comment; 75 99 76 if(get_post_meta($post->ID, "anonymous_comments")!==""){ 100 if(isset($post->ID)){ 101 102 if(get_post_meta($post->ID, "anonymous_comments",true)!==""){ 77 103 78 104 if(get_current_user_id()!=0){ 79 if(get_post_meta($post->ID, "anonymous_comments" )!==""){80 if(get_post_meta($post->ID, "admin_bypass_anonymous_comments" )!==""){105 if(get_post_meta($post->ID, "anonymous_comments",true)!==""){ 106 if(get_post_meta($post->ID, "admin_bypass_anonymous_comments",true)!==""){ 81 107 return $avatar; 82 108 } … … 84 110 } 85 111 86 if($comment->user_id==$post->post_author){ 87 if(get_post_meta($post->ID, "show_author_anonymous_comments")!==""){ 88 return $avatar; 112 if(isset($comment->user_id)){ 113 if($comment->user_id==$post->post_author){ 114 if(get_post_meta($post->ID, "show_author_anonymous_comments",true)!==""){ 115 return $avatar; 116 } 89 117 } 90 118 } … … 95 123 96 124 } 125 97 126 } 98 127 99 function author($author){ 100 101 if(is_single()){ 128 function author($author, $comment_ID, $comment){ 102 129 103 global $post, $comment; 130 if(is_admin()){ 131 if (defined('DOING_AJAX')){ 132 if(!DOING_AJAX) { 133 return $author; 134 } 135 } 136 } 104 137 105 if(get_post_meta($post->ID, "anonymous_comments")!==""){ 106 107 if(get_current_user_id()!=0){ 108 if(get_post_meta($post->ID, "anonymous_comments")!==""){ 109 if(get_post_meta($post->ID, "admin_bypass_anonymous_comments")!==""){ 110 return $author; 111 } 112 } 113 } 114 115 if($comment->user_id==$post->post_author){ 116 if(get_post_meta($post->ID, "show_author_anonymous_comments")!==""){ 138 if(get_post_meta($comment->comment_post_ID, "anonymous_comments",true)!==""){ 139 140 if(get_current_user_id()!=0){ 141 if(get_post_meta($comment->comment_post_ID, "anonymous_comments",true)!==""){ 142 if(get_post_meta($comment->comment_post_ID, "admin_bypass_anonymous_comments",true)!==""){ 117 143 return $author; 118 144 } 119 145 } 120 121 $authors = get_post_meta($post->ID, "comment_authors", true); 122 if(!is_array($authors)){ 123 $authors = array(); 146 } 147 148 $post = get_post($comment->comment_post_ID); 149 150 if($comment->user_id==$post->post_author){ 151 if(get_post_meta($post->ID, "show_author_anonymous_comments", true)!==""){ 152 return $author; 124 153 } 125 126 if(!in_array($author, $authors)){ 127 $authors[] = $author; 128 update_post_meta($post->ID, "comment_authors", $authors); 129 return __("Anonymous Commenter") . " " . count($authors); 130 }else{ 131 return __("Anonymous Commenter") . " " . (array_search ($author, $authors) + 1); 132 } 133 154 } 155 156 $authors = get_post_meta($comment->comment_post_ID, "comment_authors", true); 157 if(!is_array($authors)){ 158 $authors = array(); 159 } 160 161 if(!in_array($author, $authors)){ 162 $authors[] = $author; 163 update_post_meta($comment->comment_post_ID, "comment_authors", $authors); 164 return __("Anonymous Commenter") . " " . count($authors); 165 }else{ 166 return __("Anonymous Commenter") . " " . (array_search ($author, $authors) + 1); 134 167 } 135 168 136 169 } 137 170 171 return $author; 172 138 173 } 139 174
Note: See TracChangeset
for help on using the changeset viewer.