Ticket #4571: 4571.01.patch
File 4571.01.patch, 5.0 KB (added by , 12 years ago) |
---|
-
bp-core/bp-core-avatars.php
function bp_core_set_avatar_constants() { 36 36 } 37 37 } 38 38 39 if ( !defined( 'BP_AVATAR_DEFAULT' ) )40 define( 'BP_AVATAR_DEFAULT', BP_PLUGIN_URL . 'bp-core/images/mystery-man.jpg' );41 42 if ( !defined( 'BP_AVATAR_DEFAULT_THUMB' ) )43 define( 'BP_AVATAR_DEFAULT_THUMB', BP_PLUGIN_URL . 'bp-core/images/mystery-man-50.jpg' );44 39 } 45 40 add_action( 'bp_init', 'bp_core_set_avatar_constants', 3 ); 46 41 … … function bp_core_set_avatar_globals() { 62 57 $bp->avatar->original_max_filesize = BP_AVATAR_ORIGINAL_MAX_FILESIZE; 63 58 64 59 // Defaults 65 $bp->avatar->thumb->default = BP_AVATAR_DEFAULT_THUMB;66 $bp->avatar->full->default = BP_AVATAR_DEFAULT;60 $bp->avatar->thumb->default = bp_core_avatar_default_thumb(); 61 $bp->avatar->full->default = bp_core_avatar_default(); 67 62 68 63 // These have to be set on page load in order to avoid infinite filter loops at runtime 69 $bp->avatar->upload_path = bp_core_avatar_upload_path();70 $bp->avatar->url = bp_core_avatar_url();64 $bp->avatar->upload_path = bp_core_avatar_upload_path(); 65 $bp->avatar->url = bp_core_avatar_url(); 71 66 72 67 // Backpat for pre-1.5 73 68 if ( ! defined( 'BP_AVATAR_UPLOAD_PATH' ) ) … … function bp_core_fetch_avatar( $args = '' ) { 341 336 if ( empty( $bp->grav_default->{$object} ) ) { 342 337 $default_grav = 'wavatar'; 343 338 } else if ( 'mystery' == $bp->grav_default->{$object} ) { 344 $default_grav = apply_filters( 'bp_core_mysteryman_src', bp_core_avatar_default(), $grav_size );339 $default_grav = apply_filters( 'bp_core_mysteryman_src', 'mm', $grav_size ); 345 340 } else { 346 341 $default_grav = $bp->grav_default->{$object}; 347 342 } … … function bp_core_fetch_avatar( $args = '' ) { 372 367 373 368 // No avatar was found, and we've been told not to use a gravatar. 374 369 } else { 375 $gravatar = apply_filters( "bp_core_default_avatar_$object", BP_PLUGIN_URL . 'bp-core/images/mystery-man.jpg', $params );370 $gravatar = apply_filters( "bp_core_default_avatar_$object", bp_core_avatar_default(), $params ); 376 371 } 377 372 378 373 if ( true === $html ) … … function bp_core_avatar_original_max_filesize() { 933 928 } 934 929 935 930 /** 936 * Get the default avatar 931 * Get the default avatar. 932 * 933 * Uses Gravatar's 'mystery-man' avatar. 934 * This is used if BP_AVATAR_DEFAULT is not defined. 937 935 * 938 936 * @package BuddyPress 939 937 * @since BuddyPress (1.5) … … function bp_core_avatar_original_max_filesize() { 941 939 * @return int The URL of the default avatar 942 940 */ 943 941 function bp_core_avatar_default() { 944 global $bp; 942 // check for our define first 943 if ( defined( 'BP_AVATAR_DEFAULT' ) ) { 944 $avatar = BP_AVATAR_DEFAULT; 945 945 946 return apply_filters( 'bp_core_avatar_default', $bp->avatar->full->default ); 946 // if no define, fallback to Gravatar's mystery man 947 } else { 948 if ( is_ssl() ) { 949 $host = 'http://secure.gravatar.com/'; 950 } else { 951 $host = 'http://www.gravatar.com/'; 952 } 953 954 // defaults to Gravatar's mystery man 955 $avatar = $host . 'avatar/00000000000000000000000000000000?d=mm&s=' . bp_core_avatar_full_width(); 956 } 957 958 // don't like this? use this hook to override 959 return apply_filters( 'bp_core_avatar_default', $avatar ); 947 960 } 948 961 949 962 /** 950 * Get the default avatar thumb 963 * Get the default avatar thumb. 964 * 965 * Uses Gravatar's 'mystery-man' avatar. 966 * This is used if BP_AVATAR_DEFAULT_THUMB is not defined. 951 967 * 952 968 * @package BuddyPress 953 969 * @since BuddyPress (1.5) … … function bp_core_avatar_default() { 955 971 * @return int The URL of the default avatar thumb 956 972 */ 957 973 function bp_core_avatar_default_thumb() { 958 global $bp; 974 // check for our define first 975 if ( defined( 'BP_AVATAR_DEFAULT_THUMB' ) ) { 976 $avatar = BP_AVATAR_DEFAULT_THUMB; 977 978 // if no define, fallback to Gravatar's mystery man 979 } else { 980 if ( is_ssl() ) { 981 $host = 'http://secure.gravatar.com/'; 982 } else { 983 $host = 'http://www.gravatar.com/'; 984 } 985 986 $avatar = $host . 'avatar/00000000000000000000000000000000?d=mm&s=' . bp_core_avatar_thumb_width(); 987 } 988 989 // don't like this? use this hook to override 990 return apply_filters( 'bp_core_avatar_thumb', $avatar ); 991 } 992 993 /** 994 * If BP_AVATAR_DEFAULT was defined, use it as the Gravatar default. 995 * 996 * In BuddyPress 1.7, due to changes to the default value of the 997 * 'bp_core_mysteryman_src' hook to 'mm', we need to be considerate to those 998 * that may have set a custom default avatar via BP_AVATAR_DEFAULT. 999 * 1000 * @since BuddyPress (1.7) 1001 */ 1002 function bp_core_avatar_mysteryman_src_backpat( $avatar ) { 1003 $default_avatar = bp_core_avatar_default(); 1004 1005 // check to see if bp_core_avatar_default() is not using gravatar 1006 // if so, return our custom default avatar 1007 if ( strpos( $default_avatar, 'gravatar' ) === false ) 1008 return $default_avatar; 959 1009 960 return apply_filters( 'bp_core_avatar_thumb', $bp->avatar->thumb->default );1010 return $avatar; 961 1011 } 1012 add_filter( 'bp_core_mysteryman_src', 'bp_core_avatar_mysteryman_src_backpat' );