Skip to:
Content

BuddyPress.org

Ticket #6372: 6372.diff

File 6372.diff, 6.8 KB (added by boonebgorges, 8 years ago)
  • src/bp-core/bp-core-avatars.php

    diff --git src/bp-core/bp-core-avatars.php src/bp-core/bp-core-avatars.php
    index 786c09f..e347992 100644
    function bp_core_fetch_avatar( $args = '' ) { 
    671671                 * @param string $value  Default avatar for non-gravatar requests.
    672672                 * @param array  $params Array of parameters for the avatar request.
    673673                 */
    674                 $gravatar = apply_filters( 'bp_core_default_avatar_' . $params['object'], bp_core_avatar_default( 'local' ), $params );
     674                $gravatar = apply_filters( 'bp_core_default_avatar_' . $params['object'], bp_core_avatar_default( 'local', $params ), $params );
    675675        }
    676676
    677677        if ( true === $params['html'] ) {
    function bp_core_avatar_original_max_filesize() { 
    18451845 * Get the URL of the 'full' default avatar.
    18461846 *
    18471847 * @since 1.5.0
     1848 * @since 2.6.0 Introduced `$params` and `$object_type` parameters.
    18481849 *
    1849  * @param string $type 'local' if the fallback should be the locally-hosted version
    1850  *                     of the mystery-person, 'gravatar' if the fallback should be
    1851  *                     Gravatar's version. Default: 'gravatar'.
     1850 * @param string $type   'local' if the fallback should be the locally-hosted version
     1851 *                       of the mystery person, 'gravatar' if the fallback should be
     1852 *                       Gravatar's version. Default: 'gravatar'.
     1853 * @param array  $params Parameters passed to bp_core_fetch_avatar().
    18521854 * @return string The URL of the default avatar.
    18531855 */
    1854 function bp_core_avatar_default( $type = 'gravatar' ) {
     1856function bp_core_avatar_default( $type = 'gravatar', $params = array() ) {
    18551857        // Local override.
    18561858        if ( defined( 'BP_AVATAR_DEFAULT' ) ) {
    18571859                $avatar = BP_AVATAR_DEFAULT;
    function bp_core_avatar_default( $type = 'gravatar' ) { 
    18691871         * Filters the URL of the 'full' default avatar.
    18701872         *
    18711873         * @since 1.5.0
     1874         * @since 2.6.0 Added `$type` and `$params`.
    18721875         *
    18731876         * @param string $avatar URL of the default avatar.
     1877         * @param array  $params Params provided to bp_core_fetch_avatar().
    18741878         */
    1875         return apply_filters( 'bp_core_avatar_default', $avatar );
     1879        return apply_filters( 'bp_core_avatar_default', $avatar, $params );
    18761880}
    18771881
    18781882/**
    function bp_core_avatar_default( $type = 'gravatar' ) { 
    18821886 * defined.
    18831887 *
    18841888 * @since 1.5.0
     1889 * @since 2.6.0 Introduced `$object_type` parameter.
    18851890 *
    1886  * @param string $type 'local' if the fallback should be the locally-hosted version
    1887  *                     of the mystery-person, 'gravatar' if the fallback should be
    1888  *                     Gravatar's version. Default: 'gravatar'.
     1891 * @param string $type   'local' if the fallback should be the locally-hosted version
     1892 *                       of the mystery person, 'gravatar' if the fallback should be
     1893 *                       Gravatar's version. Default: 'gravatar'.
     1894 * @param array  $params Parameters passed to bp_core_fetch_avatar().
    18891895 * @return string The URL of the default avatar thumb.
    18901896 */
    1891 function bp_core_avatar_default_thumb( $type = 'gravatar' ) {
     1897function bp_core_avatar_default_thumb( $type = 'gravatar', $params = array() ) {
    18921898        // Local override.
    18931899        if ( defined( 'BP_AVATAR_DEFAULT_THUMB' ) ) {
    18941900                $avatar = BP_AVATAR_DEFAULT_THUMB;
    function bp_core_avatar_default_thumb( $type = 'gravatar' ) { 
    19061912         * Filters the URL of the 'thumb' default avatar.
    19071913         *
    19081914         * @since 1.5.0
     1915         * @since 2.6.0 Added `$type` and `$params`.
    19091916         *
    19101917         * @param string $avatar URL of the default avatar.
     1918         * @param string $type   'local' or 'gravatar'.
     1919         * @param string $params Params provided to bp_core_fetch_avatar().
    19111920         */
    1912         return apply_filters( 'bp_core_avatar_thumb', $avatar );
     1921        return apply_filters( 'bp_core_avatar_thumb', $avatar, $params );
    19131922}
    19141923
    19151924/**
  • src/bp-groups/bp-groups-filters.php

    diff --git src/bp-core/images/mystery-group-50.png src/bp-core/images/mystery-group-50.png
    new file mode 100644
    index 0000000..17f6dcf
    Binary files /dev/null and src/bp-core/images/mystery-group-50.png differ
    diff --git src/bp-core/images/mystery-group.png src/bp-core/images/mystery-group.png
    new file mode 100644
    index 0000000..e6bcd7f
    Binary files /dev/null and src/bp-core/images/mystery-group.png differ
    diff --git src/bp-groups/bp-groups-filters.php src/bp-groups/bp-groups-filters.php
    index d1bf7f9..0ef075f 100644
    add_filter( 'bp_get_total_group_count_for_user', 'bp_core_number_format' ); 
    7373// Activity component integration.
    7474add_filter( 'bp_activity_at_name_do_notifications', 'bp_groups_disable_at_mention_notification_for_non_public_groups', 10, 4 );
    7575
     76// Default group avatar.
     77add_filter( 'bp_core_avatar_default',       'bp_groups_default_avatar', 10, 3 );
     78add_filter( 'bp_core_avatar_default_thumb', 'bp_groups_default_avatar', 10, 3 );
     79
    7680/**
    7781 * Filter output of Group Description through WordPress's KSES API.
    7882 *
    function bp_groups_disable_at_mention_notification_for_non_public_groups( $send, 
    319323
    320324        return $send;
    321325}
     326
     327/**
     328 * Use the mystery group avatar for groups.
     329 *
     330 * @since 2.6.0
     331 *
     332 * @param string $avatar Current avatar src.
     333 * @param array  $params Avatar params.
     334 * @return string
     335 */
     336function bp_groups_default_avatar( $avatar, $params ) {
     337        if ( isset( $params['object'] ) && 'group' === $params['object'] ) {
     338                if ( isset( $params['type'] ) && 'thumb' === $params['type'] ) {
     339                        $file = 'mystery-group-50.png';
     340                } else {
     341                        $file = 'mystery-group.png';
     342                }
     343
     344                $avatar = buddypress()->plugin_url . "bp-core/images/$file";
     345        }
     346
     347        return $avatar;
     348}
  • src/bp-groups/bp-groups-template.php

    diff --git src/bp-groups/bp-groups-template.php src/bp-groups/bp-groups-template.php
    index dd454eb..fbfac50 100644
    function bp_group_avatar( $args = '' ) { 
    599599                        'css_id'     => $r['id'],
    600600                        'class'      => $r['class'],
    601601                        'width'      => $r['width'],
    602                         'height'     => $r['height']
     602                        'height'     => $r['height'],
     603                        'no_grav'    => true,
    603604                ) );
    604605
    605606                // If No avatar found, provide some backwards compatibility.
    function bp_new_group_avatar( $args = '' ) { 
    47054706                        'class'   => 'avatar',
    47064707                        'id'      => 'avatar-crop-preview',
    47074708                        'alt'     => __( 'Group photo', 'buddypress' ),
    4708                         'no_grav' => false
    47094709                ), 'get_new_group_avatar' );
    47104710
    47114711                // Merge parsed arguments with object specific data.
    function bp_get_group_has_avatar( $group_id = false ) { 
    51485148                $group_id = bp_get_current_group_id();
    51495149        }
    51505150
    5151         $group_avatar = bp_core_fetch_avatar( array(
     5151        $avatar_args = array(
    51525152                'item_id' => $group_id,
    51535153                'object'  => 'group',
    51545154                'no_grav' => true,
    51555155                'html'    => false,
    5156         ) );
     5156        );
     5157
     5158        $group_avatar = bp_core_fetch_avatar( $avatar_args );
    51575159
    5158         if ( bp_core_avatar_default( 'local' ) === $group_avatar ) {
     5160        if ( bp_core_avatar_default( 'local', $avatar_args ) === $group_avatar ) {
    51595161                return false;
    51605162        }
    51615163