WordPress.org

Plugin Directory

Changeset 1421630


Ignore:
Timestamp:
05/21/16 19:37:46 (15 months ago)
Author:
Dev49.net
Message:

Version 2.2.6.1:

  • Fixed minor avatar issue (added bp_core_fetch_avatar_url filter callback)
Location:
buddypress-first-letter-avatar
Files:
535 added
2 edited

Legend:

Unmodified
Added
Removed
  • buddypress-first-letter-avatar/trunk/buddypress-first-letter-avatar.php

    r1370961 r1421630  
    88 * Contributors: Dev49.net, DanielAGW 
    99 * Description: Set custom avatars for BuddyPress users. The avatar will be the first (or any other) letter of the user's name on a colorful background. 
    10  * Version: 2.2.6 
     10 * Version: 2.2.6.1 
    1111 * Author: Dev49.net 
    1212 * Author URI: http://dev49.net 
    1313 * Tags: avatars, comments, buddypress, custom avatar, discussion, change avatar, avatar, custom wordpress avatar, first letter avatar, comment change avatar, wordpress new avatar, avatar, initial avatar 
    1414 * Requires at least: 4.4 
    15  * Tested up to: 4.4.2 
     15 * Tested up to: 4.5.2 
    1616 * Stable tag: trunk 
    1717 * License: GPLv2 or later 
     
    110110        // add filter to bp_core_fetch_avatar: 
    111111        add_filter('bp_core_fetch_avatar', array($this, 'set_buddypress_avatar'), $this->filter_priority, 2); // this is used for every avatar call except the anonymous comment posters 
     112 
     113        // filter just the avatar URL: 
     114        add_filter('bp_core_fetch_avatar_url', array($this, 'set_buddypress_avatar_url'), $this->filter_priority, 2); 
    112115 
    113116        // add filter for wpDiscuz: 
     
    311314 
    312315    /* 
     316     * This method is used to filter just the avatar URL. Basically the same as set_buddypress_avatar(), 
     317     * but it does not return the full <img /> tag, it just returns the image URL 
     318     */ 
     319    public function set_buddypress_avatar_url($image_url = '', $params = array()) { 
     320 
     321        $user_id = $params['item_id']; 
     322        $size = $params['width']; 
     323        $email = $params['email']; 
     324 
     325        if (!is_numeric($user_id)){ // user_id was not passed, so we cannot do anything about this avatar 
     326            return $image_url; 
     327        } 
     328 
     329        // if there is no gravatar URL, it means that user has set his own profile avatar, 
     330        // so we're gonna see if we should be using it (user avatar); 
     331        // if we should, just return the input data and leave the avatar as it was: 
     332        if ($this->use_profile_avatar == true){ 
     333            if (stripos($image_url, 'gravatar.com/avatar') === false){ // we need to specifically check for false (hence '===') 
     334                return $image_url; 
     335            } 
     336        } 
     337 
     338        $user = get_user_by('id', $user_id); 
     339 
     340        if (empty($size)){ // if for some reason size was not specified... 
     341            $size = 48; // just set it to 48 
     342        } 
     343 
     344        $name = $user->data->display_name; 
     345 
     346        if (empty($email)){ // email was not supplied with parameters 
     347            $email = $user->data->user_email; // get it by user id 
     348        } 
     349 
     350        if (empty($name)){ 
     351            $name = bp_core_get_username($user_id); // BuddyPress fallback 
     352        } 
     353 
     354        if (empty($name)){ 
     355            $name = $user->data->user_nicename; // another fallback (to WP nicename) 
     356        } 
     357 
     358        $first_letter_uri = $this->generate_first_letter_uri($name, $size); // get letter URL 
     359 
     360        // check whether Gravatar should be used at all: 
     361        if ($this->use_gravatar == true && !empty($email)){ // if we should use gravatar and we have email 
     362            $gravatar_uri = $this->generate_gravatar_uri($email, $size); 
     363            $image_url = $gravatar_uri . '&default=' . urlencode($first_letter_uri); 
     364        } else { // gravatar not used or we do not have email 
     365            $image_url = $first_letter_uri; 
     366        } 
     367 
     368        return $image_url; 
     369 
     370    } 
     371 
     372 
     373 
     374    /* 
    313375     * This method is used to filter every avatar, except for anonymous comments. 
    314376     * It returns full <img /> HTML tag 
  • buddypress-first-letter-avatar/trunk/readme.txt

    r1370961 r1421630  
    11=== BuddyPress First Letter Avatar === 
    22Plugin Name: BuddyPress First Letter Avatar 
    3 Version: 2.2.6 
     3Version: 2.2.6.1 
    44Plugin URI: http://dev49.net 
    55Contributors: Dev49.net, DanielAGW 
    66Tags: avatars, comments, buddypress, custom avatar, discussion, change avatar, avatar, custom wordpress avatar, first letter avatar, comment change avatar, wordpress new avatar, avatar, initial avatar 
    77Requires at least: 4.4 
    8 Tested up to: 4.4.2 
     8Tested up to: 4.5.2 
    99Stable tag: trunk 
    1010Author: Dev49.net 
     
    8282 
    8383== Changelog == 
     84 
     85= 2.2.6.1 = 
     86* Fixed minor avatar issue (added bp_core_fetch_avatar_url filter callback) 
    8487 
    8588= 2.2.6 = 
     
    163166== Upgrade Notice == 
    164167 
     168= 2.2.6.1 = 
     169Fixed minor avatar issue, update not necessary unless you are experiencing problems. 
     170 
    165171= 2.2.6 = 
    166172Fixed minor issues, updated recommended. 
Note: See TracChangeset for help on using the changeset viewer.