diff --git src/bp-blogs/bp-blogs-functions.php src/bp-blogs/bp-blogs-functions.php
index d66589cc9..fbc1ae1bd 100644
|
|
add_action( 'update_option_comment_moderation', 'bp_blogs_update_option_comment_ |
549 | 549 | * @param int|string $new_value New value |
550 | 550 | */ |
551 | 551 | function bp_blogs_update_option_site_icon( $old_value, $new_value ) { |
| 552 | $blog_id = get_current_blog_id(); |
| 553 | |
552 | 554 | if ( 0 === $new_value ) { |
553 | | bp_blogs_update_blogmeta( get_current_blog_id(), 'site_icon_url_thumb', 0 ); |
554 | | bp_blogs_update_blogmeta( get_current_blog_id(), 'site_icon_url_full', 0 ); |
| 555 | bp_blogs_update_blogmeta( $blog_id, 'site_icon_url_thumb', 0 ); |
| 556 | bp_blogs_update_blogmeta( $blog_id, 'site_icon_url_full', 0 ); |
555 | 557 | } else { |
556 | 558 | // Save site icon URL as blogmeta. |
557 | | bp_blogs_update_blogmeta( get_current_blog_id(), 'site_icon_url_thumb', get_site_icon_url( bp_core_avatar_thumb_width() ) ); |
558 | | bp_blogs_update_blogmeta( get_current_blog_id(), 'site_icon_url_full', get_site_icon_url( bp_core_avatar_full_width() ) ); |
| 559 | bp_blogs_update_blogmeta( $blog_id, 'site_icon_url_thumb', bp_blogs_get_site_icon_url( $blog_id, bp_core_avatar_thumb_width() ) ); |
| 560 | bp_blogs_update_blogmeta( $blog_id, 'site_icon_url_full', bp_blogs_get_site_icon_url( $blog_id, bp_core_avatar_full_width() ) ); |
559 | 561 | } |
560 | 562 | } |
561 | 563 | add_action( 'update_option_site_icon', 'bp_blogs_update_option_site_icon', 10, 2 ); |
… |
… |
function bp_blogs_validate_blog_form( $blog_name = '', $blog_title = '' ) { |
1563 | 1565 | |
1564 | 1566 | return wpmu_validate_blog_signup( $blog_name, $blog_title, $user ); |
1565 | 1567 | } |
| 1568 | |
| 1569 | /** |
| 1570 | * Gets the site icon URL even when BuddyPress is not activated on the main network site. |
| 1571 | * |
| 1572 | * @since 7.0.0 |
| 1573 | * |
| 1574 | * @param integer $blog_id The ID of the blog to get the site icon URL for. |
| 1575 | * @param integer $size The size of the site icon. |
| 1576 | * @return string The site icon URL |
| 1577 | */ |
| 1578 | function bp_blogs_get_site_icon_url( $blog_id = 0, $size = 512 ) { |
| 1579 | if ( is_multisite() && ! bp_is_network_activated() && ! bp_is_root_blog( $blog_id ) ) { |
| 1580 | $switched_blog = false; |
| 1581 | $url = ''; |
| 1582 | |
| 1583 | if ( $blog_id && get_current_blog_id() !== (int) $blog_id ) { |
| 1584 | switch_to_blog( $blog_id ); |
| 1585 | $switched_blog = true; |
| 1586 | } |
| 1587 | |
| 1588 | $site_icon_id = get_option( 'site_icon' ); |
| 1589 | |
| 1590 | if ( $site_icon_id ) { |
| 1591 | $site_icon_data = wp_get_attachment_metadata( $site_icon_id ); |
| 1592 | $sizes = wp_list_pluck( $site_icon_data['sizes'], 'width' ); |
| 1593 | |
| 1594 | sort( $sizes ); |
| 1595 | $closest = 'full'; |
| 1596 | |
| 1597 | foreach ( $sizes as $width ) { |
| 1598 | $closest = array( $width, $width ); |
| 1599 | |
| 1600 | if ( (int) $size < (int) $width ) { |
| 1601 | break; |
| 1602 | } |
| 1603 | } |
| 1604 | |
| 1605 | $url = wp_get_attachment_image_url( $site_icon_id, $closest ); |
| 1606 | } |
| 1607 | |
| 1608 | if ( $switched_blog ) { |
| 1609 | restore_current_blog(); |
| 1610 | } |
| 1611 | |
| 1612 | return $url; |
| 1613 | } |
| 1614 | |
| 1615 | return get_site_icon_url( $size, '', $blog_id ); |
| 1616 | } |
diff --git src/bp-blogs/bp-blogs-template.php src/bp-blogs/bp-blogs-template.php
index 4e923426d..44942fe17 100644
|
|
function bp_blog_avatar( $args = '' ) { |
380 | 380 | |
381 | 381 | // Never attempted to fetch site icon before; do it now! |
382 | 382 | if ( '' === $site_icon ) { |
383 | | switch_to_blog( $blog_id ); |
384 | | |
385 | 383 | // Fetch the other size first. |
386 | 384 | if ( 'full' === $r['type'] ) { |
387 | 385 | $size = bp_core_avatar_thumb_width(); |
… |
… |
function bp_blog_avatar( $args = '' ) { |
391 | 389 | $save_size = 'full'; |
392 | 390 | } |
393 | 391 | |
394 | | $site_icon = get_site_icon_url( $size ); |
| 392 | $site_icon = bp_blogs_get_site_icon_url( $blog_id, $size ); |
| 393 | |
395 | 394 | // Empty site icons get saved as integer 0. |
396 | 395 | if ( empty( $site_icon ) ) { |
397 | 396 | $site_icon = 0; |
… |
… |
function bp_blog_avatar( $args = '' ) { |
403 | 402 | // Now, fetch the size we want. |
404 | 403 | if ( 0 !== $site_icon ) { |
405 | 404 | $size = 'full' === $r['type'] ? bp_core_avatar_full_width() : bp_core_avatar_thumb_width(); |
406 | | $site_icon = get_site_icon_url( $size ); |
| 405 | $site_icon = bp_blogs_get_site_icon_url( $blog_id, $size ); |
407 | 406 | } |
408 | 407 | |
409 | 408 | // Sync site icon to blogmeta. |
410 | 409 | bp_blogs_update_blogmeta( $blog_id, "site_icon_url_{$r['type']}", $site_icon ); |
411 | | |
412 | | restore_current_blog(); |
413 | 410 | } |
414 | 411 | |
415 | 412 | // We have a site icon. |
diff --git src/bp-core/admin/bp-core-admin-tools.php src/bp-core/admin/bp-core-admin-tools.php
index f3c588080..47c50d033 100644
|
|
function bp_admin_repair_list() { |
143 | 143 | __( 'Repopulate site tracking records.', 'buddypress' ), |
144 | 144 | 'bp_admin_repair_blog_records', |
145 | 145 | ); |
| 146 | |
| 147 | if ( bp_is_active( 'blogs', 'site-icon' ) ) { |
| 148 | $repair_list[91] = array( |
| 149 | 'bp-blog-site-icons', |
| 150 | __( 'Repair site tracking site icons/blog avatars synchronization.', 'buddypress' ), |
| 151 | 'bp_admin_repair_blog_site_icons', |
| 152 | ); |
| 153 | } |
146 | 154 | } |
147 | 155 | |
148 | 156 | // Emails: |
… |
… |
function bp_admin_repair_blog_records() { |
312 | 320 | return array( 0, sprintf( $statement, $result ) ); |
313 | 321 | } |
314 | 322 | |
| 323 | /** |
| 324 | * Repair site icons/blog avatars synchronization. |
| 325 | * |
| 326 | * @since 7.0.0 |
| 327 | * |
| 328 | * @return array |
| 329 | */ |
| 330 | function bp_admin_repair_blog_site_icons() { |
| 331 | |
| 332 | /* translators: %s: the result of the action performed by the repair tool */ |
| 333 | $statement = __( 'Repairing site icons/blog avatars synchronization… %s', 'buddypress' ); |
| 334 | |
| 335 | // Run function if blogs component is active. |
| 336 | if ( bp_is_active( 'blogs', 'site-icon' ) ) { |
| 337 | $blog_ids = get_sites( |
| 338 | array( |
| 339 | 'fields' => 'ids', |
| 340 | 'archived' => 0, |
| 341 | 'mature' => 0, |
| 342 | 'spam' => 0, |
| 343 | 'deleted' => 0, |
| 344 | ) |
| 345 | ); |
| 346 | |
| 347 | $sizes = array( |
| 348 | array( |
| 349 | 'key' => 'site_icon_url_full', |
| 350 | 'size' => bp_core_avatar_full_width(), |
| 351 | ), |
| 352 | array( |
| 353 | 'key' => 'site_icon_url_thumb', |
| 354 | 'size' => bp_core_avatar_thumb_width(), |
| 355 | ), |
| 356 | ); |
| 357 | |
| 358 | foreach ( $blog_ids as $blog_id ) { |
| 359 | $site_icon = 0; |
| 360 | |
| 361 | foreach ( $sizes as $size ) { |
| 362 | $site_icon = bp_blogs_get_site_icon_url( $blog_id, $size['size'] ); |
| 363 | if ( ! $site_icon ) { |
| 364 | $site_icon = 0; |
| 365 | } |
| 366 | |
| 367 | bp_blogs_update_blogmeta( $blog_id, $size['key'], $site_icon ); |
| 368 | } |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | // All done! |
| 373 | return array( 0, sprintf( $statement, __( 'Complete!', 'buddypress' ) ) ); |
| 374 | } |
| 375 | |
315 | 376 | /** |
316 | 377 | * Recalculate the total number of active site members. |
317 | 378 | * |
diff --git src/bp-templates/bp-nouveau/common-styles/_bp_blogs_loop.scss src/bp-templates/bp-nouveau/common-styles/_bp_blogs_loop.scss
index 279215208..3fdf9a1fd 100644
|
|
|
7 | 7 | |
8 | 8 | li { |
9 | 9 | |
| 10 | .item-avatar { |
| 11 | |
| 12 | img.avatar-150 { |
| 13 | max-width: 150px; |
| 14 | max-height: 150px; |
| 15 | } |
| 16 | |
| 17 | img.avatar-50 { |
| 18 | max-width: 50px; |
| 19 | max-height: 50px; |
| 20 | } |
| 21 | } |
| 22 | |
10 | 23 | @include medium-up() { |
11 | 24 | |
12 | 25 | .item-block { |
diff --git src/bp-templates/bp-nouveau/css/buddypress-rtl.css src/bp-templates/bp-nouveau/css/buddypress-rtl.css
index 800259559..d69e995d1 100644
|
|
form.ac-form .ac-reply-content input { |
1774 | 1774 | * @section 3.2 - Blogs Loop |
1775 | 1775 | *---------------------------------------------------------- |
1776 | 1776 | */ |
| 1777 | .buddypress-wrap .blogs-list li .item-avatar img.avatar-150 { |
| 1778 | max-width: 150px; |
| 1779 | max-height: 150px; |
| 1780 | } |
| 1781 | |
| 1782 | .buddypress-wrap .blogs-list li .item-avatar img.avatar-50 { |
| 1783 | max-width: 50px; |
| 1784 | max-height: 50px; |
| 1785 | } |
| 1786 | |
1777 | 1787 | @media screen and (min-width: 46.8em) { |
1778 | 1788 | .buddypress-wrap .blogs-list li .item-block { |
1779 | 1789 | float: none; |
diff --git src/bp-templates/bp-nouveau/css/buddypress.css src/bp-templates/bp-nouveau/css/buddypress.css
index 43aba64cf..c80c057ce 100644
|
|
form.ac-form .ac-reply-content input { |
1774 | 1774 | * @section 3.2 - Blogs Loop |
1775 | 1775 | *---------------------------------------------------------- |
1776 | 1776 | */ |
| 1777 | .buddypress-wrap .blogs-list li .item-avatar img.avatar-150 { |
| 1778 | max-width: 150px; |
| 1779 | max-height: 150px; |
| 1780 | } |
| 1781 | |
| 1782 | .buddypress-wrap .blogs-list li .item-avatar img.avatar-50 { |
| 1783 | max-width: 50px; |
| 1784 | max-height: 50px; |
| 1785 | } |
| 1786 | |
1777 | 1787 | @media screen and (min-width: 46.8em) { |
1778 | 1788 | .buddypress-wrap .blogs-list li .item-block { |
1779 | 1789 | float: none; |
diff --git tests/phpunit/testcases/blogs/template.php tests/phpunit/testcases/blogs/template.php
index 3e7dd11e2..db0dc0f85 100644
|
|
class BP_Tests_Blogs_Template extends BP_UnitTestCase { |
431 | 431 | ) ); |
432 | 432 | |
433 | 433 | add_filter( 'get_site_icon_url', array( $this, 'filter_blog_avatar' ) ); |
| 434 | add_filter( 'bp_is_network_activated', '__return_true' ); |
434 | 435 | |
435 | 436 | $avatar = bp_get_blog_avatar( array( |
436 | 437 | 'type' => 'full', |
… |
… |
class BP_Tests_Blogs_Template extends BP_UnitTestCase { |
441 | 442 | 'class' => 'avatar', |
442 | 443 | ) ); |
443 | 444 | |
| 445 | remove_filter( 'bp_is_network_activated', '__return_true' ); |
444 | 446 | remove_filter( 'get_site_icon_url', array( $this, 'filter_blog_avatar' ) ); |
445 | 447 | $blogs_template = $reset_blogs_template; |
446 | 448 | |