Changeset 13891
- Timestamp:
- 06/02/2024 01:12:39 AM (4 months ago)
- Location:
- trunk/src/bp-core
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-adminbar.php
r13741 r13891 32 32 33 33 // Add secondary parent item for all BuddyPress components. 34 $wp_admin_bar->add_node( array( 35 'parent' => 'my-account', 36 'id' => 'my-account-buddypress', 37 'title' => __( 'My Account', 'buddypress' ), 38 'group' => true, 39 'meta' => array( 40 'class' => 'ab-sub-secondary' 34 $wp_admin_bar->add_node( 35 array( 36 'parent' => 'my-account', 37 'id' => 'my-account-buddypress', 38 'title' => __( 'My Account', 'buddypress' ), 39 'group' => true, 40 'meta' => array( 41 'class' => 'ab-sub-secondary', 42 ), 41 43 ) 42 ) );44 ); 43 45 } 44 46 } … … 52 54 function bp_core_load_admin_bar() { 53 55 // Show the Toolbar for logged out users. 54 if ( ! is_user_logged_in() && (int) bp_get_option( 'hide-loggedout-adminbar' ) != 1 ) {56 if ( ! is_user_logged_in() && (int) bp_get_option( 'hide-loggedout-adminbar' ) !== 1 ) { 55 57 show_admin_bar( true ); 56 58 } … … 68 70 */ 69 71 function bp_core_load_admin_bar_css() { 70 add_action( 'bp_enqueue_scripts', 72 add_action( 'bp_enqueue_scripts', 'bp_core_enqueue_admin_bar_css', 1 ); 71 73 add_action( 'bp_admin_enqueue_scripts', 'bp_core_enqueue_admin_bar_css', 1 ); 72 74 } -
trunk/src/bp-core/bp-core-attachments.php
r13890 r13891 74 74 * @since 3.0.0 75 75 * 76 * @return array See wp_upload_dir(). 76 * @param array $args { 77 * @type int $object_id The ID of the object (Required). 78 * @type string $object_directory The object directory (eg: members, groups) (Required). 79 * } 80 * @return array 77 81 */ 78 82 function bp_attachments_cover_image_upload_dir( $args = array() ) { … … 102 106 103 107 // Set the subdir. 104 $subdir 108 $subdir = '/' . $r['object_directory'] . '/' . $r['object_id'] . '/cover-image'; 105 109 106 110 $upload_dir = bp_attachments_uploads_dir_get(); … … 111 115 * @since 2.4.0 112 116 * 113 * @param array $ valueArray containing the path, URL, and other helpful settings.114 * @param array $upload_dir The original Uploads dir.117 * @param array $image_upload_data Array containing the path, URL, and other helpful settings. 118 * @param array $upload_dir The original Uploads dir. 115 119 */ 116 return apply_filters( 'bp_attachments_cover_image_upload_dir', array( 117 'path' => $upload_dir['basedir'] . $subdir, 118 'url' => set_url_scheme( $upload_dir['baseurl'] ) . $subdir, 119 'subdir' => $subdir, 120 'basedir' => $upload_dir['basedir'], 121 'baseurl' => set_url_scheme( $upload_dir['baseurl'] ), 122 'error' => false, 123 ), $upload_dir ); 120 return apply_filters( 121 'bp_attachments_cover_image_upload_dir', 122 array( 123 'path' => $upload_dir['basedir'] . $subdir, 124 'url' => set_url_scheme( $upload_dir['baseurl'] ) . $subdir, 125 'subdir' => $subdir, 126 'basedir' => $upload_dir['basedir'], 127 'baseurl' => set_url_scheme( $upload_dir['baseurl'] ), 128 'error' => false, 129 ), 130 $upload_dir 131 ); 124 132 } 125 133 … … 197 205 // Loop to explode keys using '|'. 198 206 foreach ( $allowed_types as $allowed_type ) { 199 $t = explode( '|', $allowed_type );207 $t = explode( '|', $allowed_type ); 200 208 $exts = array_merge( $exts, (array) $t ); 201 209 } … … 417 425 'crop_h' => $r['crop_h'], 418 426 'crop_x' => $r['crop_x'], 419 'crop_y' => $r['crop_y'] 427 'crop_y' => $r['crop_y'], 420 428 ) 421 429 ); 422 430 423 // It's a cover image we need to fit it to feature's dimensions.431 // It's a cover image we need to fit it to feature's dimensions. 424 432 } elseif ( 'cover_image' === $type ) { 425 433 $cover_image = bp_attachments_cover_image_generate_file( … … 427 435 'file' => $image_file_path, 428 436 'component' => $r['component'], 429 'cover_image_dir' => $attachment_data['path'] 437 'cover_image_dir' => $attachment_data['path'], 430 438 ) 431 439 ); … … 520 528 $attachment_data = trailingslashit( $type_dir ) . $r['file']; 521 529 } 522 523 530 } else { 524 531 $file = false; 525 532 526 533 // Open the directory and get the first file. 527 if ( $att_dir = opendir( $type_dir ) ) { 534 $att_dir = opendir( $type_dir ); 535 if ( $att_dir ) { 528 536 529 537 while ( false !== ( $attachment_file = readdir( $att_dir ) ) ) { … … 604 612 'file_data_name' => 'file', 605 613 'multipart_params' => array( 606 'action' 607 '_wpnonce' 614 'action' => 'bp_upload_attachment', 615 '_wpnonce' => wp_create_nonce( 'bp-uploader' ), 608 616 ), 609 617 'url' => admin_url( 'admin-ajax.php', 'relative' ), 610 618 'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ), 611 619 'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ), 612 'filters' => array(613 'max_file_size' 620 'filters' => array( 621 'max_file_size' => $max_upload_size . 'b', 614 622 ), 615 623 'multipart' => true, … … 625 633 626 634 $settings = array( 627 'defaults' => $defaults,628 'browser' => array(635 'defaults' => $defaults, 636 'browser' => array( 629 637 'mobile' => wp_is_mobile(), 630 638 'supported' => _device_can_upload(), … … 692 700 /* translators: %s: File name. */ 693 701 'error_uploading' => __( '“%s” has failed to upload.', 'buddypress' ), 694 'has_avatar_warning' => __( 'If you'd like to delete the existing profile photo but not upload a new one, please use the delete tab.', 'buddypress' ) 702 'has_avatar_warning' => __( 'If you'd like to delete the existing profile photo but not upload a new one, please use the delete tab.', 'buddypress' ), 695 703 ) 696 704 ); … … 705 713 * to set specific script data. 706 714 * 707 * @param string $class Name of the class extending BP_Attachment (eg: BP_Attachment_Avatar).715 * @param string $class_name Name of the class extending BP_Attachment (eg: BP_Attachment_Avatar). 708 716 * @return null|WP_Error 709 717 */ 710 function bp_attachments_enqueue_scripts( $class = '' ) { 718 function bp_attachments_enqueue_scripts( $class_name = '' ) { 719 $class = $class_name; 720 711 721 // Enqueue me just once per page, please. 712 722 if ( did_action( 'bp_attachments_enqueue_scripts' ) ) { … … 719 729 720 730 // Get an instance of the class and get the script data. 721 $attachment = new $class ;731 $attachment = new $class(); 722 732 $script_data = $attachment->script_data(); 723 733 … … 766 776 767 777 // Merge other arguments. 768 $ui_args = array_intersect_key( $args, array( 769 'file_data_name' => true, 770 'browse_button' => true, 771 'container' => true, 772 'drop_element' => true, 773 ) ); 778 $ui_args = array_intersect_key( 779 $args, 780 array( 781 'file_data_name' => true, 782 'browse_button' => true, 783 'container' => true, 784 'drop_element' => true, 785 ) 786 ); 774 787 775 788 $defaults = array_merge( $defaults, $ui_args ); … … 780 793 781 794 if ( isset( $args['mime_types'] ) && $args['mime_types'] ) { 782 $defaults['filters']['mime_types'] = 795 $defaults['filters']['mime_types'] = array( array( 'extensions' => $args['mime_types'] ) ); 783 796 } 784 797 … … 793 806 // Include the cropping informations for avatars. 794 807 $settings['crop'] = array( 795 'full_h' 796 'full_w' 808 'full_h' => bp_core_avatar_full_height(), 809 'full_w' => bp_core_avatar_full_width(), 797 810 ); 798 811 … … 811 824 // Init the Avatar nav. 812 825 $avatar_nav = array( 813 'upload' 826 'upload' => array( 814 827 'id' => 'upload', 815 828 'caption' => __( 'Upload', 'buddypress' ), 816 'order' => 0 829 'order' => 0, 817 830 ), 818 'delete' 831 'delete' => array( 819 832 'id' => 'delete', 820 833 'caption' => __( 'Delete', 'buddypress' ), 821 834 'order' => 100, 822 'hide' => (int) ! $has_avatar 835 'hide' => (int) ! $has_avatar, 823 836 ), 824 837 ); … … 851 864 'id' => 'camera', 852 865 'caption' => __( 'Take Photo', 'buddypress' ), 853 'order' => 10 866 'order' => 10, 854 867 ); 855 868 856 869 // Set warning messages. 857 870 $strings['camera_warnings'] = array( 858 'requesting' => __( 'Please allow us to access to your camera.', 'buddypress'),859 'loading' 860 'loaded' 861 'noaccess' 862 'errormsg' 863 'videoerror' 864 'ready' 865 'nocapture' 871 'requesting' => __( 'Please allow us to access to your camera.', 'buddypress' ), 872 'loading' => __( 'Please wait as we access your camera.', 'buddypress' ), 873 'loaded' => __( 'Camera loaded. Click on the "Capture" button to take your photo.', 'buddypress' ), 874 'noaccess' => __( 'It looks like you do not have a webcam or we were unable to get permission to use your webcam. Please upload a photo instead.', 'buddypress' ), 875 'errormsg' => __( 'Your browser is not supported. Please upload a photo instead.', 'buddypress' ), 876 'videoerror' => __( 'Video error. Please upload a photo instead.', 'buddypress' ), 877 'ready' => __( 'Your profile photo is ready. Click on the "Save" button to use this photo.', 'buddypress' ), 878 'nocapture' => __( 'No photo was captured. Click on the "Capture" button to take your photo.', 'buddypress' ), 866 879 ); 867 880 } … … 886 899 $settings['nav'] = bp_sort_by_key( apply_filters( 'bp_attachments_avatar_nav', $avatar_nav, $object ), 'order', 'num' ); 887 900 888 // Specific to BuddyPress cover images.901 // Specific to BuddyPress cover images. 889 902 } elseif ( 'bp_cover_image_upload' === $defaults['multipart_params']['action'] ) { 890 903 … … 908 921 909 922 // Set warning messages. 910 $strings['cover_image_warnings'] = apply_filters( 'bp_attachments_cover_image_ui_warnings', array( 911 'dimensions' => sprintf( 912 /* translators: 1: the advised width size in pixels. 2: the advised height size in pixels. */ 913 __( 'For better results, make sure to upload an image that is larger than %1$spx wide, and %2$spx tall.', 'buddypress' ), 914 (int) $cover_dimensions['width'], 915 (int) $cover_dimensions['height'] 916 ), 917 ) ); 923 $strings['cover_image_warnings'] = apply_filters( 924 'bp_attachments_cover_image_ui_warnings', 925 array( 926 'dimensions' => sprintf( 927 /* translators: 1: the advised width size in pixels. 2: the advised height size in pixels. */ 928 __( 'For better results, make sure to upload an image that is larger than %1$spx wide, and %2$spx tall.', 'buddypress' ), 929 (int) $cover_dimensions['width'], 930 (int) $cover_dimensions['height'] 931 ), 932 ) 933 ); 918 934 } 919 935 … … 936 952 } 937 953 938 wp_enqueue_script ( 'bp-plupload' ); 939 wp_localize_script( 'bp-plupload', 'BP_Uploader', array( 'strings' => $strings, 'settings' => $settings ) ); 954 wp_enqueue_script( 'bp-plupload' ); 955 wp_localize_script( 956 'bp-plupload', 957 'BP_Uploader', 958 array( 959 'strings' => $strings, 960 'settings' => $settings, 961 ) 962 ); 940 963 941 964 /** … … 987 1010 $can = (bool) groups_is_user_admin( bp_loggedin_user_id(), $args['item_id'] ) || bp_current_user_can( 'bp_moderate' ); 988 1011 } 989 // User profile photo.1012 // User profile photo. 990 1013 } elseif ( bp_is_active( 'members' ) && 'user' === $args['object'] ) { 991 1014 $can = bp_loggedin_user_id() === (int) $args['item_id'] || bp_current_user_can( 'bp_moderate' ); 992 1015 } 993 /** 994 * No avatar arguments, fallback to bp_user_can_create_groups() 995 * or bp_is_item_admin() 996 */ 1016 /** 1017 * No avatar arguments, fallback to bp_user_can_create_groups() 1018 * or bp_is_item_admin() 1019 */ 1020 } elseif ( bp_is_group_create() ) { 1021 $can = bp_user_can_create_groups(); 997 1022 } else { 998 if ( bp_is_group_create() ) { 999 $can = bp_user_can_create_groups(); 1000 } else { 1001 $can = bp_is_item_admin(); 1002 } 1023 $can = bp_is_item_admin(); 1003 1024 } 1004 1025 } … … 1027 1048 wp_send_json( $response ); 1028 1049 1029 /**1030 * Send specific json response1031 * the html4 Plupload handler requires a text/html content-type for older IE.1032 * See https://core.trac.wordpress.org/ticket/310371033 */1050 /** 1051 * Send specific json response 1052 * the html4 Plupload handler requires a text/html content-type for older IE. 1053 * See https://core.trac.wordpress.org/ticket/31037 1054 */ 1034 1055 } else { 1035 1056 echo wp_json_encode( $response ); … … 1045 1066 * 1046 1067 * @param string $slug Template part slug. eg 'uploader' for 'uploader.php'. 1047 * @return bool1048 1068 */ 1049 1069 function bp_attachments_get_template_part( $slug ) { … … 1137 1157 1138 1158 // Current component is not supported. 1139 if ( ! in_array( $component, $settings['components'] ) ) {1159 if ( ! in_array( $component, $settings['components'], true ) ) { 1140 1160 return false; 1141 1161 } … … 1155 1175 function bp_attachments_get_cover_image_dimensions( $component = 'members' ) { 1156 1176 // Let's prevent notices when setting the warning strings. 1157 $default = array( 'width' => 0, 'height' => 0 ); 1177 $default = array( 1178 'width' => 0, 1179 'height' => 0, 1180 ); 1158 1181 1159 1182 $settings = bp_attachments_get_cover_image_settings( $component ); … … 1201 1224 } 1202 1225 1203 if ( ( bp_is_group_admin_page() && 'group-cover-image' == bp_get_group_current_admin_tab() )1226 if ( ( bp_is_group_admin_page() && 'group-cover-image' === bp_get_group_current_admin_tab() ) 1204 1227 || ( bp_is_group_create() && bp_is_group_creation_step( 'group-cover-image' ) ) ) { 1205 1228 $retval = ! bp_disable_group_cover_image_uploads(); … … 1222 1245 } 1223 1246 1224 $cover_src = bp_attachments_get_attachment( 'url', array( 1225 'item_id' => $user_id, 1226 ) ); 1247 $cover_src = bp_attachments_get_attachment( 1248 'url', 1249 array( 1250 'item_id' => $user_id, 1251 ) 1252 ); 1227 1253 1228 1254 return (bool) apply_filters( 'bp_attachments_get_user_has_cover_image', $cover_src, $user_id ); … … 1243 1269 } 1244 1270 1245 $cover_src = bp_attachments_get_attachment( 'url', array( 1246 'object_dir' => 'groups', 1247 'item_id' => $group_id, 1248 ) ); 1271 $cover_src = bp_attachments_get_attachment( 1272 'url', 1273 array( 1274 'object_dir' => 'groups', 1275 'item_id' => $group_id, 1276 ) 1277 ); 1249 1278 1250 1279 return (bool) apply_filters( 'bp_attachments_get_group_has_cover_image', $cover_src, $group_id ); … … 1330 1359 'cover_file' => $cover_file, 1331 1360 'cover_basename' => $cover_basename, 1332 'is_too_small' => $is_too_small 1361 'is_too_small' => $is_too_small, 1333 1362 ); 1334 1363 } … … 1338 1367 * 1339 1368 * @since 2.4.0 1340 *1341 * @return string|null A json object containing success data if the upload succeeded,1342 * error message otherwise.1343 1369 */ 1344 1370 function bp_attachments_cover_image_ajax_upload() { 1371 1345 1372 if ( ! bp_is_post_request() ) { 1346 1373 wp_die(); … … 1350 1377 1351 1378 // Sending the json response will be different if the current Plupload runtime is html4. 1352 $is_html4 = ! empty( $_POST['html4' 1379 $is_html4 = ! empty( $_POST['html4'] ); 1353 1380 1354 1381 if ( empty( $_POST['bp_params'] ) ) { … … 1383 1410 // Member's cover image. 1384 1411 if ( 'user' === $bp_params['object'] ) { 1385 $object_data = array( 'dir' => 'members', 'component' => 'members' ); 1412 $object_data = array( 1413 'dir' => 'members', 1414 'component' => 'members', 1415 ); 1386 1416 1387 1417 if ( ! bp_displayed_user_id() && ! empty( $bp_params['item_id'] ) ) { 1388 $needs_reset = array( 'key' => 'displayed_user', 'value' => $bp->displayed_user ); 1418 $needs_reset = array( 1419 'key' => 'displayed_user', 1420 'value' => $bp->displayed_user, 1421 ); 1389 1422 $bp->displayed_user->id = $bp_params['item_id']; 1390 1423 } 1391 1424 1392 // Group's cover image.1425 // Group's cover image. 1393 1426 } elseif ( 'group' === $bp_params['object'] ) { 1394 $object_data = array( 'dir' => 'groups', 'component' => 'groups' ); 1427 $object_data = array( 1428 'dir' => 'groups', 1429 'component' => 'groups', 1430 ); 1395 1431 1396 1432 if ( ! bp_get_current_group_id() && ! empty( $bp_params['item_id'] ) ) { 1397 $needs_reset = array( 'component' => 'groups', 'key' => 'current_group', 'value' => $bp->groups->current_group ); 1433 $needs_reset = array( 1434 'component' => 'groups', 1435 'key' => 'current_group', 1436 'value' => $bp->groups->current_group, 1437 ); 1398 1438 $bp->groups->current_group = groups_get_group( $bp_params['item_id'] ); 1399 1439 } 1400 1440 1401 // Other object's cover image.1441 // Other object's cover image. 1402 1442 } else { 1403 1443 $object_data = apply_filters( 'bp_attachments_cover_image_object_dir', array(), $bp_params['object'] ); … … 1427 1467 1428 1468 $cover_image_attachment = new BP_Attachment_Cover_Image(); 1429 $uploaded = $cover_image_attachment->upload( $_FILES );1469 $uploaded = $cover_image_attachment->upload( $_FILES ); 1430 1470 1431 1471 // Reset objects. … … 1440 1480 if ( ! empty( $uploaded['error'] ) ) { 1441 1481 // Upload error response. 1442 bp_attachments_json_response( false, $is_html4, array( 1443 'type' => 'upload_error', 1444 'message' => sprintf( 1445 /* translators: %s: the upload error message */ 1446 __( 'Upload Failed! Error was: %s', 'buddypress' ), 1447 $uploaded['error'] 1448 ), 1449 ) ); 1482 bp_attachments_json_response( 1483 false, 1484 $is_html4, 1485 array( 1486 'type' => 'upload_error', 1487 'message' => sprintf( 1488 /* translators: %s: the upload error message */ 1489 __( 'Upload Failed! Error was: %s', 'buddypress' ), 1490 $uploaded['error'] 1491 ), 1492 ) 1493 ); 1450 1494 } 1451 1495 … … 1456 1500 // The BP Attachments Uploads Dir is not set, stop. 1457 1501 if ( ! $bp_attachments_uploads_dir ) { 1458 bp_attachments_json_response( false, $is_html4, array( 1459 'type' => 'upload_error', 1460 'message' => $error_message, 1461 ) ); 1502 bp_attachments_json_response( 1503 false, 1504 $is_html4, 1505 array( 1506 'type' => 'upload_error', 1507 'message' => $error_message, 1508 ) 1509 ); 1462 1510 } 1463 1511 … … 1467 1515 if ( 1 === validate_file( $cover_dir ) || ! is_dir( $cover_dir ) ) { 1468 1516 // Upload error response. 1469 bp_attachments_json_response( false, $is_html4, array( 1470 'type' => 'upload_error', 1471 'message' => $error_message, 1472 ) ); 1517 bp_attachments_json_response( 1518 false, 1519 $is_html4, 1520 array( 1521 'type' => 'upload_error', 1522 'message' => $error_message, 1523 ) 1524 ); 1473 1525 } 1474 1526 … … 1480 1532 * class, let's use it. 1481 1533 */ 1482 $cover = bp_attachments_cover_image_generate_file( array( 1483 'file' => $uploaded['file'], 1484 'component' => $object_data['component'], 1485 'cover_image_dir' => $cover_dir 1486 ), $cover_image_attachment ); 1534 $cover = bp_attachments_cover_image_generate_file( 1535 array( 1536 'file' => $uploaded['file'], 1537 'component' => $object_data['component'], 1538 'cover_image_dir' => $cover_dir, 1539 ), 1540 $cover_image_attachment 1541 ); 1487 1542 1488 1543 if ( ! $cover ) { 1489 bp_attachments_json_response( false, $is_html4, array( 1490 'type' => 'upload_error', 1491 'message' => $error_message, 1492 ) ); 1544 bp_attachments_json_response( 1545 false, 1546 $is_html4, 1547 array( 1548 'type' => 'upload_error', 1549 'message' => $error_message, 1550 ) 1551 ); 1493 1552 } 1494 1553 … … 1553 1612 1554 1613 // Finally return the cover image url to the UI. 1555 bp_attachments_json_response( true, $is_html4, array( 1556 'name' => $name, 1557 'url' => $cover_url, 1558 'feedback_code' => $feedback_code, 1559 ) ); 1614 bp_attachments_json_response( 1615 true, 1616 $is_html4, 1617 array( 1618 'name' => $name, 1619 'url' => $cover_url, 1620 'feedback_code' => $feedback_code, 1621 ) 1622 ); 1560 1623 } 1561 1624 add_action( 'wp_ajax_bp_cover_image_upload', 'bp_attachments_cover_image_ajax_upload' ); … … 1565 1628 * 1566 1629 * @since 2.4.0 1567 *1568 * @return string|null A json object containing success data if the cover image was deleted1569 * error message otherwise.1570 1630 */ 1571 1631 function bp_attachments_cover_image_ajax_delete() { 1632 1572 1633 if ( ! bp_is_post_request() ) { 1573 1634 wp_send_json_error(); … … 1594 1655 $dir = 'members'; 1595 1656 1596 // Set it for any other cases.1657 // Set it for any other cases. 1597 1658 } else { 1598 1659 $component = $args['object'] . 's'; … … 1601 1662 1602 1663 // Handle delete. 1603 if ( bp_attachments_delete_file( array( 'item_id' => $args['item_id'], 'object_dir' => $dir, 'type' => 'cover-image' ) ) ) { 1664 if ( bp_attachments_delete_file( 1665 array( 1666 'item_id' => $args['item_id'], 1667 'object_dir' => $dir, 1668 'type' => 'cover-image', 1669 ) 1670 ) ) { 1604 1671 $item_id = (int) $args['item_id']; 1605 1672 … … 1640 1707 1641 1708 } else { 1642 wp_send_json_error( array( 1643 'feedback_code' => 2, 1644 ) ); 1709 wp_send_json_error( 1710 array( 1711 'feedback_code' => 2, 1712 ) 1713 ); 1645 1714 } 1646 1715 } … … 1729 1798 $supported_file = bp_attachments_get_file_object( $file ); 1730 1799 1731 if ( is_null( $supported_file ) ) {1800 if ( is_null( $supported_file ) ) { 1732 1801 continue; 1733 1802 } … … 1762 1831 $supported_file = bp_attachments_get_file_object( $file ); 1763 1832 1764 if ( is_null( $supported_file ) ) {1833 if ( is_null( $supported_file ) ) { 1765 1834 continue; 1766 1835 } -
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.