Changeset 13891 for trunk/src/bp-core/bp-core-avatars.php
- Timestamp:
- 06/02/2024 01:12:39 AM (5 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-avatars.php
r13890 r13891 56 56 $bp = buddypress(); 57 57 58 $bp->avatar = new stdClass ;59 $bp->avatar->thumb = new stdClass ;60 $bp->avatar->full = new stdClass ;58 $bp->avatar = new stdClass(); 59 $bp->avatar->thumb = new stdClass(); 60 $bp->avatar->full = new stdClass(); 61 61 62 62 // Dimensions. … … 76 76 // These have to be set on page load in order to avoid infinite filter loops at runtime. 77 77 $bp->avatar->upload_path = bp_core_avatar_upload_path(); 78 $bp->avatar->url = bp_core_avatar_url();78 $bp->avatar->url = bp_core_avatar_url(); 79 79 80 80 // Cache the root blog's show_avatars setting, to avoid unnecessary … … 83 83 84 84 // Backpat for pre-1.5. 85 if ( ! defined( 'BP_AVATAR_UPLOAD_PATH' ) ) 85 if ( ! defined( 'BP_AVATAR_UPLOAD_PATH' ) ) { 86 86 define( 'BP_AVATAR_UPLOAD_PATH', $bp->avatar->upload_path ); 87 } 87 88 88 89 // Backpat for pre-1.5. 89 if ( ! defined( 'BP_AVATAR_URL' ) ) 90 if ( ! defined( 'BP_AVATAR_URL' ) ) { 90 91 define( 'BP_AVATAR_URL', $bp->avatar->url ); 92 } 91 93 92 94 /** … … 112 114 } 113 115 114 /** this filter is documented in wp-admin/options-discussion.php */116 /** This filter is documented in wp-admin/options-discussion.php */ 115 117 $gravatar_defaults = apply_filters( 116 118 'avatar_defaults', … … 264 266 switch ( $params['object'] ) { 265 267 266 case 'blog' 268 case 'blog': 267 269 $params['item_id'] = get_current_blog_id(); 268 270 break; 269 271 270 case 'group' 272 case 'group': 271 273 if ( bp_is_active( 'groups' ) ) { 272 274 $params['item_id'] = $bp->groups->current_group->id; … … 277 279 break; 278 280 279 case 'user' 280 default 281 case 'user': 282 default: 281 283 $params['item_id'] = bp_displayed_user_id(); 282 284 break; … … 305 307 switch ( $params['object'] ) { 306 308 307 case 'blog' 309 case 'blog': 308 310 $params['avatar_dir'] = 'blog-avatars'; 309 311 break; 310 312 311 case 'group' 313 case 'group': 312 314 if ( bp_is_active( 'groups' ) ) { 313 315 $params['avatar_dir'] = 'group-avatars'; … … 318 320 break; 319 321 320 case 'user' 321 default 322 case 'user': 323 default: 322 324 $params['avatar_dir'] = 'avatars'; 323 325 break; … … 346 348 switch ( $params['object'] ) { 347 349 348 case 'blog' 350 case 'blog': 349 351 $item_name = get_blog_option( $params['item_id'], 'blogname' ); 350 352 break; 351 353 352 case 'group' 354 case 'group': 353 355 $item_name = bp_get_group_name( groups_get_group( $params['item_id'] ) ); 354 356 break; 355 357 356 case 'user' 357 default 358 case 'user': 359 default: 358 360 $item_name = bp_core_get_user_displayname( $params['item_id'] ); 359 361 break; … … 370 372 * @param array $params Array of parameters for the request. 371 373 */ 372 $item_name = apply_filters( 'bp_core_avatar_alt', $item_name, $params['item_id'], $params['object'], $params );374 $item_name = apply_filters( 'bp_core_avatar_alt', $item_name, $params['item_id'], $params['object'], $params ); 373 375 $params['alt'] = sprintf( $params['alt'], $item_name ); 374 376 } … … 429 431 if ( false !== $params['width'] ) { 430 432 // Width has been specified. No modification necessary. 431 } elseif ( 'thumb' == $params['type'] ) {433 } elseif ( 'thumb' === $params['type'] ) { 432 434 $params['width'] = bp_core_avatar_thumb_width(); 433 435 } else { … … 439 441 if ( false !== $params['height'] ) { 440 442 // Height has been specified. No modification necessary. 441 } elseif ( 'thumb' == $params['type'] ) {443 } elseif ( 'thumb' === $params['type'] ) { 442 444 $params['height'] = bp_core_avatar_thumb_height(); 443 445 } else { … … 467 469 468 470 // Merge classes. 469 $avatar_classes = array_merge( $avatar_classes, array( 470 $params['object'] . '-' . $params['item_id'] . '-avatar', 471 'avatar-' . $params['width'], 472 ) ); 471 $avatar_classes = array_merge( 472 $avatar_classes, 473 array( 474 $params['object'] . '-' . $params['item_id'] . '-avatar', 475 'avatar-' . $params['width'], 476 ) 477 ); 473 478 474 479 // Sanitize each class. … … 479 484 480 485 // Set img URL and DIR based on prepopulated constants. 481 $avatar_loc 482 $avatar_loc->path 483 $avatar_loc->url 484 485 $avatar_loc->dir 486 $avatar_loc = new stdClass(); 487 $avatar_loc->path = trailingslashit( bp_core_avatar_upload_path() ); 488 $avatar_loc->url = trailingslashit( bp_core_avatar_url() ); 489 490 $avatar_loc->dir = trailingslashit( $params['avatar_dir'] ); 486 491 487 492 /** … … 495 500 * @param string $value Subdirectory where the requested avatar should be found. 496 501 */ 497 $avatar_folder_url = apply_filters( 'bp_core_avatar_folder_url', ( $avatar_loc->url 502 $avatar_folder_url = apply_filters( 'bp_core_avatar_folder_url', ( $avatar_loc->url . $avatar_loc->dir . $params['item_id'] ), $params['item_id'], $params['object'], $params['avatar_dir'] ); 498 503 499 504 /** … … 514 519 * or thumbnail image. 515 520 */ 516 $avatar_size = ( 'full' == $params['type'] ) ? '-bpfull' : '-bpthumb';517 $legacy_user_avatar_name = ( 'full' == $params['type'] ) ? '-avatar2' : '-avatar1';518 $legacy_group_avatar_name = ( 'full' == $params['type'] ) ? '-groupavatar-full' : '-groupavatar-thumb';521 $avatar_size = ( 'full' === $params['type'] ) ? '-bpfull' : '-bpthumb'; 522 $legacy_user_avatar_name = ( 'full' === $params['type'] ) ? '-avatar2' : '-avatar1'; 523 $legacy_group_avatar_name = ( 'full' === $params['type'] ) ? '-groupavatar-full' : '-groupavatar-thumb'; 519 524 520 525 // Check for directory. … … 538 543 // Check for current avatar. 539 544 foreach ( $avatar_files as $key => $value ) { 540 if ( strpos ( $value, $avatar_size )!== false ) {541 $avatar_url = $avatar_folder_url . '/' . $avatar_files[ $key];545 if ( strpos( $value, $avatar_size ) !== false ) { 546 $avatar_url = $avatar_folder_url . '/' . $avatar_files[ $key ]; 542 547 } 543 548 } 544 549 545 550 // Legacy avatar check. 546 if ( ! isset( $avatar_url ) ) {551 if ( ! isset( $avatar_url ) ) { 547 552 foreach ( $avatar_files as $key => $value ) { 548 if ( strpos ( $value, $legacy_user_avatar_name )!== false ) {549 $avatar_url = $avatar_folder_url . '/' . $avatar_files[ $key];553 if ( strpos( $value, $legacy_user_avatar_name ) !== false ) { 554 $avatar_url = $avatar_folder_url . '/' . $avatar_files[ $key ]; 550 555 } 551 556 } 552 557 553 558 // Legacy group avatar check. 554 if ( ! isset( $avatar_url ) ) {559 if ( ! isset( $avatar_url ) ) { 555 560 foreach ( $avatar_files as $key => $value ) { 556 if ( strpos ( $value, $legacy_group_avatar_name )!== false ) {557 $avatar_url = $avatar_folder_url . '/' . $avatar_files[ $key];561 if ( strpos( $value, $legacy_group_avatar_name ) !== false ) { 562 $avatar_url = $avatar_folder_url . '/' . $avatar_files[ $key ]; 558 563 } 559 564 } … … 589 594 * @param string $avatar_folder_dir Avatar DIR path. 590 595 */ 591 return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $avatar_url . '"' . $html_class . $html_css_id 592 593 // ...or only the URL596 return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $avatar_url . '"' . $html_class . $html_css_id . $html_width . $html_height . $html_alt . $html_title . $extra_attr . ' />', $params, $params['item_id'], $params['avatar_dir'], $html_css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir ); 597 598 // ...or only the URL 594 599 } else { 595 600 … … 625 630 if ( empty( $bp->grav_default->{$params['object']} ) ) { 626 631 $default_grav = 'wavatar'; 627 } elseif ( 'mystery' == $bp->grav_default->{$params['object']} ) {632 } elseif ( 'mystery' === $bp->grav_default->{$params['object']} ) { 628 633 629 634 /** … … 642 647 // Set gravatar object. 643 648 if ( empty( $params['email'] ) ) { 644 if ( 'user' == $params['object'] ) {649 if ( 'user' === $params['object'] ) { 645 650 $params['email'] = bp_core_get_user_email( $params['item_id'] ); 646 } elseif ( 'group' == $params['object'] || 'blog'== $params['object'] ) {651 } elseif ( 'group' === $params['object'] || 'blog' === $params['object'] ) { 647 652 $params['email'] = $params['item_id'] . '-' . $params['object'] . '@' . bp_get_domain(); 648 653 } … … 670 675 671 676 // Append email hash to Gravatar. 672 $gravatar .= 677 $gravatar .= md5( strtolower( $params['email'] ) ); 673 678 674 679 // Main Gravatar URL args. 675 680 $url_args = array( 676 's' => $params['width'] 681 's' => $params['width'], 677 682 ); 678 683 … … 716 721 717 722 // Set up the Gravatar URL. 718 $gravatar = esc_url( add_query_arg( 719 rawurlencode_deep( array_filter( $url_args ) ), 720 $gravatar 721 ) ); 722 723 // No avatar was found, and we've been told not to use a gravatar. 723 $gravatar = esc_url( 724 add_query_arg( 725 rawurlencode_deep( array_filter( $url_args ) ), 726 $gravatar 727 ) 728 ); 729 730 // No avatar was found, and we've been told not to use a gravatar. 724 731 } else { 725 732 … … 771 778 'item_id' => false, 772 779 'object' => 'user', // User OR group OR blog OR custom type (if you use filters). 773 'avatar_dir' => false 780 'avatar_dir' => false, 774 781 ); 775 782 … … 851 858 if ( $av_dir = opendir( $avatar_folder_dir ) ) { 852 859 while ( false !== ( $avatar_file = readdir( $av_dir ) ) ) { 853 if ( ( preg_match( "/-bpfull/", $avatar_file ) || preg_match( "/-bpthumb/", $avatar_file ) ) && '.' != $avatar_file && '..' != $avatar_file ) {860 if ( ( preg_match( '/-bpfull/', $avatar_file ) || preg_match( '/-bpthumb/', $avatar_file ) ) && '.' !== $avatar_file && '..' !== $avatar_file ) { 854 861 @unlink( $avatar_folder_dir . '/' . $avatar_file ); 855 862 } … … 905 912 906 913 // Handle delete. 907 if ( bp_core_delete_existing_avatar( array( 'item_id' => $avatar_data['item_id'], 'object' => $avatar_data['object'] ) ) ) { 914 if ( bp_core_delete_existing_avatar( 915 array( 916 'item_id' => $avatar_data['item_id'], 917 'object' => $avatar_data['object'], 918 ) 919 ) ) { 908 920 $return = array( 909 'avatar' => esc_url( bp_core_fetch_avatar( array( 910 'object' => $avatar_data['object'], 911 'item_id' => $avatar_data['item_id'], 912 'html' => false, 913 'type' => 'full', 914 ) ) ), 921 'avatar' => esc_url( 922 bp_core_fetch_avatar( 923 array( 924 'object' => $avatar_data['object'], 925 'item_id' => $avatar_data['item_id'], 926 'html' => false, 927 'type' => 'full', 928 ) 929 ) 930 ), 915 931 'feedback_code' => 4, 916 932 'item_id' => $avatar_data['item_id'], … … 919 935 wp_send_json_success( $return ); 920 936 } else { 921 wp_send_json_error( array( 922 'feedback_code' => 3, 923 ) ); 937 wp_send_json_error( 938 array( 939 'feedback_code' => 3, 940 ) 941 ); 924 942 } 925 943 } … … 966 984 967 985 // Upload the file. 968 $avatar_attachment = new BP_Attachment_Avatar();986 $avatar_attachment = new BP_Attachment_Avatar(); 969 987 $bp->avatar_admin->original = $avatar_attachment->upload( $file, $upload_dir_filter ); 970 988 … … 1030 1048 * 1031 1049 * @since 2.3.0 1032 *1033 * @return string|null A JSON object containing success data if the upload succeeded1034 * error message otherwise.1035 1050 */ 1036 1051 function bp_avatar_ajax_upload() { 1052 1037 1053 if ( ! bp_is_post_request() ) { 1038 1054 wp_die(); … … 1044 1060 */ 1045 1061 $is_html4 = false; 1046 if ( ! empty( $_POST['html4' 1062 if ( ! empty( $_POST['html4'] ) ) { 1047 1063 $is_html4 = true; 1048 1064 } … … 1055 1071 1056 1072 // We need it to carry on. 1057 if ( ! empty( $_POST['bp_params' 1058 $bp_params = $_POST['bp_params' 1073 if ( ! empty( $_POST['bp_params'] ) ) { 1074 $bp_params = $_POST['bp_params']; 1059 1075 } else { 1060 1076 bp_attachments_json_response( false, $is_html4 ); … … 1071 1087 } 1072 1088 1073 $bp = buddypress();1089 $bp = buddypress(); 1074 1090 $bp_params['upload_dir_filter'] = ''; 1075 $needs_reset = array();1091 $needs_reset = array(); 1076 1092 1077 1093 if ( 'user' === $bp_params['object'] && bp_is_active( 'members' ) ) { … … 1079 1095 1080 1096 if ( ! bp_displayed_user_id() && ! empty( $bp_params['item_id'] ) ) { 1081 $needs_reset = array( 'key' => 'displayed_user', 'value' => $bp->displayed_user ); 1097 $needs_reset = array( 1098 'key' => 'displayed_user', 1099 'value' => $bp->displayed_user, 1100 ); 1082 1101 $bp->displayed_user->id = $bp_params['item_id']; 1083 1102 } … … 1086 1105 1087 1106 if ( ! bp_get_current_group_id() && ! empty( $bp_params['item_id'] ) ) { 1088 $needs_reset = array( 'component' => 'groups', 'key' => 'current_group', 'value' => $bp->groups->current_group ); 1107 $needs_reset = array( 1108 'component' => 'groups', 1109 'key' => 'current_group', 1110 'value' => $bp->groups->current_group, 1111 ); 1089 1112 $bp->groups->current_group = groups_get_group( $bp_params['item_id'] ); 1090 1113 } … … 1109 1132 */ 1110 1133 if ( isset( $bp_params['ui_available_width'] ) ) { 1111 $bp->avatar_admin->ui_available_width = 1134 $bp->avatar_admin->ui_available_width = (int) $bp_params['ui_available_width']; 1112 1135 } 1113 1136 … … 1148 1171 1149 1172 // Upload error reply. 1150 bp_attachments_json_response( false, $is_html4, array( 1151 'type' => 'upload_error', 1152 'message' => $message, 1153 ) ); 1173 bp_attachments_json_response( 1174 false, 1175 $is_html4, 1176 array( 1177 'type' => 'upload_error', 1178 'message' => $message, 1179 ) 1180 ); 1154 1181 } 1155 1182 … … 1161 1188 1162 1189 // Set the name of the file. 1163 $name = $_FILES['file']['name'];1190 $name = $_FILES['file']['name']; 1164 1191 $name_parts = pathinfo( $name ); 1165 $name = trim( substr( $name, 0, - ( 1 + strlen( $name_parts['extension'] ) ) ) );1192 $name = trim( substr( $name, 0, - ( 1 + strlen( $name_parts['extension'] ) ) ) ); 1166 1193 1167 1194 // Finally return the avatar to the editor. 1168 bp_attachments_json_response( true, $is_html4, array( 1169 'name' => $name, 1170 'url' => $bp->avatar_admin->image->url, 1171 'width' => $uploaded_image[0], 1172 'height' => $uploaded_image[1], 1173 'feedback' => $feedback_message, 1174 ) ); 1195 bp_attachments_json_response( 1196 true, 1197 $is_html4, 1198 array( 1199 'name' => $name, 1200 'url' => $bp->avatar_admin->image->url, 1201 'width' => $uploaded_image[0], 1202 'height' => $uploaded_image[1], 1203 'feedback' => $feedback_message, 1204 ) 1205 ); 1175 1206 } 1176 1207 add_action( 'wp_ajax_bp_avatar_upload', 'bp_avatar_ajax_upload' ); … … 1182 1213 * @since 10.0.0 Adds the `$return` param to eventually return the crop result. 1183 1214 * 1184 * @param string $data Base64 encoded image. 1185 * @param int $item_id Item to associate. 1186 * @param string $return Whether to get the crop `array` or a `boolean`. Defaults to `boolean`. 1187 * @return array|bool True on success, false on failure. 1188 */ 1189 function bp_avatar_handle_capture( $data = '', $item_id = 0, $return = 'boolean' ) { 1215 * @param string $data Optional. Base64 encoded image. 1216 * @param int $item_id Optional. Item to associate. 1217 * @param string $retval Optional. Whether to get the crop `array` or a `boolean`. Defaults to `boolean`. 1218 * @return array|bool 1219 */ 1220 function bp_avatar_handle_capture( $data = '', $item_id = 0, $retval = 'boolean' ) { 1221 $return = $retval; 1222 1190 1223 if ( empty( $data ) || empty( $item_id ) ) { 1191 1224 return false; … … 1229 1262 1230 1263 // It's not a regular upload, we may need to create this folder. 1231 if ( ! is_dir( $avatar_folder_dir ) ) {1264 if ( ! is_dir( $avatar_folder_dir ) ) { 1232 1265 if ( ! wp_mkdir_p( $avatar_folder_dir ) ) { 1233 1266 return false; … … 1241 1274 1242 1275 // Crop to default values. 1243 $crop_args = array( 'item_id' => $item_id, 'original_file' => $avatar_to_crop, 'crop_x' => 0, 'crop_y' => 0 ); 1276 $crop_args = array( 1277 'item_id' => $item_id, 1278 'original_file' => $avatar_to_crop, 1279 'crop_x' => 0, 1280 'crop_y' => 0, 1281 ); 1244 1282 1245 1283 if ( 'array' === $return ) { … … 1248 1286 1249 1287 return bp_core_avatar_handle_crop( $crop_args ); 1250 } else {1251 return false; 1252 }1288 } 1289 1290 return false; 1253 1291 } 1254 1292 … … 1276 1314 * @type int $crop_y The vertical starting point of the crop. Default: 0. 1277 1315 * } 1278 * @param string $ret urnWhether to get the crop `array` or a `boolean`. Defaults to `boolean`.1279 * @return array|bool True or the crop result on success, false on failure.1280 */ 1281 function bp_core_avatar_handle_crop( $args = '', $ret urn= 'boolean' ) {1316 * @param string $retval Optional. Whether to get the crop `array` or a `boolean`. Defaults to `boolean`. 1317 * @return array|bool 1318 */ 1319 function bp_core_avatar_handle_crop( $args = '', $retval = 'boolean' ) { 1282 1320 1283 1321 $r = bp_parse_args( … … 1318 1356 } 1319 1357 1320 if ( 'array' === $ret urn) {1358 if ( 'array' === $retval ) { 1321 1359 return $cropped; 1322 1360 } … … 1329 1367 * 1330 1368 * @since 2.3.0 1331 *1332 * @return string|null A JSON object containing success data if the crop/capture succeeded1333 * error message otherwise.1334 1369 */ 1335 1370 function bp_avatar_ajax_set() { 1371 1336 1372 if ( ! bp_is_post_request() ) { 1337 1373 wp_send_json_error(); … … 1371 1407 1372 1408 if ( ! $cropped_webcam_avatar ) { 1373 wp_send_json_error( array( 1374 'feedback_code' => 1 1375 ) ); 1409 wp_send_json_error( 1410 array( 1411 'feedback_code' => 1, 1412 ) 1413 ); 1376 1414 1377 1415 } else { 1378 1416 $return = array( 1379 'avatar' => esc_url(1417 'avatar' => esc_url( 1380 1418 bp_core_fetch_avatar( 1381 1419 array( … … 1419 1457 $avatar_dir = 'avatars'; 1420 1458 1421 // Defaults to object-avatars dir.1459 // Defaults to object-avatars dir. 1422 1460 } else { 1423 1461 $avatar_dir = sanitize_key( $avatar_data['object'] ) . '-avatars'; … … 1433 1471 'crop_h' => $avatar_data['crop_h'], 1434 1472 'crop_x' => $avatar_data['crop_x'], 1435 'crop_y' => $avatar_data['crop_y'] 1473 'crop_y' => $avatar_data['crop_y'], 1436 1474 ); 1437 1475 … … 1441 1479 if ( $cropped_avatar ) { 1442 1480 $return = array( 1443 'avatar' => esc_url(1481 'avatar' => esc_url( 1444 1482 bp_core_fetch_avatar( 1445 1483 array( … … 1468 1506 wp_send_json_success( $return ); 1469 1507 } else { 1470 wp_send_json_error( array( 1471 'feedback_code' => 1, 1472 ) ); 1508 wp_send_json_error( 1509 array( 1510 'feedback_code' => 1, 1511 ) 1512 ); 1473 1513 } 1474 1514 } … … 1493 1533 $user = get_user_by( 'id', absint( $id_or_email ) ); 1494 1534 } elseif ( $id_or_email instanceof WP_User ) { 1495 // User Object 1535 // User Object. 1496 1536 $user = $id_or_email; 1497 1537 } elseif ( $id_or_email instanceof WP_Post ) { 1498 // Post Object 1538 // Post Object. 1499 1539 $user = get_user_by( 'id', (int) $id_or_email->post_author ); 1500 1540 } elseif ( $id_or_email instanceof WP_Comment ) { … … 1521 1561 1522 1562 // Get the BuddyPress avatar URL. 1523 if ( $bp_avatar = bp_core_fetch_avatar( $args ) ) { 1563 $bp_avatar = bp_core_fetch_avatar( $args ); 1564 if ( $bp_avatar ) { 1524 1565 return $bp_avatar; 1525 1566 } … … 1535 1576 * 1536 1577 * @param array $file The $_FILES array. 1537 * @return bool True if no errors are found. False if there are errors.1578 * @return bool 1538 1579 */ 1539 1580 function bp_core_check_avatar_upload( $file ) { 1540 if ( isset( $file['error'] ) && $file['error'] ) 1581 if ( isset( $file['error'] ) && $file['error'] ) { 1541 1582 return false; 1583 } 1542 1584 1543 1585 return true; … … 1553 1595 */ 1554 1596 function bp_core_check_avatar_size( $file ) { 1555 if ( $file['file']['size'] > bp_core_avatar_original_max_filesize() ) 1597 if ( $file['file']['size'] > bp_core_avatar_original_max_filesize() ) { 1556 1598 return false; 1599 } 1557 1600 1558 1601 return true; … … 1595 1638 */ 1596 1639 function bp_core_get_allowed_avatar_mimes() { 1597 $allowed_types 1640 $allowed_types = bp_core_get_allowed_avatar_types(); 1598 1641 1599 1642 return bp_attachments_get_allowed_mimes( 'avatar', $allowed_types ); … … 1628 1671 1629 1672 switch ( $type ) { 1630 case 'upload_path' 1673 case 'upload_path': 1631 1674 $constant = 'BP_AVATAR_UPLOAD_PATH'; 1632 1675 $key = 'basedir'; … … 1634 1677 break; 1635 1678 1636 case 'url' 1679 case 'url': 1637 1680 $constant = 'BP_AVATAR_URL'; 1638 1681 $key = 'baseurl'; … … 1640 1683 break; 1641 1684 1642 default 1685 default: 1643 1686 return $retval; 1644 1645 break;1646 1687 } 1647 1688 … … 1659 1700 $upload_dir = $bp->avatar->upload_dir; 1660 1701 1661 // No cache, so query for it.1702 // No cache, so query for it. 1662 1703 } else { 1663 1704 … … 1702 1743 * @since 1.2.0 1703 1744 * 1704 * @param string $ valueAbsolute upload path for the WP installation.1745 * @param string $upload_path Absolute upload path for the WP installation. 1705 1746 */ 1706 1747 return apply_filters( 'bp_core_avatar_upload_path', bp_core_get_upload_dir() ); … … 1721 1762 * @since 1.2.0 1722 1763 * 1723 * @param string $ valueRaw base URL for the root site upload location.1764 * @param string $avatar_url Raw base URL for the root site upload location. 1724 1765 */ 1725 1766 return apply_filters( 'bp_core_avatar_url', bp_core_get_upload_dir( 'url' ) ); … … 1736 1777 function bp_get_user_has_avatar( $user_id = 0 ) { 1737 1778 1738 if ( empty( $user_id ) ) 1779 if ( empty( $user_id ) ) { 1739 1780 $user_id = bp_displayed_user_id(); 1781 } 1740 1782 1741 1783 $retval = false; 1742 if ( bp_core_fetch_avatar( array( 'item_id' => $user_id, 'no_grav' => true, 'html' => false, 'type' => 'full' ) ) != bp_core_avatar_default( 'local' ) ) 1784 if ( bp_core_fetch_avatar( 1785 array( 1786 'item_id' => $user_id, 1787 'no_grav' => true, 1788 'html' => false, 1789 'type' => 'full', 1790 ) 1791 ) !== bp_core_avatar_default( 'local' ) ) { 1743 1792 $retval = true; 1793 } 1744 1794 1745 1795 /** … … 1795 1845 * @since 1.5.0 1796 1846 * 1797 * @param int $ valueValue for the 'thumb' avatar width setting.1847 * @param int $avatar_thumb_width Value for the 'thumb' avatar width setting. 1798 1848 */ 1799 1849 return apply_filters( 'bp_core_avatar_thumb_width', bp_core_avatar_dimension( 'thumb', 'width' ) ); … … 1814 1864 * @since 1.5.0 1815 1865 * 1816 * @param int $ valueValue for the 'thumb' avatar height setting.1866 * @param int $avatar_thumb_height Value for the 'thumb' avatar height setting. 1817 1867 */ 1818 1868 return apply_filters( 'bp_core_avatar_thumb_height', bp_core_avatar_dimension( 'thumb', 'height' ) ); … … 1833 1883 * @since 1.5.0 1834 1884 * 1835 * @param int $ valueValue for the 'full' avatar width setting.1885 * @param int $avatar_full_width Value for the 'full' avatar width setting. 1836 1886 */ 1837 1887 return apply_filters( 'bp_core_avatar_full_width', bp_core_avatar_dimension( 'full', 'width' ) ); … … 1852 1902 * @since 1.5.0 1853 1903 * 1854 * @param int $ valueValue for the 'full' avatar height setting.1904 * @param int $avatar_full_height Value for the 'full' avatar height setting. 1855 1905 */ 1856 1906 return apply_filters( 'bp_core_avatar_full_height', bp_core_avatar_dimension( 'full', 'height' ) ); … … 1871 1921 * @since 1.5.0 1872 1922 * 1873 * @param int $ valueValue for the max width.1923 * @param int $original_max_width Value for the max width. 1874 1924 */ 1875 1925 return apply_filters( 'bp_core_avatar_original_max_width', (int) buddypress()->avatar->original_max_width ); … … 1890 1940 * @since 1.5.0 1891 1941 * 1892 * @param int $ value Value for the max filesize.1942 * @param int $original_max_filesize Value for the max filesize. 1893 1943 */ 1894 1944 return apply_filters( 'bp_core_avatar_original_max_filesize', (int) buddypress()->avatar->original_max_filesize ); … … 1912 1962 $avatar = BP_AVATAR_DEFAULT; 1913 1963 1914 // Use the local default image.1964 // Use the local default image. 1915 1965 } elseif ( 'local' === $type ) { 1916 1966 $size = ''; … … 1919 1969 ( isset( $params['width'] ) && $params['width'] <= 50 ) 1920 1970 ) { 1921 1922 1971 $size = '-50'; 1923 1972 } … … 1925 1974 $avatar = buddypress()->plugin_url . "bp-core/images/mystery-man{$size}.jpg"; 1926 1975 1927 // Use Gravatar's mystery person as fallback.1976 // Use Gravatar's mystery person as fallback. 1928 1977 } else { 1929 1978 $size = ''; … … 1982 2031 $avatar = BP_AVATAR_DEFAULT_THUMB; 1983 2032 1984 // Use the local default image.2033 // Use the local default image. 1985 2034 } elseif ( 'local' === $type ) { 1986 2035 $avatar = buddypress()->plugin_url . 'bp-core/images/mystery-man-50.jpg'; 1987 2036 1988 // Use Gravatar's mystery person as fallback.2037 // Use Gravatar's mystery person as fallback. 1989 2038 } else { 1990 2039 $avatar = '//www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&s=' . bp_core_avatar_thumb_width(); … … 2021 2070 $reset_w = bp_is_group_admin_screen( 'group-avatar' ); 2022 2071 2023 // Group's avatar create screen.2072 // Group's avatar create screen. 2024 2073 } elseif ( bp_is_group_create() ) { 2025 2074 /** … … 2029 2078 $reset_w = 'group-avatar' === bp_action_variable( 1 ); 2030 2079 2031 // User's change avatar screen.2080 // User's change avatar screen. 2032 2081 } else { 2033 2082 $reset_w = bp_is_user_change_avatar(); … … 2060 2109 $retval = ! bp_disable_group_avatar_uploads(); 2061 2110 2062 // Group Manage.2111 // Group Manage. 2063 2112 } elseif ( bp_is_group_admin_page() && bp_is_group_admin_screen( 'group-avatar' ) && 'crop-image' !== bp_get_avatar_admin_step() ) { 2064 2113 $retval = ! bp_disable_group_avatar_uploads(); … … 2164 2213 * @since 10.0.0 2165 2214 * 2166 * @param bool $ valueTrue to disable avatar history. False otherwise.2215 * @param bool $avatar_history True to disable avatar history. False otherwise. 2167 2216 * Default: `false`. 2168 2217 */ … … 2235 2284 2236 2285 $avatars = array(); 2237 $history_url = trailingslashit( bp_core_avatar_url() ) . 2286 $history_url = trailingslashit( bp_core_avatar_url() ) . $avatar_dir . '/' . $item_id . '/history'; 2238 2287 2239 2288 foreach ( $historic_avatars as $historic_avatar ) { … … 2318 2367 } 2319 2368 2320 $is_full = preg_match( "/-bpfull/", $current_avatar->name );2321 $is_thumb = preg_match( "/-bpthumb/", $current_avatar->name );2369 $is_full = preg_match( '/-bpfull/', $current_avatar->name ); 2370 $is_thumb = preg_match( '/-bpthumb/', $current_avatar->name ); 2322 2371 2323 2372 if ( $is_full || $is_thumb ) { … … 2395 2444 } else { 2396 2445 foreach ( $avatar_types as $type_key => $avatar_path ) { 2397 $filename = wp_basename( $avatar_path );2398 $avatar_id = pathinfo( $filename, PATHINFO_FILENAME );2446 $filename = wp_basename( $avatar_path ); 2447 $avatar_id = pathinfo( $filename, PATHINFO_FILENAME ); 2399 2448 $recycle_path = $avatar_dir_path . '/' . str_replace( $avatar_id, $recycle_timestamp . '-bp' . $type_key, $filename ); 2400 2449 … … 2470 2519 $gmdate = gmdate( 'Y-m-d H:i:s', $avatars_history[ $latest_id ]->last_modified ); 2471 2520 $date = strtotime( get_date_from_gmt( $gmdate ) ); 2472 $history_url = trailingslashit( bp_core_avatar_url() ) . 2521 $history_url = trailingslashit( bp_core_avatar_url() ) . $avatar_dir . '/' . $item_id . '/history'; 2473 2522 2474 2523 // Prepare the avatar object for JavaScript.
Note: See TracChangeset
for help on using the changeset viewer.