Skip to content

Instantly share code, notes, and snippets.

View ckchaudhary's full-sized avatar

Chandan Chaudhary ckchaudhary

View GitHub Profile
/*
http://webdeveloperswall.com/javascript/floating-sidebar-for-twentythirteen
*/
var jq=jQuery.noConflict();
var wdw_fs_status = "unaltered";
jq(window).load(function(){
//if there is a sidebar, in the first place
<script>
jQuery(document).ready(function($){
$(".wpcf7").on( 'mailsent.wpcf7', function(){
var redirect_to = $(this).find('#wdw_redirect_to_url').val();
if( typeof(redirect_to)!=='undefined' && redirect_to!='' ){
window.location.href= redirect_to;
}
});
});
</script>
<?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
<li class="bbp-body">
<?php while ( bbp_topics() ) : bbp_the_topic(); ?>
<?php bbp_get_template_part( 'loop', 'single-topic' ); ?>
<?php endwhile; ?>
<?php if( function_exists( 'bbpresslmt_loadmore_button' ) ): ?>
<?php bbpresslmt_loadmore_button(); ?>
<?php if( function_exists( 'bbpresslmt_loadmore_button' ) ): ?>
<?php bbpresslmt_loadmore_button(); ?>
<?php endif; ?>
<li class="bbp-body">
<?php while ( bbp_topics() ) : bbp_the_topic(); ?>
<?php bbp_get_template_part( 'loop', 'single-topic' ); ?>
<?php endwhile; ?>
</li>
@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'},