Changeset 12555
- Timestamp:
- 02/29/2020 03:38:06 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-avatars.php
r12536 r12555 1006 1006 $needs_reset = array(); 1007 1007 1008 if ( 'user' === $bp_params['object'] && bp_is_active( ' xprofile' ) ) {1009 $bp_params['upload_dir_filter'] = ' xprofile_avatar_upload_dir';1008 if ( 'user' === $bp_params['object'] && bp_is_active( 'members' ) ) { 1009 $bp_params['upload_dir_filter'] = 'bp_members_avatar_upload_dir'; 1010 1010 1011 1011 if ( ! bp_displayed_user_id() && ! empty( $bp_params['item_id'] ) ) { … … 1298 1298 ); 1299 1299 1300 /** This action is documented in wp-includes/deprecated.php */ 1301 do_action_deprecated( 'xprofile_avatar_uploaded', array( (int) $avatar_data['item_id'], $avatar_data['type'], $avatar_data ), '6.0.0', 'bp_members_avatar_uploaded' ); 1302 1300 1303 /** 1301 1304 * Fires if the new avatar was successfully captured. 1302 1305 * 1303 * @since 1.1.0 Used to inform the avatar was successfully cropped 1304 * @since 2.3.4 Add two new parameters to inform about the user id and 1305 * about the way the avatar was set (eg: 'crop' or 'camera') 1306 * Move the action at the right place, once the avatar is set 1307 * @since 2.8.0 Added the `$avatar_data` parameter. 1306 * @since 6.0.0 1308 1307 * 1309 1308 * @param string $item_id Inform about the user id the avatar was set for. … … 1311 1310 * @param array $avatar_data Array of parameters passed to the avatar handler. 1312 1311 */ 1313 do_action( ' xprofile_avatar_uploaded', (int) $avatar_data['item_id'], $avatar_data['type'], $avatar_data );1312 do_action( 'bp_members_avatar_uploaded', (int) $avatar_data['item_id'], $avatar_data['type'], $avatar_data ); 1314 1313 1315 1314 wp_send_json_success( $return ); … … 1356 1355 1357 1356 if ( 'user' === $avatar_data['object'] ) { 1357 /** This action is documented in wp-includes/deprecated.php */ 1358 do_action_deprecated( 'xprofile_avatar_uploaded', array( (int) $avatar_data['item_id'], $avatar_data['type'], $r ), '6.0.0', 'bp_members_avatar_uploaded' ); 1359 1358 1360 /** This action is documented in bp-core/bp-core-avatars.php */ 1359 do_action( ' xprofile_avatar_uploaded', (int) $avatar_data['item_id'], $avatar_data['type'], $r );1361 do_action( 'bp_members_avatar_uploaded', (int) $avatar_data['item_id'], $avatar_data['type'], $r ); 1360 1362 } elseif ( 'group' === $avatar_data['object'] ) { 1361 1363 /** This action is documented in bp-groups/bp-groups-screens.php */ … … 1937 1939 $retval = false; 1938 1940 1939 // No need to carry on if the current WordPress version is not supported.1940 if ( ! bp_attachments_is_wp_version_supported() ) {1941 return $retval;1942 }1943 1944 1941 if ( bp_is_user_change_avatar() && 'crop-image' !== bp_get_avatar_admin_step() ) { 1945 1942 $retval = ! bp_core_get_root_option( 'bp-disable-avatar-uploads' ); -
trunk/src/bp-members/bp-members-functions.php
r12503 r12555 2849 2849 return apply_filters( 'bp_get_current_member_type', buddypress()->current_member_type ); 2850 2850 } 2851 2852 /** 2853 * Setup the avatar upload directory for a user. 2854 * 2855 * @since 6.0.0 2856 * 2857 * @param string $directory The root directory name. Optional. 2858 * @param int $user_id The user ID. Optional. 2859 * @return array Array containing the path, URL, and other helpful settings. 2860 */ 2861 function bp_members_avatar_upload_dir( $directory = 'avatars', $user_id = 0 ) { 2862 2863 // Use displayed user if no user ID was passed. 2864 if ( empty( $user_id ) ) { 2865 $user_id = bp_displayed_user_id(); 2866 } 2867 2868 // Failsafe against accidentally nooped $directory parameter. 2869 if ( empty( $directory ) ) { 2870 $directory = 'avatars'; 2871 } 2872 2873 $path = bp_core_avatar_upload_path() . '/' . $directory. '/' . $user_id; 2874 $newbdir = $path; 2875 $newurl = bp_core_avatar_url() . '/' . $directory. '/' . $user_id; 2876 $newburl = $newurl; 2877 $newsubdir = '/' . $directory. '/' . $user_id; 2878 2879 /** 2880 * Filters the avatar upload directory for a user. 2881 * 2882 * @since 6.0.0 2883 * 2884 * @param array $value Array containing the path, URL, and other helpful settings. 2885 */ 2886 return apply_filters( 'bp_members_avatar_upload_dir', array( 2887 'path' => $path, 2888 'url' => $newurl, 2889 'subdir' => $newsubdir, 2890 'basedir' => $newbdir, 2891 'baseurl' => $newburl, 2892 'error' => false 2893 ) ); 2894 } -
trunk/src/bp-members/bp-members-template.php
r12336 r12555 1511 1511 */ 1512 1512 function bp_displayed_user_use_cover_image_header() { 1513 return (bool) bp_is_active( ' xprofile', 'cover_image' ) && ! bp_disable_cover_image_uploads() && bp_attachments_is_wp_version_supported();1513 return (bool) bp_is_active( 'members', 'cover_image' ) && ! bp_disable_cover_image_uploads(); 1514 1514 } 1515 1515 … … 2646 2646 return $url; 2647 2647 } 2648 2649 2650 /** 2651 * Render an avatar delete link. 2652 * 2653 * @since 1.1.0 2654 * @since 6.0.0 Moved from /bp-xprofile/bp-xprofile-template.php to this file. 2655 */ 2656 function bp_avatar_delete_link() { 2657 echo bp_get_avatar_delete_link(); 2658 } 2659 2660 /** 2661 * Return an avatar delete link. 2662 * 2663 * @since 1.1.0 2664 * @since 6.0.0 Moved from /bp-xprofile/bp-xprofile-template.php to this file. 2665 * 2666 * @return string 2667 */ 2668 function bp_get_avatar_delete_link() { 2669 2670 /** 2671 * Filters the link used for deleting an avatar. 2672 * 2673 * @since 1.1.0 2674 * 2675 * @param string $value Nonced URL used for deleting an avatar. 2676 */ 2677 return apply_filters( 'bp_get_avatar_delete_link', wp_nonce_url( bp_displayed_user_domain() . bp_get_profile_slug() . '/change-avatar/delete-avatar/', 'bp_delete_avatar_link' ) ); 2678 } -
trunk/src/bp-xprofile/bp-xprofile-functions.php
r12533 r12555 707 707 708 708 /** 709 * Setup the avatar upload directory for a user.710 *711 * @since 1.0.0712 *713 * @package BuddyPress Core714 *715 * @param string $directory The root directory name. Optional.716 * @param int $user_id The user ID. Optional.717 * @return array Array containing the path, URL, and other helpful settings.718 */719 function xprofile_avatar_upload_dir( $directory = 'avatars', $user_id = 0 ) {720 721 // Use displayed user if no user ID was passed.722 if ( empty( $user_id ) ) {723 $user_id = bp_displayed_user_id();724 }725 726 // Failsafe against accidentally nooped $directory parameter.727 if ( empty( $directory ) ) {728 $directory = 'avatars';729 }730 731 $path = bp_core_avatar_upload_path() . '/' . $directory. '/' . $user_id;732 $newbdir = $path;733 $newurl = bp_core_avatar_url() . '/' . $directory. '/' . $user_id;734 $newburl = $newurl;735 $newsubdir = '/' . $directory. '/' . $user_id;736 737 /**738 * Filters the avatar upload directory for a user.739 *740 * @since 1.1.0741 *742 * @param array $value Array containing the path, URL, and other helpful settings.743 */744 return apply_filters( 'xprofile_avatar_upload_dir', array(745 'path' => $path,746 'url' => $newurl,747 'subdir' => $newsubdir,748 'basedir' => $newbdir,749 'baseurl' => $newburl,750 'error' => false751 ) );752 }753 754 /**755 709 * When search_terms are passed to BP_User_Query, search against xprofile fields. 756 710 * -
trunk/src/bp-xprofile/bp-xprofile-template.php
r12529 r12555 1206 1206 1207 1207 /** 1208 * Render an avatar delete link.1209 *1210 * @since 1.1.01211 */1212 function bp_avatar_delete_link() {1213 echo bp_get_avatar_delete_link();1214 }1215 1216 /**1217 * Return an avatar delete link.1218 *1219 * @since 1.1.01220 *1221 * @return string1222 */1223 function bp_get_avatar_delete_link() {1224 1225 /**1226 * Filters the link used for deleting an avatar.1227 *1228 * @since 1.1.01229 *1230 * @param string $value Nonced URL used for deleting an avatar.1231 */1232 return apply_filters( 'bp_get_avatar_delete_link', wp_nonce_url( bp_displayed_user_domain() . bp_get_profile_slug() . '/change-avatar/delete-avatar/', 'bp_delete_avatar_link' ) );1233 }1234 1235 /**1236 1208 * Render an edit profile button. 1237 1209 * -
trunk/tests/phpunit/testcases/core/class-bp-attachment.php
r11737 r12555 239 239 240 240 /* No error */ 241 $user_avatar = $avatar_attachment->upload( $_FILES, ' xprofile_avatar_upload_dir' );241 $user_avatar = $avatar_attachment->upload( $_FILES, 'bp_members_avatar_upload_dir' ); 242 242 $this->assertEquals( $user_avatar['file'], $bp->avatar->upload_path . '/avatars/' . $u1 .'/mystery-man.jpg' ); 243 243 … … 245 245 add_filter( 'bp_core_avatar_original_max_filesize', array( $this, 'max_filesize' ) ); 246 246 247 $user_avatar = $avatar_attachment->upload( $_FILES, ' xprofile_avatar_upload_dir' );247 $user_avatar = $avatar_attachment->upload( $_FILES, 'bp_members_avatar_upload_dir' ); 248 248 249 249 remove_filter( 'bp_core_avatar_original_max_filesize', array( $this, 'max_filesize' ) ); … … 254 254 $_FILES[ $avatar_attachment->file_input ]['type'] = 'application/pdf'; 255 255 256 $user_avatar = $avatar_attachment->upload( $_FILES, ' xprofile_avatar_upload_dir' );256 $user_avatar = $avatar_attachment->upload( $_FILES, 'bp_members_avatar_upload_dir' ); 257 257 $this->assertFalse( empty( $user_avatar['error'] ) ); 258 258
Note: See TracChangeset
for help on using the changeset viewer.