Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/22/2016 12:35:27 AM (8 years ago)
Author:
r-a-y
Message:

Blogs: Use WordPress' Site Icons as blog avatars.

If the current install is using WordPress 4.3+, we'll now use WordPress'
Site Icon as the site avatar in the Sites Directory:
https://codex.wordpress.org/Creating_a_Favicon#WordPress_Version_4.3_or_later

If no site icon is available, we'll fallback to the site owner's user
avatar as before. Under the hood, we are mirroring the site icon URLs to
blogmeta whenever a site icon is updated or deleted.

Devs can disable this functionality with the following filter:
add_filter( 'bp_is_blogs_site-icon_active', '__return_false' );

Fixes #6544.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-blogs/bp-blogs-functions.php

    r10971 r11150  
    477477
    478478/**
     479 * Syncs site icon URLs to blogmeta.
     480 *
     481 * @since 2.7.0
     482 *
     483 * @param int|string $old_value Old value
     484 * @param int|string $new_value New value
     485 */
     486function bp_blogs_update_option_site_icon( $old_value, $new_value ) {
     487    if ( 0 === $new_value ) {
     488        bp_blogs_update_blogmeta( get_current_blog_id(), 'site_icon_url_thumb', 0 );
     489        bp_blogs_update_blogmeta( get_current_blog_id(), 'site_icon_url_full',  0 );
     490    } else {
     491        // Save site icon URL as blogmeta.
     492        bp_blogs_update_blogmeta( get_current_blog_id(), 'site_icon_url_thumb', get_site_icon_url( bp_core_avatar_thumb_width() ) );
     493        bp_blogs_update_blogmeta( get_current_blog_id(), 'site_icon_url_full',  get_site_icon_url( bp_core_avatar_full_width()  ) );
     494    }
     495}
     496add_action( 'update_option_site_icon', 'bp_blogs_update_option_site_icon', 10, 2 );
     497
     498/**
    479499 * Deletes the 'url' blogmeta for a site.
    480500 *
Note: See TracChangeset for help on using the changeset viewer.