Changeset 1943668
- Timestamp:
- 09/19/2018 01:32:44 PM (8 years ago)
- Location:
- wp-initials-avatar
- Files:
-
- 2 edited
- 4 copied
-
tags/0.9 (copied) (copied from wp-initials-avatar/trunk)
-
tags/0.9/options.php (copied) (copied from wp-initials-avatar/trunk/options.php)
-
tags/0.9/readme.txt (copied) (copied from wp-initials-avatar/trunk/readme.txt) (2 diffs)
-
tags/0.9/wordpress-initials-avatar.php (copied) (copied from wp-initials-avatar/trunk/wordpress-initials-avatar.php) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/wordpress-initials-avatar.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-initials-avatar/tags/0.9/readme.txt
r1933670 r1943668 3 3 Requires at least: 3.5 4 4 Requires PHP: 5.6 5 Stable tag: 0. 855 Stable tag: 0.9 6 6 License: MIT 7 7 License URI: https://opensource.org/licenses/MIT … … 25 25 26 26 == Changelog == 27 28 = 0.9 = 29 * Fixes and conflict handling (thanks mayukojpn - https://github.com/LasseRafn/wordpress-initials-avatar/pull/11) 27 30 28 31 = 0.85 = -
wp-initials-avatar/tags/0.9/wordpress-initials-avatar.php
r1933670 r1943668 5 5 Plugin URI: https://github.com/LasseRafn/wordpress-initials-avatar 6 6 Description: Replaces the default avatars with initials 7 Version: 0. 857 Version: 0.9 8 8 Author: lasserafn 9 9 Author URI: https://github.com/LasseRafn … … 44 44 add_filter( 'get_avatar_url', 'wordpress_initials_avatar', 10, 3 ); 45 45 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 */ 46 54 function 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) ) { 48 56 return $url; 49 57 } 50 58 51 59 $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 63 60 $name = 'initials'; 64 61 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 ) { 66 77 $name = get_comment_author( $id_or_email->ID ); 67 78 } -
wp-initials-avatar/trunk/readme.txt
r1933670 r1943668 3 3 Requires at least: 3.5 4 4 Requires PHP: 5.6 5 Stable tag: 0. 855 Stable tag: 0.9 6 6 License: MIT 7 7 License URI: https://opensource.org/licenses/MIT … … 25 25 26 26 == Changelog == 27 28 = 0.9 = 29 * Fixes and conflict handling (thanks mayukojpn - https://github.com/LasseRafn/wordpress-initials-avatar/pull/11) 27 30 28 31 = 0.85 = -
wp-initials-avatar/trunk/wordpress-initials-avatar.php
r1933670 r1943668 5 5 Plugin URI: https://github.com/LasseRafn/wordpress-initials-avatar 6 6 Description: Replaces the default avatars with initials 7 Version: 0. 857 Version: 0.9 8 8 Author: lasserafn 9 9 Author URI: https://github.com/LasseRafn … … 44 44 add_filter( 'get_avatar_url', 'wordpress_initials_avatar', 10, 3 ); 45 45 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 */ 46 54 function 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) ) { 48 56 return $url; 49 57 } 50 58 51 59 $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 63 60 $name = 'initials'; 64 61 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 ) { 66 77 $name = get_comment_author( $id_or_email->ID ); 67 78 }
Note: See TracChangeset
for help on using the changeset viewer.