Changeset 1100834
- Timestamp:
- 02/27/2015 12:21:35 AM (11 years ago)
- Location:
- wp-first-letter-avatar
- Files:
-
- 149 added
- 2 edited
-
tags/1.2.3 (added)
-
tags/1.2.3/css (added)
-
tags/1.2.3/css/style.css (added)
-
tags/1.2.3/images (added)
-
tags/1.2.3/images/default (added)
-
tags/1.2.3/images/default/128 (added)
-
tags/1.2.3/images/default/128/a.png (added)
-
tags/1.2.3/images/default/128/b.png (added)
-
tags/1.2.3/images/default/128/c.png (added)
-
tags/1.2.3/images/default/128/d.png (added)
-
tags/1.2.3/images/default/128/e.png (added)
-
tags/1.2.3/images/default/128/f.png (added)
-
tags/1.2.3/images/default/128/g.png (added)
-
tags/1.2.3/images/default/128/h.png (added)
-
tags/1.2.3/images/default/128/i.png (added)
-
tags/1.2.3/images/default/128/j.png (added)
-
tags/1.2.3/images/default/128/k.png (added)
-
tags/1.2.3/images/default/128/l.png (added)
-
tags/1.2.3/images/default/128/m.png (added)
-
tags/1.2.3/images/default/128/mystery.png (added)
-
tags/1.2.3/images/default/128/n.png (added)
-
tags/1.2.3/images/default/128/o.png (added)
-
tags/1.2.3/images/default/128/p.png (added)
-
tags/1.2.3/images/default/128/q.png (added)
-
tags/1.2.3/images/default/128/r.png (added)
-
tags/1.2.3/images/default/128/s.png (added)
-
tags/1.2.3/images/default/128/t.png (added)
-
tags/1.2.3/images/default/128/u.png (added)
-
tags/1.2.3/images/default/128/v.png (added)
-
tags/1.2.3/images/default/128/w.png (added)
-
tags/1.2.3/images/default/128/x.png (added)
-
tags/1.2.3/images/default/128/y.png (added)
-
tags/1.2.3/images/default/128/z.png (added)
-
tags/1.2.3/images/default/256 (added)
-
tags/1.2.3/images/default/256/a.png (added)
-
tags/1.2.3/images/default/256/b.png (added)
-
tags/1.2.3/images/default/256/c.png (added)
-
tags/1.2.3/images/default/256/d.png (added)
-
tags/1.2.3/images/default/256/e.png (added)
-
tags/1.2.3/images/default/256/f.png (added)
-
tags/1.2.3/images/default/256/g.png (added)
-
tags/1.2.3/images/default/256/h.png (added)
-
tags/1.2.3/images/default/256/i.png (added)
-
tags/1.2.3/images/default/256/j.png (added)
-
tags/1.2.3/images/default/256/k.png (added)
-
tags/1.2.3/images/default/256/l.png (added)
-
tags/1.2.3/images/default/256/m.png (added)
-
tags/1.2.3/images/default/256/mystery.png (added)
-
tags/1.2.3/images/default/256/n.png (added)
-
tags/1.2.3/images/default/256/o.png (added)
-
tags/1.2.3/images/default/256/p.png (added)
-
tags/1.2.3/images/default/256/q.png (added)
-
tags/1.2.3/images/default/256/r.png (added)
-
tags/1.2.3/images/default/256/s.png (added)
-
tags/1.2.3/images/default/256/t.png (added)
-
tags/1.2.3/images/default/256/u.png (added)
-
tags/1.2.3/images/default/256/v.png (added)
-
tags/1.2.3/images/default/256/w.png (added)
-
tags/1.2.3/images/default/256/x.png (added)
-
tags/1.2.3/images/default/256/y.png (added)
-
tags/1.2.3/images/default/256/z.png (added)
-
tags/1.2.3/images/default/48 (added)
-
tags/1.2.3/images/default/48/a.png (added)
-
tags/1.2.3/images/default/48/b.png (added)
-
tags/1.2.3/images/default/48/c.png (added)
-
tags/1.2.3/images/default/48/d.png (added)
-
tags/1.2.3/images/default/48/e.png (added)
-
tags/1.2.3/images/default/48/f.png (added)
-
tags/1.2.3/images/default/48/g.png (added)
-
tags/1.2.3/images/default/48/h.png (added)
-
tags/1.2.3/images/default/48/i.png (added)
-
tags/1.2.3/images/default/48/j.png (added)
-
tags/1.2.3/images/default/48/k.png (added)
-
tags/1.2.3/images/default/48/l.png (added)
-
tags/1.2.3/images/default/48/m.png (added)
-
tags/1.2.3/images/default/48/mystery.png (added)
-
tags/1.2.3/images/default/48/n.png (added)
-
tags/1.2.3/images/default/48/o.png (added)
-
tags/1.2.3/images/default/48/p.png (added)
-
tags/1.2.3/images/default/48/q.png (added)
-
tags/1.2.3/images/default/48/r.png (added)
-
tags/1.2.3/images/default/48/s.png (added)
-
tags/1.2.3/images/default/48/t.png (added)
-
tags/1.2.3/images/default/48/u.png (added)
-
tags/1.2.3/images/default/48/v.png (added)
-
tags/1.2.3/images/default/48/w.png (added)
-
tags/1.2.3/images/default/48/x.png (added)
-
tags/1.2.3/images/default/48/y.png (added)
-
tags/1.2.3/images/default/48/z.png (added)
-
tags/1.2.3/images/default/512 (added)
-
tags/1.2.3/images/default/512/a.png (added)
-
tags/1.2.3/images/default/512/b.png (added)
-
tags/1.2.3/images/default/512/c.png (added)
-
tags/1.2.3/images/default/512/d.png (added)
-
tags/1.2.3/images/default/512/e.png (added)
-
tags/1.2.3/images/default/512/f.png (added)
-
tags/1.2.3/images/default/512/g.png (added)
-
tags/1.2.3/images/default/512/h.png (added)
-
tags/1.2.3/images/default/512/i.png (added)
-
tags/1.2.3/images/default/512/j.png (added)
-
tags/1.2.3/images/default/512/k.png (added)
-
tags/1.2.3/images/default/512/l.png (added)
-
tags/1.2.3/images/default/512/m.png (added)
-
tags/1.2.3/images/default/512/mystery.png (added)
-
tags/1.2.3/images/default/512/n.png (added)
-
tags/1.2.3/images/default/512/o.png (added)
-
tags/1.2.3/images/default/512/p.png (added)
-
tags/1.2.3/images/default/512/q.png (added)
-
tags/1.2.3/images/default/512/r.png (added)
-
tags/1.2.3/images/default/512/s.png (added)
-
tags/1.2.3/images/default/512/t.png (added)
-
tags/1.2.3/images/default/512/u.png (added)
-
tags/1.2.3/images/default/512/v.png (added)
-
tags/1.2.3/images/default/512/w.png (added)
-
tags/1.2.3/images/default/512/x.png (added)
-
tags/1.2.3/images/default/512/y.png (added)
-
tags/1.2.3/images/default/512/z.png (added)
-
tags/1.2.3/images/default/96 (added)
-
tags/1.2.3/images/default/96/a.png (added)
-
tags/1.2.3/images/default/96/b.png (added)
-
tags/1.2.3/images/default/96/c.png (added)
-
tags/1.2.3/images/default/96/d.png (added)
-
tags/1.2.3/images/default/96/e.png (added)
-
tags/1.2.3/images/default/96/f.png (added)
-
tags/1.2.3/images/default/96/g.png (added)
-
tags/1.2.3/images/default/96/h.png (added)
-
tags/1.2.3/images/default/96/i.png (added)
-
tags/1.2.3/images/default/96/j.png (added)
-
tags/1.2.3/images/default/96/k.png (added)
-
tags/1.2.3/images/default/96/l.png (added)
-
tags/1.2.3/images/default/96/m.png (added)
-
tags/1.2.3/images/default/96/mystery.png (added)
-
tags/1.2.3/images/default/96/n.png (added)
-
tags/1.2.3/images/default/96/o.png (added)
-
tags/1.2.3/images/default/96/p.png (added)
-
tags/1.2.3/images/default/96/q.png (added)
-
tags/1.2.3/images/default/96/r.png (added)
-
tags/1.2.3/images/default/96/s.png (added)
-
tags/1.2.3/images/default/96/t.png (added)
-
tags/1.2.3/images/default/96/u.png (added)
-
tags/1.2.3/images/default/96/v.png (added)
-
tags/1.2.3/images/default/96/w.png (added)
-
tags/1.2.3/images/default/96/x.png (added)
-
tags/1.2.3/images/default/96/y.png (added)
-
tags/1.2.3/images/default/96/z.png (added)
-
tags/1.2.3/images/default/template_512.psd (added)
-
tags/1.2.3/readme.txt (added)
-
tags/1.2.3/wp-first-letter-avatar-config.php (added)
-
tags/1.2.3/wp-first-letter-avatar.php (added)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/wp-first-letter-avatar.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-first-letter-avatar/trunk/readme.txt
r1099472 r1100834 1 1 === WP First Letter Avatar === 2 2 Plugin Name: WP First Letter Avatar 3 Version: 1.2. 23 Version: 1.2.3 4 4 Plugin URI: https://github.com/DanielAGW/wp-first-letter-avatar 5 5 Contributors: DanielAGW … … 70 70 == Changelog == 71 71 72 = 1.2.3 = 73 * Improved avatar appearance on top admin/user bar 74 * Added full compatibility with bbPress plugin 75 72 76 = 1.2.2 = 73 77 * Fixed conflicts with some comment systems (such as wpDiscuz) … … 88 92 == Upgrade Notice == 89 93 94 = 1.2.3 = 95 This version introduces full compatibility with bbPress and fixes some issues with avatars on user/admin bar. Update recommended. 96 90 97 = 1.2.2 = 91 98 This version fixes conflicts with some comment systems (such as wpDiscuz) and slightly improves plugin performance. Update recommended. -
wp-first-letter-avatar/trunk/wp-first-letter-avatar.php
r1099472 r1100834 5 5 * Contributors: DanielAGW 6 6 * Description: Set custom avatars for users with no Gravatar. The avatar will be a first (or any other) letter of the users's name, just like in Discourse. 7 * Version: 1.2. 27 * Version: 1.2.3 8 8 * Author: Daniel Wroblewski 9 9 * Author URI: https://github.com/DanielAGW … … 52 52 // add filter to get_avatar but only when not in admin panel: 53 53 if (!is_admin()){ 54 add_filter('get_avatar', array($this, 'set_avatar'), 10, 4); 55 } 54 add_filter('get_avatar', array($this, 'set_comment_avatar'), 10, 5); 55 } 56 // use different function for top user/admin bar and remove it after it's been rendered: 57 add_action('admin_bar_menu', function(){ 58 add_filter('get_avatar', array($this, 'set_userbar_avatar'), 10, 5); 59 },0); 60 add_action('wp_after_admin_bar_render', function(){ 61 remove_filter('get_avatar', array($this, 'set_userbar_avatar'), 10); 62 }); 63 56 64 57 65 // get plugin configuration from database: … … 106 114 107 115 108 public function set_avatar($avatar, $id_or_email, $size = '96', $default, $alt = ''){ // only size and alt arguments are used 109 110 // get comment information: 111 $comment_author = get_comment_author(); 112 $comment_email = get_comment_author_email(); 113 114 // if, for some reason, there is no comment author, use email instead: 115 if (empty($comment_author)){ 116 $comment_author = $comment_email; 116 private function set_avatar($name, $email, $size, $alt){ 117 118 if (empty($name)){ // if, for some reason, there is no name, use email instead 119 $name = $email; 120 } else if (empty($email)){ // and if no email, use user/guest name 121 $email = $name; 117 122 } 118 123 … … 120 125 if ($this->use_gravatar == TRUE){ 121 126 // gravatar used as default option, now check whether user's gravatar is set: 122 if ($this->gravatar_exists($ comment_email)){127 if ($this->gravatar_exists($email)){ 123 128 // gravatar is set, output the gravatar img 124 $avatar_output = $this->output_gravatar_img($ comment_email, $size, $alt);129 $avatar_output = $this->output_gravatar_img($email, $size, $alt); 125 130 } else { 126 131 // gravatar is not set, proceed to choose custom avatar: 127 $avatar_output = $this->choose_custom_avatar($ comment_author, $size, $alt);132 $avatar_output = $this->choose_custom_avatar($name, $size, $alt); 128 133 } 129 134 } else { 130 135 // gravatar is not used as default option, only custom avatars will be used; proceed to choose custom avatar: 131 $avatar_output = $this->choose_custom_avatar($comment_author, $size, $alt); 132 } 136 $avatar_output = $this->choose_custom_avatar($name, $size, $alt); 137 } 138 139 return $avatar_output; 140 141 } 142 143 144 145 public function set_comment_avatar($avatar, $id_or_email, $size = '96', $default, $alt = ''){ 146 147 // create two main variables: 148 $name = ''; 149 $email = ''; 150 151 // check if it's a comment: 152 $comment_id = get_comment_ID(); 153 154 if ($comment_id === NULL){ // if it's not a regular comment, use $id_or_email to get more data 155 156 if (is_numeric($id_or_email)){ // if id_or_email represents user id, get user by id 157 $id = (int) $id_or_email; 158 $user = get_user_by('id', $id); 159 } else if (is_object($id_or_email)){ // if id_or_email represents an object 160 if (!empty($id_or_email->user_id)){ // if there we can get user_id from the object, get user by id 161 $id = (int) $id_or_email->user_id; 162 $user = get_user_by('id', $id); 163 } 164 } else { // id_or_email is not user_id and is not an object, then it must be an email 165 $user = get_user_by('email', $id_or_email); 166 } 167 168 if ($user && is_object($user)){ // if commenter is a registered user... 169 $name = $user->data->display_name; 170 $email = $user->data->user_email; 171 } else { // if commenter is not a registered user, we have to try various fallbacks 172 $post_id = get_the_ID(); 173 if ($post_id !== NULL){ // if this actually is a post... 174 $post_data = array('name' => '', 'email' => ''); 175 // first we try for bbPress: 176 $post_data['name'] = get_post_meta($post_id, '_bbp_anonymous_name', TRUE); 177 $post_data['email'] = get_post_meta($post_id, '_bbp_anonymous_email', TRUE); 178 if (!empty($post_data)){ // we have some post data... 179 $name = $post_data['name']; 180 $email = $post_data['email']; 181 } 182 } else { // nothing else to do, assign email from id_or_email to email and later use it as name 183 if (!empty($id_or_email)){ 184 $email = $id_or_email; 185 } 186 } 187 } 188 189 } else { // if it's a standard comment, use basic comment functions to retrive info 190 191 $name = get_comment_author(); 192 $email = get_comment_author_email(); 193 194 } 195 196 $avatar_output = $this->set_avatar($name, $email, $size, $alt); 197 198 return $avatar_output; 199 200 } 201 202 203 204 public function set_userbar_avatar($avatar, $id_or_email, $size = '96', $default, $alt = ''){ // only size and alt arguments are used 205 206 // get user information: 207 global $current_user; 208 get_currentuserinfo(); 209 $name = $current_user->display_name; 210 $email = $current_user->user_email; 211 212 $avatar_output = $this->set_avatar($name, $email, $size, $alt); 133 213 134 214 return $avatar_output;
Note: See TracChangeset
for help on using the changeset viewer.