[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Members: Change Avatar screen handler 4 * 5 * @package BuddyPress 6 * @subpackage MembersScreens 7 * @since 6.0.0 8 */ 9 10 /** 11 * Handle the display of the profile Change Avatar page by loading the correct template file. 12 * 13 * @since 6.0.0 14 */ 15 function bp_members_screen_change_avatar() { 16 // Bail if not the correct screen. 17 if ( ! bp_is_my_profile() && ! bp_current_user_can( 'bp_moderate' ) ) { 18 return false; 19 } 20 21 // Bail if there are action variables. 22 if ( bp_action_variables() ) { 23 bp_do_404(); 24 return; 25 } 26 27 $bp = buddypress(); 28 29 if ( ! isset( $bp->avatar_admin ) ) { 30 $bp->avatar_admin = new stdClass(); 31 } 32 33 $bp->avatar_admin->step = 'upload-image'; 34 35 if ( !empty( $_FILES ) ) { 36 37 // Check the nonce. 38 check_admin_referer( 'bp_avatar_upload' ); 39 40 // Pass the file to the avatar upload handler. 41 if ( bp_core_avatar_handle_upload( $_FILES, 'bp_members_avatar_upload_dir' ) ) { 42 $bp->avatar_admin->step = 'crop-image'; 43 44 // Make sure we include the jQuery jCrop file for image cropping. 45 add_action( 'wp_print_scripts', 'bp_core_add_jquery_cropper' ); 46 } 47 } 48 49 // If the image cropping is done, crop the image and save a full/thumb version. 50 if ( isset( $_POST['avatar-crop-submit'] ) ) { 51 52 // Check the nonce. 53 check_admin_referer( 'bp_avatar_cropstore' ); 54 55 $args = array( 56 'item_id' => bp_displayed_user_id(), 57 'original_file' => $_POST['image_src'], 58 'crop_x' => $_POST['x'], 59 'crop_y' => $_POST['y'], 60 'crop_w' => $_POST['w'], 61 'crop_h' => $_POST['h'] 62 ); 63 64 // Handle crop. 65 $cropped_avatar = bp_core_avatar_handle_crop( $args, 'array' ); 66 67 if ( ! $cropped_avatar ) { 68 bp_core_add_message( __( 'There was a problem cropping your profile photo.', 'buddypress' ), 'error' ); 69 } else { 70 71 /** This action is documented in wp-includes/deprecated.php */ 72 do_action_deprecated( 'xprofile_avatar_uploaded', array( (int) $args['item_id'], 'crop' ), '6.0.0', 'bp_members_avatar_uploaded' ); 73 74 /** 75 * Fires right before the redirect, after processing a new avatar. 76 * 77 * @since 6.0.0 78 * @since 10.0.0 Adds a new param: an array containing the full, thumb avatar and the timestamp. 79 * 80 * @param string $item_id Inform about the user id the avatar was set for. 81 * @param string $type Inform about the way the avatar was set ('camera'). 82 * @param array $args Array of parameters passed to the crop handler. 83 * @param array $cropped_avatar Array containing the full, thumb avatar and the timestamp. 84 */ 85 do_action( 'bp_members_avatar_uploaded', (int) $args['item_id'], 'crop', $args, $cropped_avatar ); 86 87 bp_core_add_message( __( 'Your new profile photo was uploaded successfully.', 'buddypress' ) ); 88 bp_core_redirect( bp_displayed_user_domain() ); 89 } 90 } 91 92 /** This action is documented in wp-includes/deprecated.php */ 93 do_action_deprecated( 'xprofile_screen_change_avatar', array(), '6.0.0', 'bp_members_screen_change_avatar' ); 94 95 /** 96 * Fires right before the loading of the Member Change Avatar screen template file. 97 * 98 * @since 6.0.0 99 */ 100 do_action( 'bp_members_screen_change_avatar' ); 101 102 /** This filter is documented in wp-includes/deprecated.php */ 103 $template = apply_filters_deprecated( 'xprofile_template_change_avatar', array( 'members/single/home' ), '6.0.0', 'bp_members_template_change_avatar' ); 104 105 /** 106 * Filters the template to load for the Member Change Avatar page screen. 107 * 108 * @since 6.0.0 109 * 110 * @param string $template Path to the Member template to load. 111 */ 112 bp_core_load_template( apply_filters( 'bp_members_template_change_avatar', $template ) ); 113 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Dec 22 01:00:54 2024 | Cross-referenced by PHPXref 0.7.1 |