Changeset 12554
- Timestamp:
- 02/29/2020 03:33:10 PM (3 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/js/avatar.js
r12548 r12554 51 51 } ); 52 52 53 $( 'body.wp-admin' ).on( 'click', '.bp- xprofile-avatar-user-edit', function() {53 $( 'body.wp-admin' ).on( 'click', '.bp-members-avatar-user-edit', function() { 54 54 self.resetViews(); 55 55 } ); … … 79 79 $( '.main-column p #upload' ).remove(); 80 80 81 // Admin Extended Profile.82 } else if ( $( '#bp_ xprofile_user_admin_avatar a.bp-xprofile-avatar-user-admin' ).length ) {83 $( '#bp_ xprofile_user_admin_avatar a.bp-xprofile-avatar-user-admin' ).remove();81 // Member Admin. 82 } else if ( $( '#bp_members_user_admin_avatar a.bp-members-avatar-user-admin' ).length ) { 83 $( '#bp_members_user_admin_avatar a.bp-members-avatar-user-admin' ).remove(); 84 84 } 85 85 }, -
trunk/src/bp-members/admin/css/admin-rtl.css
r11718 r12554 30 30 div#community-profile-page li.bp-groups-profile-stats:before, 31 31 div#community-profile-page li.bp-blogs-profile-stats:before, 32 div#community-profile-page a.bp- xprofile-avatar-user-admin:before,33 div#community-profile-page a.bp- xprofile-avatar-user-edit:before {32 div#community-profile-page a.bp-members-avatar-user-admin:before, 33 div#community-profile-page a.bp-members-avatar-user-edit:before { 34 34 font: 400 20px/1 dashicons; 35 35 speak: none; … … 62 62 } 63 63 64 div#community-profile-page a.bp- xprofile-avatar-user-admin:before {64 div#community-profile-page a.bp-members-avatar-user-admin:before { 65 65 content: "\f182"; 66 66 } 67 67 68 div#community-profile-page a.bp- xprofile-avatar-user-edit:before {68 div#community-profile-page a.bp-members-avatar-user-edit:before { 69 69 content: "\f107"; 70 70 } 71 71 72 div#community-profile-page div#bp_ xprofile_user_admin_avatar div.avatar {72 div#community-profile-page div#bp_members_user_admin_avatar div.avatar { 73 73 width: 150px; 74 74 margin: 0 auto; 75 75 } 76 76 77 div#community-profile-page div#bp_ xprofile_user_admin_avatar div.avatar img {77 div#community-profile-page div#bp_members_user_admin_avatar div.avatar img { 78 78 max-width: 100%; 79 79 height: auto; 80 80 } 81 81 82 div#community-profile-page div#bp_ xprofile_user_admin_avatar a {82 div#community-profile-page div#bp_members_user_admin_avatar a { 83 83 display: block; 84 84 margin: 1em 0; -
trunk/src/bp-members/admin/css/admin.css
r11718 r12554 30 30 div#community-profile-page li.bp-groups-profile-stats:before, 31 31 div#community-profile-page li.bp-blogs-profile-stats:before, 32 div#community-profile-page a.bp- xprofile-avatar-user-admin:before,33 div#community-profile-page a.bp- xprofile-avatar-user-edit:before {32 div#community-profile-page a.bp-members-avatar-user-admin:before, 33 div#community-profile-page a.bp-members-avatar-user-edit:before { 34 34 font: 400 20px/1 dashicons; 35 35 speak: none; … … 62 62 } 63 63 64 div#community-profile-page a.bp- xprofile-avatar-user-admin:before {64 div#community-profile-page a.bp-members-avatar-user-admin:before { 65 65 content: "\f182"; 66 66 } 67 67 68 div#community-profile-page a.bp- xprofile-avatar-user-edit:before {68 div#community-profile-page a.bp-members-avatar-user-edit:before { 69 69 content: "\f107"; 70 70 } 71 71 72 div#community-profile-page div#bp_ xprofile_user_admin_avatar div.avatar {72 div#community-profile-page div#bp_members_user_admin_avatar div.avatar { 73 73 width: 150px; 74 74 margin: 0 auto; 75 75 } 76 76 77 div#community-profile-page div#bp_ xprofile_user_admin_avatar div.avatar img {77 div#community-profile-page div#bp_members_user_admin_avatar div.avatar img { 78 78 max-width: 100%; 79 79 height: auto; 80 80 } 81 81 82 div#community-profile-page div#bp_ xprofile_user_admin_avatar a {82 div#community-profile-page div#bp_members_user_admin_avatar a { 83 83 display: block; 84 84 margin: 1em 0; -
trunk/src/bp-members/classes/class-bp-members-admin.php
r12479 r12554 643 643 $js = apply_filters( 'bp_members_admin_js', $js ); 644 644 wp_enqueue_script( 'bp-members-js', $js, array( 'jquery' ), bp_get_version(), true ); 645 646 if ( ! bp_core_get_root_option( 'bp-disable-avatar-uploads' ) && buddypress()->avatar->show_avatars ) { 647 /** 648 * Get Thickbox. 649 * 650 * We cannot simply use add_thickbox() here as WordPress is not playing 651 * nice with Thickbox width/height see https://core.trac.wordpress.org/ticket/17249 652 * Using media-upload might be interesting in the future for the send to editor stuff 653 * and we make sure the tb_window is wide enough 654 */ 655 wp_enqueue_style ( 'thickbox' ); 656 wp_enqueue_script( 'media-upload' ); 657 658 // Get Avatar Uploader. 659 bp_attachments_enqueue_scripts( 'BP_Attachment_Avatar' ); 660 } 645 661 } 646 662 … … 724 740 * 725 741 * @since 2.0.0 742 * @since 6.0.0 The `delete_avatar` action is now managed into this method. 726 743 */ 727 744 public function user_admin_load() { … … 820 837 } 821 838 839 // Set the screen id. 840 $screen_id = get_current_screen()->id; 841 822 842 // User Stat metabox. 823 843 add_meta_box( … … 825 845 sprintf( _x( "%s's Stats", 'members user-admin edit screen', 'buddypress' ), $display_name ), 826 846 array( $this, 'user_admin_stats_metabox' ), 827 get_current_screen()->id,847 $screen_id, 828 848 sanitize_key( $this->stats_metabox->context ), 829 849 sanitize_key( $this->stats_metabox->priority ) 830 850 ); 851 852 if ( buddypress()->avatar->show_avatars ) { 853 // Avatar Metabox. 854 add_meta_box( 855 'bp_members_user_admin_avatar', 856 _x( 'Profile Photo', 'members user-admin edit screen', 'buddypress' ), 857 array( $this, 'user_admin_avatar_metabox' ), 858 $screen_id, 859 'side', 860 'low' 861 ); 862 } 831 863 832 864 // Member Type metabox. Only added if member types have been registered. … … 837 869 _x( 'Member Type', 'members user-admin edit screen', 'buddypress' ), 838 870 array( $this, 'user_admin_member_type_metabox' ), 839 get_current_screen()->id,871 $screen_id, 840 872 'side', 841 873 'core' … … 875 907 bp_core_redirect( $redirect_to ); 876 908 909 // Eventually delete avatar. 910 } elseif ( 'delete_avatar' === $doaction ) { 911 912 // Check the nonce. 913 check_admin_referer( 'delete_avatar' ); 914 915 $redirect_to = remove_query_arg( '_wpnonce', $redirect_to ); 916 917 if ( bp_core_delete_existing_avatar( array( 'item_id' => $user_id ) ) ) { 918 $redirect_to = add_query_arg( 'updated', 'avatar', $redirect_to ); 919 } else { 920 $redirect_to = add_query_arg( 'error', 'avatar', $redirect_to ); 921 } 922 923 bp_core_redirect( $redirect_to ); 924 877 925 // Update other stuff once above ones are done. 878 926 } else { … … 1171 1219 </ul> 1172 1220 1221 <?php 1222 } 1223 1224 /** 1225 * Render the Avatar metabox to moderate inappropriate images. 1226 * 1227 * @since 6.0.0 1228 * 1229 * @param WP_User|null $user The WP_User object for the user being edited. 1230 */ 1231 public function user_admin_avatar_metabox( $user = null ) { 1232 1233 if ( empty( $user->ID ) ) { 1234 return; 1235 } ?> 1236 1237 <div class="avatar"> 1238 1239 <?php echo bp_core_fetch_avatar( array( 1240 'item_id' => $user->ID, 1241 'object' => 'user', 1242 'type' => 'full', 1243 'title' => $user->display_name 1244 ) ); ?> 1245 1246 <?php if ( bp_get_user_has_avatar( $user->ID ) ) : 1247 1248 $query_args = array( 1249 'user_id' => $user->ID, 1250 'action' => 'delete_avatar' 1251 ); 1252 1253 if ( ! empty( $_REQUEST['wp_http_referer'] ) ) { 1254 $wp_http_referer = wp_unslash( $_REQUEST['wp_http_referer'] ); 1255 $wp_http_referer = remove_query_arg( array( 'action', 'updated' ), $wp_http_referer ); 1256 $wp_http_referer = wp_validate_redirect( esc_url_raw( $wp_http_referer ) ); 1257 $query_args['wp_http_referer'] = urlencode( $wp_http_referer ); 1258 } 1259 1260 $community_url = add_query_arg( $query_args, $this->edit_profile_url ); 1261 $delete_link = wp_nonce_url( $community_url, 'delete_avatar' ); ?> 1262 1263 <a href="<?php echo esc_url( $delete_link ); ?>" class="bp-members-avatar-user-admin"><?php esc_html_e( 'Delete Profile Photo', 'buddypress' ); ?></a> 1264 1265 <?php endif; 1266 1267 // Load the Avatar UI templates if user avatar uploads are enabled. 1268 if ( ! bp_core_get_root_option( 'bp-disable-avatar-uploads' ) ) : ?> 1269 <a href="#TB_inline?width=800px&height=400px&inlineId=bp-members-avatar-editor" class="thickbox bp-members-avatar-user-edit"><?php esc_html_e( 'Edit Profile Photo', 'buddypress' ); ?></a> 1270 <div id="bp-members-avatar-editor" style="display:none;"> 1271 <?php bp_attachments_get_template_part( 'avatars/index' ); ?> 1272 </div> 1273 <?php endif; ?> 1274 1275 </div> 1173 1276 <?php 1174 1277 } -
trunk/src/bp-xprofile/classes/class-bp-xprofile-user-admin.php
r11758 r12554 57 57 */ 58 58 private function setup_actions() { 59 // Enqueue scripts.60 add_action( 'bp_members_admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 10, 1 );61 59 62 60 // Register the metabox in Member's community admin profile. 63 61 add_action( 'bp_members_admin_xprofile_metabox', array( $this, 'register_metaboxes' ), 10, 3 ); 64 62 65 // Saves the profile actions for user ( avatar,profile fields ).63 // Saves the profile actions for user ( profile fields ). 66 64 add_action( 'bp_members_admin_update_user', array( $this, 'user_admin_load' ), 10, 4 ); 67 }68 69 /**70 * Enqueue needed scripts.71 *72 * @since 2.3.073 *74 * @param int $screen_id Screen ID being displayed.75 */76 public function enqueue_scripts( $screen_id ) {77 if ( ( false === strpos( $screen_id, 'users_page_bp-profile-edit' )78 && false === strpos( $screen_id, 'profile_page_bp-profile-edit' ) )79 || bp_core_get_root_option( 'bp-disable-avatar-uploads' )80 || ! buddypress()->avatar->show_avatars81 || ! bp_attachments_is_wp_version_supported() ) {82 return;83 }84 85 /**86 * Get Thickbox.87 *88 * We cannot simply use add_thickbox() here as WordPress is not playing89 * nice with Thickbox width/height see https://core.trac.wordpress.org/ticket/1724990 * Using media-upload might be interesting in the future for the send to editor stuff91 * and we make sure the tb_window is wide enough92 */93 wp_enqueue_style ( 'thickbox' );94 wp_enqueue_script( 'media-upload' );95 96 // Get Avatar Uploader.97 bp_attachments_enqueue_scripts( 'BP_Attachment_Avatar' );98 65 } 99 66 … … 156 123 ); 157 124 } 158 159 if ( buddypress()->avatar->show_avatars ) {160 // Avatar Metabox.161 add_meta_box(162 'bp_xprofile_user_admin_avatar',163 _x( 'Profile Photo', 'xprofile user-admin edit screen', 'buddypress' ),164 array( $this, 'user_admin_avatar_metabox' ),165 $screen_id,166 'side',167 'low'168 );169 }170 125 } 171 126 … … 177 132 * 178 133 * @since 2.0.0 134 * @since 6.0.0 The `delete_avatar` action is now managed into BP_Members_Admin::user_admin_load(). 179 135 * 180 136 * @param string $doaction Action being run. … … 185 141 public function user_admin_load( $doaction = '', $user_id = 0, $request = array(), $redirect_to = '' ) { 186 142 187 // Eventually delete avatar. 188 if ( 'delete_avatar' === $doaction ) { 189 190 check_admin_referer( 'delete_avatar' ); 191 192 $redirect_to = remove_query_arg( '_wpnonce', $redirect_to ); 193 194 if ( bp_core_delete_existing_avatar( array( 'item_id' => $user_id ) ) ) { 195 $redirect_to = add_query_arg( 'updated', 'avatar', $redirect_to ); 196 } else { 197 $redirect_to = add_query_arg( 'error', 'avatar', $redirect_to ); 198 } 199 200 bp_core_redirect( $redirect_to ); 201 202 } elseif ( isset( $_POST['field_ids'] ) ) { 203 // Update profile fields. 143 // Update profile fields. 144 if ( isset( $_POST['field_ids'] ) ) { 145 204 146 // Check the nonce. 205 147 check_admin_referer( 'edit-bp-profile_' . $user_id ); … … 435 377 } 436 378 437 /**438 * Render the Avatar metabox to moderate inappropriate images.439 *440 * @since 2.0.0441 *442 * @param WP_User|null $user The WP_User object for the user being edited.443 */444 public function user_admin_avatar_metabox( $user = null ) {445 446 if ( empty( $user->ID ) ) {447 return;448 } ?>449 450 <div class="avatar">451 452 <?php echo bp_core_fetch_avatar( array(453 'item_id' => $user->ID,454 'object' => 'user',455 'type' => 'full',456 'title' => $user->display_name457 ) ); ?>458 459 <?php if ( bp_get_user_has_avatar( $user->ID ) ) :460 461 $query_args = array(462 'user_id' => $user->ID,463 'action' => 'delete_avatar'464 );465 466 if ( ! empty( $_REQUEST['wp_http_referer'] ) ) {467 $wp_http_referer = wp_unslash( $_REQUEST['wp_http_referer'] );468 $wp_http_referer = remove_query_arg( array( 'action', 'updated' ), $wp_http_referer );469 $wp_http_referer = wp_validate_redirect( esc_url_raw( $wp_http_referer ) );470 $query_args['wp_http_referer'] = urlencode( $wp_http_referer );471 }472 473 $community_url = add_query_arg( $query_args, buddypress()->members->admin->edit_profile_url );474 $delete_link = wp_nonce_url( $community_url, 'delete_avatar' ); ?>475 476 <a href="<?php echo esc_url( $delete_link ); ?>" class="bp-xprofile-avatar-user-admin"><?php esc_html_e( 'Delete Profile Photo', 'buddypress' ); ?></a>477 478 <?php endif;479 480 // Load the Avatar UI templates if user avatar uploads are enabled and current WordPress version is supported.481 if ( ! bp_core_get_root_option( 'bp-disable-avatar-uploads' ) && bp_attachments_is_wp_version_supported() ) : ?>482 <a href="#TB_inline?width=800px&height=400px&inlineId=bp-xprofile-avatar-editor" class="thickbox bp-xprofile-avatar-user-edit"><?php esc_html_e( 'Edit Profile Photo', 'buddypress' ); ?></a>483 <div id="bp-xprofile-avatar-editor" style="display:none;">484 <?php bp_attachments_get_template_part( 'avatars/index' ); ?>485 </div>486 <?php endif; ?>487 488 </div>489 <?php490 }491 492 379 } 493 380 endif; // End class_exists check.
Note: See TracChangeset
for help on using the changeset viewer.