Ticket #6604: 6604.patch
File 6604.patch, 34.3 KB (added by , 10 years ago) |
---|
-
src/bp-core/bp-core-catchuri.php
diff --git src/bp-core/bp-core-catchuri.php src/bp-core/bp-core-catchuri.php index e0cdf60..836ae7d 100644
function bp_core_load_template( $templates ) { 402 402 } 403 403 404 404 /** 405 * Filters the template locations. 406 * 407 * Allows plugins to alter where the template files are located. 408 * 409 * @since BuddyPress (1.1.0) 410 * 411 * @param string $template Located template path. 412 * @param array $filtered_templates Array of templates to attempt to load. 405 * It's a modal, use the specific template 413 406 */ 414 $located_template = apply_filters( 'bp_located_template', $template, $filtered_templates ); 407 if ( bp_is_modal() ) { 408 $located_template = bp_locate_template( reset( $filtered_templates ), false ); 409 } else { 410 /** 411 * Filters the template locations. 412 * 413 * Allows plugins to alter where the template files are located. 414 * 415 * @since BuddyPress (1.1.0) 416 * 417 * @param string $template Located template path. 418 * @param array $filtered_templates Array of templates to attempt to load. 419 */ 420 $located_template = apply_filters( 'bp_located_template', $template, $filtered_templates ); 421 } 422 415 423 if ( !empty( $located_template ) ) { 416 424 // Template was located, lets set this as a valid page and not a 404. 417 425 status_header( 200 ); -
src/bp-core/bp-core-cssjs.php
diff --git src/bp-core/bp-core-cssjs.php src/bp-core/bp-core-cssjs.php index 392f926..737b172 100644
function bp_core_register_common_scripts() { 43 43 'bp-avatar' => array( 'file' => "{$url}avatar{$min}.js", 'dependencies' => array( 'jcrop' ), 'footer' => true ), 44 44 'bp-webcam' => array( 'file' => "{$url}webcam{$min}.js", 'dependencies' => array( 'bp-avatar' ), 'footer' => true ), 45 45 46 // 2.? 47 'bp-modal' => array( 'file' => "{$url}modal{$min}.js", 'dependencies' => array( 'thickbox' ), 'footer' => true ), 48 46 49 ) ); 47 50 48 51 $version = bp_get_version(); … … function bp_core_register_common_styles() { 87 90 'file' => "{$url}avatar{$min}.css", 88 91 'dependencies' => array( 'jcrop' ) 89 92 ), 93 'bp-modal' => array( 94 'file' => "{$url}modal{$min}.css", 95 'dependencies' => array( 'thickbox' ) 96 ), 90 97 ) ); 91 98 92 99 foreach ( $styles as $id => $style ) { … … function bp_core_get_js_dependencies() { 337 344 'bp-jquery-scroll-to' 338 345 ) ); 339 346 } 347 348 /** 349 * Add the needed script and css for the BuddyPress modal 350 * 351 * @since 2.?.0 352 */ 353 function bp_add_modal() { 354 // Enqueue me just once per page, please. 355 if ( did_action( 'bp_modal_scripts_enqueued' ) ) { 356 return; 357 } 358 359 wp_enqueue_script( 'bp-modal' ); 360 wp_enqueue_style ( 'bp-modal' ); 361 362 /** 363 * Fires at the conclusion of bp_add_modal() 364 * to avoid the scripts to be loaded more than once. 365 * 366 * @since 2.?.0 367 */ 368 do_action( 'bp_modal_scripts_enqueued' ); 369 } 370 371 /** 372 * Enqueue scripts for the BuddyPress modal iframe 373 * 374 * @since 2.?.0 375 * 376 * @param bool $is_admin wether the context is wp-admin or not 377 */ 378 function bp_modal_enqueue_scripts( $is_admin = false ) { 379 global $wp_filter; 380 381 // Leave themes register their stylesheet 382 $theme = get_template(); 383 if ( empty( $theme ) ) { 384 $theme = get_stylesheet(); 385 } 386 387 // Only keep scripts enqueued hooking bp_enqueue_scripts. 388 if ( isset( $wp_filter[ 'wp_enqueue_scripts' ] ) ) { 389 foreach ( $wp_filter[ 'wp_enqueue_scripts' ] as $priority => $actions ) { 390 391 foreach ( $actions as $key => $actions_data ) { 392 if ( 'bp_enqueue_scripts' !== $key && ! ( false !== strpos( $key, $theme ) && ! $is_admin ) ) { 393 unset( $wp_filter[ 'wp_enqueue_scripts' ][ $priority ][ $key ] ); 394 } 395 } 396 } 397 } 398 399 return wp_enqueue_scripts(); 400 } 401 add_action( 'bp_modal_header', 'bp_modal_enqueue_scripts', 1 ); 402 add_action( 'bp_modal_header', 'locale_stylesheet' ); 403 add_action( 'bp_modal_header', 'wp_print_styles', 8 ); 404 add_action( 'bp_modal_header', 'wp_print_head_scripts', 9 ); 405 add_action( 'bp_modal_footer', 'wp_print_footer_scripts', 20 ); 406 407 /* Admin context */ 408 add_action( 'bp_admin_modal_header', 'bp_modal_enqueue_scripts', 1 ); 409 add_action( 'bp_admin_modal_header', 'register_admin_color_schemes', 2 ); 410 add_action( 'bp_admin_modal_header', 'print_admin_styles', 3 ); 411 add_action( 'bp_admin_modal_footer', '_wp_footer_scripts' ); -
src/bp-core/bp-core-dependency.php
diff --git src/bp-core/bp-core-dependency.php src/bp-core/bp-core-dependency.php index 22f5a30..7238b30 100644
function bp_enqueue_scripts() { 383 383 } 384 384 385 385 /** 386 * Fire the 'bp_modal_header' action, or the 'bp_admin_modal_header' in the modal was opened from 387 * an Administration screen. 388 * 389 * @since 2.?.0 390 */ 391 function bp_modal_header( $is_admin = false ) { 392 $action = 'bp_modal_header'; 393 394 if ( true === (bool) $is_admin ) { 395 $action = 'bp_admin_modal_header'; 396 } 397 398 /** 399 * Fires inside the 'bp_modal_header' function. 400 * 401 * @since 2.?.0 402 * 403 * @param bool $is_admin True for a wp-admin context, false otherwise 404 */ 405 do_action( $action, $is_admin ); 406 } 407 408 /** 409 * Fire the 'bp_modal_footer' action, or the 'bp_admin_modal_footer' in the modal was opened from 410 * an Administration screen. 411 * 412 * @since 2.?.0 413 */ 414 function bp_modal_footer( $is_admin = false ) { 415 $action = 'bp_modal_footer'; 416 417 if ( true === (bool) $is_admin ) { 418 $action = 'bp_admin_modal_footer'; 419 } 420 421 /** 422 * Fires inside the 'bp_modal_footer' function. 423 * 424 * @since 2.?.0 425 * 426 * @param bool $is_admin True for a wp-admin context, false otherwise 427 */ 428 do_action( $action, $is_admin ); 429 } 430 431 /** 386 432 * Fire the 'bp_add_rewrite_tag' action, where BP adds its custom rewrite tags. 387 433 * 388 434 * @since BuddyPress (1.8.0) -
src/bp-core/bp-core-functions.php
diff --git src/bp-core/bp-core-functions.php src/bp-core/bp-core-functions.php index 1ea91ec..a8ad8e6 100644
function bp_update_is_item_mod( $is_item_mod = false, $component = '' ) { 1987 1987 } 1988 1988 1989 1989 /** 1990 * Set a BuddyPress modal 1991 * 1992 * @since 2.?.0 1993 * 1994 * @param bool $set whether the current screen is a modal (True) or not (False) 1995 */ 1996 function bp_set_is_modal( $set = false ) { 1997 buddypress()->core->is_modal = $set; 1998 } 1999 2000 /** 1990 2001 * Trigger a 404. 1991 2002 * 1992 2003 * @since BuddyPress (1.5.0) -
src/bp-core/bp-core-template.php
diff --git src/bp-core/bp-core-template.php src/bp-core/bp-core-template.php index 52bae24..6a3f7e8 100644
function bp_is_register_page() { 2747 2747 } 2748 2748 2749 2749 /** 2750 * Is the current page the BuddyPress modal? 2751 * 2752 * Eg http://example.com/members/foobar/bp-modal. 2753 * 2754 * @return bool True if the current page is the BuddyPress modal. 2755 */ 2756 function bp_is_modal() { 2757 $retval = false; 2758 $bp = buddypress(); 2759 2760 if ( isset( $bp->core->is_modal ) ) { 2761 $retval = (bool) $bp->core->is_modal; 2762 } 2763 2764 return $retval; 2765 } 2766 2767 /** 2750 2768 * Customize the body class, according to the currently displayed BP content. 2751 2769 */ 2752 2770 function bp_the_body_class() { … … function bp_nav_menu( $args = array() ) { 3334 3352 return $nav_menu; 3335 3353 } 3336 3354 } 3355 3356 /** 3357 * Output a modal link 3358 * 3359 * @since 2.?.0 3360 * 3361 * @param array $args the attributes of the BuddyPress modal 3362 */ 3363 function bp_modal_link( $args = array() ) { 3364 echo bp_get_modal_link( $args ); 3365 } 3366 3367 /** 3368 * Get a modal link 3369 * 3370 * @since 2.?.0 3371 * 3372 * @param array $args { 3373 * An array of arguments. 3374 * 3375 * @type int $item_id The ID of the item. Default: current user_id. Required. 3376 * @type string $object The type of object (eg: user, group..). Default:user. Required. 3377 * @type string $width The width of the modal. Default:600. Optionnal. 3378 * @type string $height The height of the modal. Default:500. Optionnal. 3379 * @type string $modal_title The title tag for the generated iframe on link click. Default: ''. Optionnal. 3380 * @type string $modal_action The name of the action that will be executed by the modal. Default: ''.Required. 3381 * @type array $link_class The list of class to add to the generated link. Default: empty array. Optionnal. 3382 * @type string $link_title The title attribute of the link. Default: 'Open window'. Optionnal. 3383 * @type string $link_text The text of the link. Default: 'Open window'. Optionnal. 3384 * } 3385 * @return string the html to link to the modal 3386 */ 3387 function bp_get_modal_link( $args = array() ) { 3388 $r = bp_parse_args( $args, array( 3389 'item_id' => bp_loggedin_user_id(), 3390 'object' => 'user', 3391 'width' => 600, 3392 'height' => 500, 3393 'modal_title' => '', 3394 'modal_action' => '', 3395 'link_class' => array(), 3396 'link_title' => __( 'Open window', 'buddypress' ), 3397 'link_text' => __( 'Open window', 'buddypress' ), 3398 ) ); 3399 3400 if ( empty( $r['item_id'] ) || empty( $r['object'] ) || empty( $r['modal_action'] ) ) { 3401 return; 3402 } 3403 3404 // Add BuddyPress modal 3405 bp_add_modal(); 3406 3407 $query_args = array( 3408 'is_admin' => 0, 3409 'title' => $r['modal_title'], 3410 'action' => $r['modal_action'], 3411 'TB_iframe' => true, 3412 'width' => $r['width'], 3413 'height' => $r['height'], 3414 ); 3415 3416 if ( is_admin() ) { 3417 $query_args['is_admin'] = 1; 3418 } 3419 3420 if ( 'group' === $r['object'] ) { 3421 if ( is_a( $r['item_id'], 'BP_Groups_Group' ) ) { 3422 $group = $r['item_id']; 3423 } else { 3424 $group = groups_get_group( array( 'group_id' => $r['item_id'] ) ); 3425 } 3426 3427 $group_link = bp_get_group_permalink( $group ); 3428 3429 if ( empty( $group_link ) ) { 3430 return; 3431 } 3432 3433 if ( 'group-avatar' === $r['modal_action'] ) { 3434 $group_link = trailingslashit( $group_link . 'admin' ); 3435 } 3436 3437 $modal_link = add_query_arg( $query_args, trailingslashit( $group_link . 'bp-modal' ) ); 3438 3439 } elseif ( 'user' === $r['object'] ) { 3440 $user_link = bp_core_get_user_domain( $r['item_id'] ); 3441 3442 if ( empty( $user_link ) ) { 3443 return; 3444 } 3445 3446 if ( 'change-avatar' === $r['modal_action'] ) { 3447 $user_link = trailingslashit( $user_link . 'profile' ); 3448 } 3449 $modal_link = add_query_arg( $query_args, trailingslashit( $user_link . 'bp-modal' ) ); 3450 } else { 3451 return; 3452 } 3453 3454 return apply_filters( 'bp_get_modal_link', sprintf( '<a href="%1$s" class="bp-thickbox %2$s" title="%3$s">%4$s</a>', 3455 esc_url( $modal_link ), 3456 esc_attr( join( ' ', (array) $r['link_class'] ) ), 3457 esc_attr( $r['link_title'] ), 3458 esc_html( $r['link_text'] ) 3459 ) ); 3460 } 3461 3462 /** 3463 * Output the modal iframe title tag 3464 * 3465 * @since 2.?.0 3466 */ 3467 function bp_modal_title() { 3468 echo bp_modal_get_title(); 3469 } 3470 3471 /** 3472 * Get the modale iframe title tag 3473 * 3474 * @since 2.?.0 3475 * 3476 * @return string the title tag for the modal iframe 3477 */ 3478 function bp_modal_get_title() { 3479 $title = _x( 'BuddyPress modal', 'BuddyPress' ); 3480 3481 if ( isset( $_GET['title'] ) ) { 3482 $title = $_GET['title']; 3483 } 3484 3485 return apply_filters( 'bp_modal_title', esc_html( strip_tags( $title ) ), $title ); 3486 } 3487 3488 /** 3489 * Output the modal content 3490 * 3491 * @since 2.?.0 3492 */ 3493 function bp_modal_content() { 3494 $action = 'bp_modal_content'; 3495 3496 if ( isset( $_GET['action'] ) ) { 3497 $action .= '_' .sanitize_file_name( $_GET['action'] ); 3498 } 3499 3500 /** 3501 * This is a dynamic action depending on the $modal_action 3502 * defined in bp_get_modal_link. 3503 * 3504 * @since 2.?.0 3505 * 3506 * eg: "bp_modal_content_$modal_action" 3507 */ 3508 do_action( $action ); 3509 } -
src/bp-core/css/modal.css
diff --git src/bp-core/css/modal.css src/bp-core/css/modal.css index e69de29..9de4a80 100644
1 body.bp-modal #TB_title { 2 float: left; 3 height: 1px; 4 } 5 6 body.bp-modal #TB_ajaxWindowTitle { 7 display: none; 8 } 9 10 body.bp-modal #TB_window { 11 max-width: 90%; 12 max-height: 90%; 13 } 14 15 body.bp-modal .tb-close-icon, 16 #bp-modal-buttons .bp-full-height-icon { 17 left: auto; 18 right: -30px; 19 color: #eee; 20 -webkit-transition: color .1s ease-in-out, background .1s ease-in-out; 21 transition: color .1s ease-in-out, background .1s ease-in-out; 22 } 23 24 body.bp-modal #TB_closeWindowButton:focus, 25 body.bp-modal #TB_closeWindowButton:focus .tb-close-icon, 26 body.bp-modal .tb-close-icon:focus, 27 body.bp-modal .tb-close-icon:hover, 28 #bp-modal-buttons #bp-modal-full-height:focus, 29 #bp-modal-buttons #bp-modal-full-height:focus .bp-full-height-icon, 30 #bp-modal-buttons .bp-full-height-icon:focus, 31 #bp-modal-buttons .bp-full-height-icon:hover { 32 color: #00a0d2; 33 outline: none; 34 -webkit-box-shadow: none; 35 box-shadow: none; 36 } 37 38 body.buddypress .tb-close-icon:before, 39 body.toplevel_page_bp-groups .tb-close-icon:before { 40 content: "\f335"; 41 font-size: 32px; 42 } 43 44 #bp-modal-buttons .bp-full-height-icon { 45 position:absolute; 46 top:30px; 47 text-align: center; 48 line-height: 29px; 49 width: 29px; 50 height: 29px; 51 } 52 53 #bp-modal-buttons .bp-full-height-icon:before { 54 font: normal 20px/32px 'dashicons'; 55 speak: none; 56 -webkit-font-smoothing: antialiased; 57 -moz-osx-font-smoothing: grayscale; 58 } 59 60 #bp-modal-buttons .bp-full-height-icon:before { 61 content: "\f316"; 62 } 63 64 #bp-modal-buttons .bp-full-height-icon.max:before { 65 content: "\f317"; 66 } 67 68 body.bp-modal #TB_iframeContent { 69 margin:0; 70 max-width: 100%; 71 max-height: 100%; 72 } -
src/bp-core/js/avatar.js
diff --git src/bp-core/js/avatar.js src/bp-core/js/avatar.js index c5019df..886528c 100644
window.bp = window.bp || {}; 26 26 // Init some vars 27 27 this.views = new Backbone.Collection(); 28 28 this.jcropapi = {}; 29 this.warning = null; 29 this.warning = null; 30 this.opener = window.opener || window.parent || window.top; 30 31 31 32 // Set up nav 32 33 this.setupNav(); … … window.bp = window.bp || {}; 236 237 type: _.isUndefined( avatar.get( 'type' ) ) ? 'crop' : avatar.get( 'type' ), 237 238 nonce: avatar.get( 'nonces' ).set 238 239 } ).done( function( response ) { 239 var avatarStatus = new bp.Views.AvatarStatus( { 240 value : BP_Uploader.strings.feedback_messages[ response.feedback_code ], 241 type : 'success' 242 } ); 240 var avatarClass, 241 avatarStatus = new bp.Views.AvatarStatus( { 242 value : BP_Uploader.strings.feedback_messages[ response.feedback_code ], 243 type : 'success' 244 } ); 243 245 244 246 self.views.add( { 245 247 id : 'status', … … window.bp = window.bp || {}; 248 250 249 251 avatarStatus.inject( '.bp-avatar-status' ); 250 252 253 avatarClass = '.' + avatar.get( 'object' ) + '-' + response.item_id + '-avatar'; 254 255 // Update each avatars of the parent page 256 if ( typeof self.opener.bp.updateAvatars !== 'undefined' ) { 257 self.opener.bp.updateAvatars( avatarClass, response.avatar ); 258 251 259 // Update each avatars of the page 252 $( '.' + avatar.get( 'object' ) + '-' + response.item_id + '-avatar' ).each( function() { 253 $(this).prop( 'src', response.avatar ); 254 } ); 260 } else { 261 // Update each avatars of the page 262 $( avatarClass ).each( function() { 263 $(this).prop( 'src', response.avatar ); 264 } ); 265 } 255 266 256 267 // Inject the Delete nav 257 268 bp.Avatar.navItems.get( 'delete' ).set( { hide: 0 } ); … … window.bp = window.bp || {}; 312 323 object: model.get( 'object' ), 313 324 nonce: model.get( 'nonces' ).remove 314 325 } ).done( function( response ) { 315 var avatarStatus = new bp.Views.AvatarStatus( { 316 value : BP_Uploader.strings.feedback_messages[ response.feedback_code ], 317 type : 'success' 318 } ); 326 var avatarClass, 327 avatarStatus = new bp.Views.AvatarStatus( { 328 value : BP_Uploader.strings.feedback_messages[ response.feedback_code ], 329 type : 'success' 330 } ); 319 331 320 332 self.views.add( { 321 333 id : 'status', … … window.bp = window.bp || {}; 324 336 325 337 avatarStatus.inject( '.bp-avatar-status' ); 326 338 339 avatarClass = '.' + model.get( 'object' ) + '-' + response.item_id + '-avatar'; 340 341 // Update each avatars of the parent page 342 if ( typeof self.opener.bp.updateAvatars !== 'undefined' ) { 343 self.opener.bp.updateAvatars( avatarClass, response.avatar ); 344 327 345 // Update each avatars of the page 328 $( '.' + model.get( 'object' ) + '-' + response.item_id + '-avatar').each( function() { 329 $( this ).prop( 'src', response.avatar ); 330 } ); 346 } else { 347 $( avatarClass ).each( function() { 348 $( this ).prop( 'src', response.avatar ); 349 } ); 350 } 331 351 332 352 // Remove the Delete nav 333 353 bp.Avatar.navItems.get( 'delete' ).set( { active: 0, hide: 1 } ); -
src/bp-core/js/modal.js
diff --git src/bp-core/js/modal.js src/bp-core/js/modal.js index e69de29..0ff740b 100644
1 /* global bp */ 2 3 window.bp = window.bp || {}; 4 5 ( function( $ ) { 6 var originalWidth, originalHeight, originalIframeHeight; 7 8 // Asjust Thickbox 9 bp_tb_position = function() { 10 var availableWidth = $( window ).width(), 11 availableHeight = $( window ).height(), 12 needReposition = false; 13 14 // Don't do anything if we don't have needed Thickbox attributes 15 if ( typeof TB_WIDTH === 'undefined' || typeof TB_HEIGHT === 'undefined' || typeof tb_position === 'undefined' ) { 16 return; 17 } 18 19 // Only set originalWidth and originalHeight if not defined 20 if ( typeof originalWidth === 'undefined' ) { 21 originalWidth = TB_WIDTH; 22 } 23 24 if ( typeof originalHeight === 'undefined' ) { 25 originalHeight = TB_HEIGHT; 26 } 27 28 if ( availableWidth < TB_WIDTH ) { 29 TB_WIDTH = availableWidth - 50; 30 needReposition = true; 31 } else if ( availableWidth > originalWidth ) { 32 TB_WIDTH = originalWidth; 33 needReposition = true; 34 } 35 36 if ( availableHeight < TB_HEIGHT ) { 37 TB_HEIGHT = availableHeight - 50; 38 needReposition = true; 39 } else if ( availableHeight > originalHeight ) { 40 TB_HEIGHT = originalHeight; 41 needReposition = true; 42 } 43 44 // Ask Thickbox to "reposition" 45 if ( true === needReposition ) { 46 tb_position(); 47 48 $( '#TB_window' ).css( { 49 'height' : TB_HEIGHT + 'px' 50 } ); 51 52 $( '#TB_iframeContent' ).css( { 53 'width' : originalWidth - 1 + 'px', 54 'height' : TB_HEIGHT - 1 + 'px' 55 } ); 56 } 57 }; 58 59 // Make sure links are not containing bigger dimensions than available ones 60 $( 'a.bp-thickbox' ).each( function() { 61 var href = $( this ).attr( 'href' ), 62 availableWidth = $( window ).width(), 63 availableHeight = $( window ).height(); 64 65 if ( ! href ) { 66 return; 67 } 68 69 // Requested Thickbox width & height 70 var tb_width = href.match( /width=([0-9]+)/ ); 71 var tb_height = href.match( /height=([0-9]+)/ ); 72 73 if ( tb_width[1] ) { 74 // If too large resize 75 if ( parseInt( tb_width[1] ) > availableWidth ) { 76 href = href.replace( /width=[0-9]+/g, 'width=' + Number( availableWidth - 50 ) ); 77 78 // Leave unchanged 79 } else { 80 href = href.replace( /width=[0-9]+/g, 'width=' + tb_width[1] ); 81 } 82 } 83 84 if ( tb_height[1] ) { 85 // If too large resize 86 if ( parseInt( tb_height[1] ) > availableHeight ) { 87 href = href.replace( /height=[0-9]+/g, 'height=' + Number( availableHeight - 50 ) ); 88 89 // Leave unchanged 90 } else { 91 href = href.replace( /height=[0-9]+/g, 'height=' + tb_height[1] ); 92 } 93 } 94 95 // Reset links 96 $( this ).attr( 'href', href ); 97 } ); 98 99 // Listen to bp-thickbox links 100 $( document ).ready( function() { 101 tb_init( 'a.bp-thickbox' ); 102 $( 'body' ).addClass( 'bp-modal' ); 103 } ); 104 105 // Add a button to the BuddyPress modal 106 window.tb_showIframe = function() { 107 var isBPiframe = $( '#TB_iframeContent' ).prop( 'src' ).match( /bp-modal/ ); 108 109 if ( null === isBPiframe ) { 110 return; 111 } 112 113 $( '#TB_title' ).append( '<div id="bp-modal-buttons"><a href="#" id="bp-modal-full-height"><span class="screen-reader-text">Zoom</span><div class="bp-full-height-icon"></div></a>' ); 114 }; 115 116 // Toggle the BuddyPress modal height from original to full 117 $( 'body' ).on( 'click', '#bp-modal-buttons .bp-full-height-icon', function( event ) { 118 event.preventDefault(); 119 120 var bpFullHeighBtn = $( this ); 121 122 bp_tb_position(); 123 124 if ( typeof originalIframeHeight === 'undefined' ) { 125 originalIframeHeight = $( '#TB_iframeContent' ).prop( 'style' ).height; 126 } 127 128 if ( ! bpFullHeighBtn.hasClass( 'max' ) ) { 129 TB_HEIGHT = $( window ).height() - 50; 130 bpFullHeighBtn.addClass( 'max' ); 131 } else { 132 TB_HEIGHT = originalIframeHeight; 133 bpFullHeighBtn.removeClass( 'max' ); 134 } 135 136 // Reposition 137 tb_position(); 138 139 $( '#TB_window' ).css( { 140 'height' : TB_HEIGHT + 'px' 141 } ); 142 143 $( '#TB_iframeContent' ).css( { 144 'width' : originalWidth - 1 + 'px', 145 'height' : TB_HEIGHT - 1 + 'px' 146 } ); 147 } ); 148 149 // Reposition on window resize 150 $( window ).resize( function() { bp_tb_position(); } ); 151 152 /** 153 * Update the avatars for a given class 154 * 155 * @param {string} avatarClass the name of the class 156 * @param {string} replace the link to the avatar 157 */ 158 bp.updateAvatars = function( avatarClass, replace ) { 159 $( avatarClass ).each( function() { 160 $(this).prop( 'src', replace ); 161 } ); 162 }; 163 164 /** 165 * Insert/Update html inside a given selector 166 * 167 * @param {string} selectorId the element ID 168 * @param {string} html the html to insert 169 */ 170 bp.updateHtml = function( selectorId, html ) { 171 $( selectorId ).html( html ); 172 }; 173 174 /** 175 * Insert/Update an input value 176 * @param {string} inputId the input ID 177 * @param {string} val the value to insert 178 */ 179 bp.updateVal = function( inputId, val ) { 180 $( selectorId ).val( val ); 181 }; 182 183 } )( jQuery ); -
src/bp-groups/admin/css/admin.css
diff --git src/bp-groups/admin/css/admin.css src/bp-groups/admin/css/admin.css index 651a6d5..a380726 100644
table.bp-group-members .urole-column { 84 84 padding-left: 20px; 85 85 padding-right: 20px; 86 86 } 87 88 div#bp_group_avatar div.avatar { 89 width: 150px; 90 margin: 0 auto; 91 } 92 93 div#bp_group_avatar div.avatar img { 94 max-width: 100%; 95 height: auto; 96 } 97 98 div#bp_group_avatar a.bp-groups-avatar-admin-edit { 99 display: block; 100 margin: 1em 0; 101 text-decoration: none; 102 color: #888; 103 } 104 105 div#bp_group_avatar a.bp-groups-avatar-admin-edit:before { 106 font: normal 20px/1 'dashicons'; 107 speak: none; 108 display: inline-block; 109 padding: 0 2px 0 0; 110 top: 0; 111 left: -1px; 112 position: relative; 113 vertical-align: top; 114 -webkit-font-smoothing: antialiased; 115 -moz-osx-font-smoothing: grayscale; 116 text-decoration: none !important; 117 color: #888; 118 } 119 120 div#bp_group_avatar a.bp-groups-avatar-admin-edit:before { 121 content: "\f107"; 122 } -
src/bp-groups/bp-groups-admin.php
diff --git src/bp-groups/bp-groups-admin.php src/bp-groups/bp-groups-admin.php index 41be4e3..def70ce 100644
function bp_groups_admin_load() { 133 133 add_meta_box( 'bp_group_add_members', _x( 'Add New Members', 'group admin edit screen', 'buddypress' ), 'bp_groups_admin_edit_metabox_add_new_members', get_current_screen()->id, 'normal', 'core' ); 134 134 add_meta_box( 'bp_group_members', _x( 'Manage Members', 'group admin edit screen', 'buddypress' ), 'bp_groups_admin_edit_metabox_members', get_current_screen()->id, 'normal', 'core' ); 135 135 136 // Manage Group's avatar 137 $disabled_avatar_uploads = (int) bp_disable_group_avatar_uploads(); 138 if ( ! $disabled_avatar_uploads && buddypress()->avatar->show_avatars && bp_attachments_is_wp_version_supported() ) { 139 add_meta_box( 'bp_group_avatar', _x( 'Photo', 'group admin edit screen', 'buddypress' ), 'bp_groups_admin_edit_metabox_avatar', get_current_screen()->id, 'side', 'core' ); 140 } 141 136 142 /** 137 143 * Fires after the registration of all of the default group meta boxes. 138 144 * … … function bp_groups_admin_edit_metabox_settings( $item ) { 797 803 } 798 804 799 805 /** 806 * Output the markup for a single group's Edit Avatar metabox. 807 * 808 * @since 2.?.0 809 */ 810 function bp_groups_admin_edit_metabox_avatar( $item ) { 811 ?> 812 <div class="avatar"> 813 814 <?php 815 echo bp_core_fetch_avatar( array( 816 'item_id' => $item->id, 817 'object' => 'group', 818 'type' => 'full', 819 'title' => $item->name 820 ) ); 821 822 bp_modal_link( array( 823 'item_id' => $item, 824 'object' => 'group', 825 'width' => 800, 826 'height' => 400, 827 'modal_title' => __( 'Edit Group Photo', 'buddypress' ), 828 'modal_action' => 'group-avatar', 829 'link_text' => __( 'Edit Group Photo', 'buddypress' ), 830 'link_class' => array( 'bp-groups-avatar-admin-edit' ), 831 ) ); 832 ?> 833 834 </div> 835 <?php 836 } 837 838 /** 800 839 * Output the markup for a single group's Add New Members metabox. 801 840 * 802 841 * @since BuddyPress (1.7.0) -
src/bp-groups/bp-groups-screens.php
diff --git src/bp-groups/bp-groups-screens.php src/bp-groups/bp-groups-screens.php index 61a9ed6..237ef3d 100644
function groups_screen_group_admin_delete_group() { 1308 1308 add_action( 'bp_screens', 'groups_screen_group_admin_delete_group' ); 1309 1309 1310 1310 /** 1311 * Handle the display for a group modal 1312 * 1313 * @since 2.?.0 1314 */ 1315 function groups_sreen_modal() { 1316 $bp = buddypress(); 1317 1318 if ( bp_is_group_admin_page() && 'bp-modal' === bp_action_variable( 0 ) ) { 1319 1320 if ( ! bp_is_item_admin() ) { 1321 return; 1322 } 1323 1324 if ( ! empty( $_GET['action'] ) ) { 1325 $bp->action_variables = array( sanitize_file_name( $_GET['action'] ) ); 1326 } 1327 1328 bp_set_is_modal( true ); 1329 1330 } elseif ( 'bp-modal' === bp_current_action() ) { 1331 if ( ! empty( $_GET['action'] ) ) { 1332 $bp->current_action = sanitize_file_name( $_GET['action'] ); 1333 } 1334 1335 bp_set_is_modal( true ); 1336 } 1337 1338 if ( bp_is_modal() ) { 1339 bp_core_load_template( 'assets/modal' ); 1340 } 1341 } 1342 add_action( 'bp_screens', 'groups_sreen_modal', 0 ); 1343 1344 /** 1311 1345 * Render the group settings fields on the Notification Settings page. 1312 1346 */ 1313 1347 function groups_screen_notification_settings() { -
src/bp-groups/bp-groups-template.php
diff --git src/bp-groups/bp-groups-template.php src/bp-groups/bp-groups-template.php index 0e3ec0a..6d8e5a9 100644
function bp_groups_get_profile_stats( $args = '' ) { 6260 6260 */ 6261 6261 return apply_filters( 'bp_groups_get_profile_stats', $r['output'], $r ); 6262 6262 } 6263 6264 /** 6265 * Output the Edit avatar template part for the group modal 6266 * 6267 * @since 2.?.0 6268 */ 6269 function bp_groups_modal_manage_avatar() { 6270 bp_attachments_get_template_part( 'avatars/index' ); 6271 } 6272 add_action( 'bp_modal_content_group-avatar', 'bp_groups_modal_manage_avatar' ); -
src/bp-members/bp-members-screens.php
diff --git src/bp-members/bp-members-screens.php src/bp-members/bp-members-screens.php index 2377fdc..46892db 100644
function bp_core_screen_activation() { 377 377 } 378 378 add_action( 'bp_screens', 'bp_core_screen_activation' ); 379 379 380 /** 381 * Handle the display for a user modal 382 * 383 * @since 2.?.0 384 */ 385 function bp_members_sreen_modal() { 386 $bp = buddypress(); 387 388 if ( bp_is_profile_component() && 'bp-modal' === bp_current_action() ) { 389 390 if ( ! bp_is_item_admin() ) { 391 return; 392 } 393 394 if ( ! empty( $_GET['action'] ) ) { 395 $bp->current_action = sanitize_file_name( $_GET['action'] ); 396 } 397 398 bp_set_is_modal( true ); 399 400 } elseif ( bp_is_user() && 'bp-modal' === bp_current_component() ) { 401 if ( ! empty( $_GET['action'] ) ) { 402 $bp->current_action = sanitize_file_name( $_GET['action'] ); 403 } 404 405 bp_set_is_modal( true ); 406 } 407 408 if ( bp_is_modal() ) { 409 bp_core_load_template( 'assets/modal' ); 410 } 411 } 412 add_action( 'bp_screens', 'bp_members_sreen_modal', 0 ); 413 380 414 /** Theme Compatibility *******************************************************/ 381 415 382 416 /** -
src/bp-templates/bp-legacy/buddypress/assets/modal.php
diff --git src/bp-templates/bp-legacy/buddypress/assets/modal.php src/bp-templates/bp-legacy/buddypress/assets/modal.php index e69de29..a755432 100644
1 <?php 2 /** 3 * BuddyPress Modal template 4 * 5 * This template is used to render the BuddyPress modal 6 * 7 * @since 2.? 8 * 9 * @package BuddyPress 10 * @subpackage bp-core 11 */ 12 13 $is_admin = false; 14 // Check if the modal was opened from an Admin page 15 // And enqueue admin style if needed 16 if ( ! empty( $_GET['is_admin'] ) ) { 17 $is_admin = true; 18 wp_enqueue_style( 'colors' ); 19 } 20 21 ?> 22 <!DOCTYPE html> 23 <!--[if IE 8]> 24 <html xmlns="http://www.w3.org/1999/xhtml" class="ie8" <?php language_attributes(); ?>> 25 <![endif]--> 26 <!--[if !(IE 8) ]><!--> 27 <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>> 28 <!--<![endif]--> 29 <head> 30 <meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php echo get_option( 'blog_charset' ); ?>" /> 31 <title><?php bloginfo('name') ?> › <?php bp_modal_title(); ?></title> 32 33 <?php bp_modal_header( $is_admin ); ?> 34 35 </head> 36 <body class="bp-core-ui <?php echo ( true === $is_admin ) ? 'bp-admin' : 'bp-front' ;?> no-js"> 37 <script type="text/javascript"> 38 document.body.className = document.body.className.replace('no-js', 'js'); 39 </script> 40 41 <div id="buddypress" class="bp-modal <?php echo ( true === $is_admin ) ? 'wrap' : '' ;?>"> 42 43 <?php bp_modal_content(); ?> 44 45 </div> 46 47 <?php bp_modal_footer( $is_admin ); ?> 48 49 </body> 50 </html> -
src/bp-templates/bp-legacy/css/buddypress.css
diff --git src/bp-templates/bp-legacy/css/buddypress.css src/bp-templates/bp-legacy/css/buddypress.css index aca34c6..e06917e 100644
Hello, this is the BuddyPress Legacy stylesheet. 22 22 3.9 - Private Messaging Threads 23 23 3.10 - Extended Profiles 24 24 3.11 - Widgets 25 3.12 - Modal 25 26 4.0 - Media Queries 26 27 4.1 - Smartphones Landscape 27 28 4.2 - Smartphones Portrait … … a.bp-title-button { 841 842 #buddypress form *[disabled="disabled"]{ 842 843 cursor: default; 843 844 opacity: .4; 844 } 845 } 846 847 body.modal-open .screen-reader-text, 845 848 .bp-screen-reader-text { 846 849 position: absolute; 847 850 margin: -1px; … … body.register #buddypress div.page ul { 1641 1644 } 1642 1645 1643 1646 /*-------------------------------------------------------------- 1647 3.11 - Modal 1648 --------------------------------------------------------------*/ 1649 body.bp-core-ui.bp-front { 1650 background-color: #FFF; 1651 } 1652 1653 body.bp-core-ui.bp-admin .bp-avatar-nav ul.avatar-nav-items li.current { 1654 border-bottom-color: #f1f1f1; 1655 } 1656 1657 #buddypress.bp-modal { 1658 margin: 1em; 1659 } 1660 1661 /*-------------------------------------------------------------- 1644 1662 4.0 - Media Queries 1645 1663 --------------------------------------------------------------*/ 1646 1664 /*-------------------------------------------------------------- -
src/bp-xprofile/bp-xprofile-admin.php
diff --git src/bp-xprofile/bp-xprofile-admin.php src/bp-xprofile/bp-xprofile-admin.php index d729a7e..2717144 100644
class BP_XProfile_User_Admin { 684 684 * @since BuddyPress (2.0.0) 685 685 */ 686 686 private function setup_actions() { 687 // Enqueue scripts688 add_action( 'bp_members_admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 10, 1 );689 690 687 // Register the metabox in Member's community admin profile 691 688 add_action( 'bp_members_admin_xprofile_metabox', array( $this, 'register_metaboxes' ), 10, 3 ); 692 689 … … class BP_XProfile_User_Admin { 695 692 } 696 693 697 694 /** 698 * Enqueue needed scripts.699 *700 * @access public701 * @since BuddyPress (2.3.0)702 */703 public function enqueue_scripts( $screen_id ) {704 if ( ( false === strpos( $screen_id, 'users_page_bp-profile-edit' )705 && false === strpos( $screen_id, 'profile_page_bp-profile-edit' ) )706 || bp_core_get_root_option( 'bp-disable-avatar-uploads' )707 || ! buddypress()->avatar->show_avatars708 || ! bp_attachments_is_wp_version_supported() ) {709 return;710 }711 712 /**713 * Get Thickbox714 *715 * We cannot simply use add_thickbox() here as WordPress is not playing716 * nice with Thickbox width/height see https://core.trac.wordpress.org/ticket/17249717 * Using media-upload might be interesting in the future for the send to editor stuff718 * and we make sure the tb_window is wide enougth719 */720 wp_enqueue_style ( 'thickbox' );721 wp_enqueue_script( 'media-upload' );722 723 // Get Avatar Uploader724 bp_attachments_enqueue_scripts( 'BP_Attachment_Avatar' );725 }726 727 /**728 695 * Register the xProfile metabox on Community Profile admin page. 729 696 * 730 697 * @access public … … class BP_XProfile_User_Admin { 1064 1031 'object' => 'user', 1065 1032 'type' => 'full', 1066 1033 'title' => $user->display_name 1067 ) ); ?> 1068 1069 <?php if ( bp_get_user_has_avatar( $user->ID ) ) : 1034 ) ); 1035 1036 // Add a BuddyPress modal to edit the avatar 1037 if ( ! bp_core_get_root_option( 'bp-disable-avatar-uploads' ) && bp_attachments_is_wp_version_supported() ) : 1038 bp_modal_link( array( 1039 'item_id' => $user->ID, 1040 'object' => 'user', 1041 'width' => 800, 1042 'height' => 400, 1043 'modal_title' => __( 'Edit Profile Photo', 'buddypress' ), 1044 'modal_action' => 'change-avatar', 1045 'link_text' => __( 'Edit Profile Photo', 'buddypress' ), 1046 'link_class' => array( 'bp-xprofile-avatar-user-edit' ), 1047 ) ); 1048 1049 elseif ( bp_get_user_has_avatar( $user->ID ) ) : 1070 1050 1071 1051 $query_args = array( 1072 1052 'user_id' => $user->ID, … … class BP_XProfile_User_Admin { 1082 1062 1083 1063 <a href="<?php echo esc_url( $delete_link ); ?>" title="<?php esc_attr_e( 'Delete Profile Photo', 'buddypress' ); ?>" class="bp-xprofile-avatar-user-admin"><?php esc_html_e( 'Delete Profile Photo', 'buddypress' ); ?></a></li> 1084 1064 1085 <?php endif; 1086 1087 // Load the Avatar UI templates if user avatar uploads are enabled and current WordPress version is supported 1088 if ( ! bp_core_get_root_option( 'bp-disable-avatar-uploads' ) && bp_attachments_is_wp_version_supported() ) : ?> 1089 <a href="#TB_inline?width=800px&height=400px&inlineId=bp-xprofile-avatar-editor" title="<?php esc_attr_e( 'Edit Profile Photo', 'buddypress' );?>" class="thickbox bp-xprofile-avatar-user-edit"><?php esc_html_e( 'Edit Profile Photo', 'buddypress' ); ?></a> 1090 <div id="bp-xprofile-avatar-editor" style="display:none;"> 1091 <?php bp_attachments_get_template_part( 'avatars/index' ); ?> 1092 </div> 1093 <?php endif; ?> 1065 <?php endif; ?> 1094 1066 1095 1067 </div> 1096 1068 <?php -
src/bp-xprofile/bp-xprofile-template.php
diff --git src/bp-xprofile/bp-xprofile-template.php src/bp-xprofile/bp-xprofile-template.php index dce9f49..fdcd96e 100644
function bp_profile_settings_visibility_select( $args = '' ) { 1322 1322 */ 1323 1323 return apply_filters( 'bp_profile_settings_visibility_select', $retval, $r, $args ); 1324 1324 } 1325 1326 /** 1327 * Output the Edit avatar template part for the user modal 1328 * 1329 * @since 2.?.0 1330 */ 1331 function bp_profile_modal_manage_avatar() { 1332 bp_attachments_get_template_part( 'avatars/index' ); 1333 } 1334 add_action( 'bp_modal_content_change-avatar', 'bp_profile_modal_manage_avatar' );