Plugin Directory

Changeset 1943668


Ignore:
Timestamp:
09/19/2018 01:32:44 PM (8 years ago)
Author:
LasseRafn
Message:

Tagging version 0.9

Location:
wp-initials-avatar
Files:
2 edited
4 copied

Legend:

Unmodified
Added
Removed
  • wp-initials-avatar/tags/0.9/readme.txt

    r1933670 r1943668  
    33Requires at least: 3.5
    44Requires PHP: 5.6
    5 Stable tag: 0.85
     5Stable tag: 0.9
    66License: MIT
    77License URI: https://opensource.org/licenses/MIT
     
    2525
    2626== Changelog ==
     27
     28= 0.9 =
     29* Fixes and conflict handling (thanks mayukojpn - https://github.com/LasseRafn/wordpress-initials-avatar/pull/11)
    2730
    2831= 0.85 =
  • wp-initials-avatar/tags/0.9/wordpress-initials-avatar.php

    r1933670 r1943668  
    55Plugin URI: https://github.com/LasseRafn/wordpress-initials-avatar
    66Description: Replaces the default avatars with initials
    7 Version: 0.85
     7Version: 0.9
    88Author: lasserafn
    99Author URI: https://github.com/LasseRafn
     
    4444add_filter( 'get_avatar_url', 'wordpress_initials_avatar', 10, 3 );
    4545
     46/**
     47 * Filters the avatar URL.
     48 *
     49 * @param string $url         The URL of the avatar.
     50 * @param mixed  $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
     51 *                            user email, WP_User object, WP_Post object, or WP_Comment object.
     52 * @param array  $args        Arguments passed to get_avatar_data(), after processing.
     53 */
    4654function wordpress_initials_avatar( $url, $id_or_email, $args ) {
    47     if ( $args['default'] !== 'initials' && ( $args['force_default'] || false ) ) {
     55    if ( $args['default'] !== 'initials' && ( $args['force_default'] || false ) || !preg_match('/gravatar.com/', $url) ) {
    4856        return $url;
    4957    }
    5058
    5159    $user = false;
    52 
    53     if ( is_numeric( $id_or_email ) ) {
    54         $id   = (int) $id_or_email;
    55         $user = get_user_by( 'id', $id );
    56     } elseif ( is_object( $id_or_email && ! empty( $id_or_email->user_id ) ) ) {
    57         $id   = (int) $id_or_email->user_id;
    58         $user = get_user_by( 'id', $id );
    59     } else {
    60         $user = get_user_by( 'email', $id_or_email );
    61     }
    62 
    6360    $name = 'initials';
    6461
    65     if ( $id_or_email instanceof WP_Comment ) {
     62    if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) {
     63        $id_or_email = get_comment( $id_or_email );
     64    }
     65    // Process the user identifier.
     66    if ( is_numeric( $id_or_email ) ) {
     67        $user = get_user_by( 'id', absint( $id_or_email ) );
     68    } elseif ( is_string( $id_or_email ) ) {
     69        $user = get_user_by( 'email', $id_or_email );
     70    } elseif ( $id_or_email instanceof WP_User ) {
     71        // User Object
     72        $user = $id_or_email;
     73    } elseif ( $id_or_email instanceof WP_Post ) {
     74        // Post Object
     75        $user = get_user_by( 'id', (int) $id_or_email->post_author );
     76    } elseif ( $id_or_email instanceof WP_Comment ) {
    6677        $name = get_comment_author( $id_or_email->ID );
    6778    }
  • wp-initials-avatar/trunk/readme.txt

    r1933670 r1943668  
    33Requires at least: 3.5
    44Requires PHP: 5.6
    5 Stable tag: 0.85
     5Stable tag: 0.9
    66License: MIT
    77License URI: https://opensource.org/licenses/MIT
     
    2525
    2626== Changelog ==
     27
     28= 0.9 =
     29* Fixes and conflict handling (thanks mayukojpn - https://github.com/LasseRafn/wordpress-initials-avatar/pull/11)
    2730
    2831= 0.85 =
  • wp-initials-avatar/trunk/wordpress-initials-avatar.php

    r1933670 r1943668  
    55Plugin URI: https://github.com/LasseRafn/wordpress-initials-avatar
    66Description: Replaces the default avatars with initials
    7 Version: 0.85
     7Version: 0.9
    88Author: lasserafn
    99Author URI: https://github.com/LasseRafn
     
    4444add_filter( 'get_avatar_url', 'wordpress_initials_avatar', 10, 3 );
    4545
     46/**
     47 * Filters the avatar URL.
     48 *
     49 * @param string $url         The URL of the avatar.
     50 * @param mixed  $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
     51 *                            user email, WP_User object, WP_Post object, or WP_Comment object.
     52 * @param array  $args        Arguments passed to get_avatar_data(), after processing.
     53 */
    4654function wordpress_initials_avatar( $url, $id_or_email, $args ) {
    47     if ( $args['default'] !== 'initials' && ( $args['force_default'] || false ) ) {
     55    if ( $args['default'] !== 'initials' && ( $args['force_default'] || false ) || !preg_match('/gravatar.com/', $url) ) {
    4856        return $url;
    4957    }
    5058
    5159    $user = false;
    52 
    53     if ( is_numeric( $id_or_email ) ) {
    54         $id   = (int) $id_or_email;
    55         $user = get_user_by( 'id', $id );
    56     } elseif ( is_object( $id_or_email && ! empty( $id_or_email->user_id ) ) ) {
    57         $id   = (int) $id_or_email->user_id;
    58         $user = get_user_by( 'id', $id );
    59     } else {
    60         $user = get_user_by( 'email', $id_or_email );
    61     }
    62 
    6360    $name = 'initials';
    6461
    65     if ( $id_or_email instanceof WP_Comment ) {
     62    if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) {
     63        $id_or_email = get_comment( $id_or_email );
     64    }
     65    // Process the user identifier.
     66    if ( is_numeric( $id_or_email ) ) {
     67        $user = get_user_by( 'id', absint( $id_or_email ) );
     68    } elseif ( is_string( $id_or_email ) ) {
     69        $user = get_user_by( 'email', $id_or_email );
     70    } elseif ( $id_or_email instanceof WP_User ) {
     71        // User Object
     72        $user = $id_or_email;
     73    } elseif ( $id_or_email instanceof WP_Post ) {
     74        // Post Object
     75        $user = get_user_by( 'id', (int) $id_or_email->post_author );
     76    } elseif ( $id_or_email instanceof WP_Comment ) {
    6677        $name = get_comment_author( $id_or_email->ID );
    6778    }
Note: See TracChangeset for help on using the changeset viewer.