Skip to content

Instantly share code, notes, and snippets.

<?php
add_filter( 'bp_core_fetch_avatar', 'revert_to_default_wp_avatar', 80, 3 );//late load
function revert_to_default_wp_avatar( $img, $params, $item_id ){
//we are concerned only with users
if( $params['object']!='user' )
return $img;
//check if user has uploaded an avatar
//if not then revert back to wordpress core get_avatar method
//remove the filter first, or else it will go in infinite loop
@ckchaudhary
ckchaudhary / Printing menu items using recursion
Created January 26, 2014 03:11
A recursion example in javascript.
<script>
/*
* the problem: we have a random list of menu items with multiple level of heirarchy.
* we want the items to be printed into the desired order
*/
/* ordered properly just for understanding, this array is shuffled and made random before using */
var items = [
{id: 1, parent: 0, order: 2, title: 'Main Course'},
{id: 4, parent: 1, order: 3, title: 'Mughlai'},