Plugin Directory

Changeset 1533113


Ignore:
Timestamp:
11/13/2016 01:16:40 AM (9 years ago)
Author:
Dev49.net
Message:

Version 2.2.7:

  • Added option to pass additional arguments to get_avatar() - thanks dpsjorge! (for developers only)
Location:
buddypress-first-letter-avatar
Files:
535 added
2 edited

Legend:

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

    r1459906 r1533113  
    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.2
     10 * Version: 2.2.7
    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
    14  * Requires at least: 4.5
    15  * Tested up to: 4.5.3
     14 * Requires at least: 4.6
     15 * Tested up to: 4.6.1
    1616 * Stable tag: trunk
    1717 * License: GPLv2 or later
     
    3232    // Setup:
    3333    const MINIMUM_PHP = '5.4';
    34     const MINIMUM_WP = '4.0';
     34    const MINIMUM_WP = '4.6';
    3535    const IMAGES_PATH = 'images'; // avatars root directory
    3636    const GRAVATAR_URL = 'https://secure.gravatar.com/avatar/'; // default url for gravatar
     
    106106
    107107        // add filter to get_avatar:
    108         add_filter('get_avatar', array($this, 'set_comment_avatar'), $this->filter_priority, 5); // this will only be used for anonymous WordPress comments (from non-users)
     108        add_filter('get_avatar', array($this, 'set_comment_avatar'), $this->filter_priority, 6); // this will only be used for anonymous WordPress comments (from non-users)
    109109
    110110        // add filter to bp_core_fetch_avatar:
     
    211211     * It returns a full HTML <img /> tag with avatar (first letter or Gravatar)
    212212     */
    213     public function set_comment_avatar($avatar, $id_or_email, $size = '96', $default = '', $alt = ''){
     213    public function set_comment_avatar($avatar, $id_or_email, $size = '96', $default = '', $alt = '', $args = array()){
    214214
    215215        // create two main variables:
     
    268268            }
    269269
    270         } else { // if it's a standard comment, use basic comment functions to retrive info
     270        } else { // if it's a standard comment, use basic comment functions to retrieve info
    271271
    272272            $comment = $id_or_email;
     
    305305        }
    306306
    307         $avatar_img_output = $this->generate_avatar_img_tag($avatar_uri, $size, $alt); // get final <img /> tag for the avatar/gravatar
     307        $avatar_img_output = $this->generate_avatar_img_tag($avatar_uri, $size, $alt, $args); // get final <img /> tag for the avatar/gravatar
    308308
    309309        return $avatar_img_output;
     
    518518     * Generate full HTML <img /> tag with avatar URL, size, CSS classes etc.
    519519     */
    520     private function generate_avatar_img_tag($avatar_uri, $size, $alt = ''){
     520    private function generate_avatar_img_tag($avatar_uri, $size, $alt = '', $args = array()){
     521
     522        // Default classes
     523        $css_classes = 'avatar avatar-' . $size . ' photo';
     524
     525        // Append plugin class
     526        $css_classes .= ' bpfla';
    521527
    522528        // prepare extra classes for <img> tag depending on plugin settings:
    523         $extra_img_class = '';
    524529        if ($this->round_avatars == true){
    525             $extra_img_class .= 'round-avatars';
    526         }
    527 
    528         $output_data = "<img alt='{$alt}' src='{$avatar_uri}' class='avatar avatar-{$size} photo bpfla {$extra_img_class}' width='{$size}' height='{$size}' />";
     530            $css_classes .= ' round-avatars';
     531        }
     532
     533        // Append extra classes
     534        if (array_key_exists('class', $args)) {
     535            if (is_array($args['class'])) {
     536                $css_classes .= ' ' . implode(' ', $args['class']);
     537            } else {
     538                $css_classes .= ' ' . $args['class'];
     539            }
     540        }
     541
     542        $output_data = "<img alt='{$alt}' src='{$avatar_uri}' class='{$css_classes}' width='{$size}' height='{$size}' />";
    529543
    530544        // return the complete <img> tag:
     
    602616                $charset_flag = 'arabic';
    603617            } else { // for some reason none of the charsets is appropriate
    604                 $file_name = $this->image_unknown; // set it to uknknown
     618                $file_name = $this->image_unknown; // set it to unknown
    605619            }
    606620
  • buddypress-first-letter-avatar/trunk/readme.txt

    r1459906 r1533113  
    11=== BuddyPress First Letter Avatar ===
    22Plugin Name: BuddyPress First Letter Avatar
    3 Version: 2.2.6.2
     3Version: 2.2.7
    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
    7 Requires at least: 4.5
    8 Tested up to: 4.5.3
     7Requires at least: 4.6
     8Tested up to: 4.6.1
    99Stable tag: trunk
    1010Author: Dev49.net
     
    8383== Changelog ==
    8484
     85= 2.2.7 =
     86* Added option to pass additional arguments to get_avatar() - thanks dpsjorge! (for developers only)
     87
    8588= 2.2.6.2 =
    8689* Fixed group avatars issue
     
    98101
    99102= 2.2.4 =
    100 * Added fallback for Polish letters (thanks Micha!)
     103* Added fallback for Polish letters (thanks Michal!)
    101104* Plugin prepared for translations (contributors are welcome!)
    102105
     
    169172== Upgrade Notice ==
    170173
     174= 2.2.7 =
     175Added new feature for developers, update not necessary.
     176
    171177= 2.2.6.2 =
    172178Fixed group avatars issue, update recommended.
Note: See TracChangeset for help on using the changeset viewer.