Skip to content

Instantly share code, notes, and snippets.

View ckchaudhary's full-sized avatar

Chandan Chaudhary ckchaudhary

View GitHub Profile
@ckchaudhary
ckchaudhary / subsite-lostpassword
Created February 8, 2015 19:44
WordPress multisite forgot password url fix
<?php
/*
Plugin Name: Subsite Lostpassword
Plugin URI: http://webdeveloperswall.com/wordpress/multisite-forgot-password-url-issue/
Description: Updates URLs on susbites and in lost password request emails to point to the subsite where the lost password request started.
Version: 1.0
Author: ckchaudhary
Author URI: http://webdeveloperswall.com/wordpress/multisite-forgot-password-url-issue/
*/
@ckchaudhary
ckchaudhary / gist:751e32c10aca4c88e16c
Created July 3, 2015 08:23
Geo my wp - member locator - include other members
add_filter( 'gmw_fl_after_query_clauses', 'wdw_gmw_fl_qc_alter', 11, 2 );
/**
* Geo my wp - member locator addon.
* By default the plugin excludes all the users who have not provided their location info yet.
* This is bad. If i am not searching by location, but searching only by xprofile fields,
* the plugin still excludes users who have not entered their location info yet.
*
* This is a dirty hack to attemtp to fix that.
*
* @author ckchaudhary <ckchaudhary@hotmail.com>
@ckchaudhary
ckchaudhary / gist:4a930f90a92d21349957
Created July 8, 2015 11:00
og description for buddypress groups and activities
<?php
add_action( 'wp_head', 'dtk_buddypress_og_data', 11 );
function dtk_buddypress_og_data(){
if( bp_is_single_activity() ){
if ( bp_has_activities( 'display_comments=threaded&show_hidden=true&include=' . bp_current_action() ) ){
while ( bp_activities() ){
bp_the_activity();
$title = wp_strip_all_tags( bp_get_activity_action() );
$content = wp_strip_all_tags( bp_get_activity_content_body() );
$url = bp_activity_get_permalink( bp_get_activity_id() );
@ckchaudhary
ckchaudhary / gist:f0f9011d2b30665c1892
Created October 20, 2015 10:46
php merge and override arrays recursively
<?php
/**
* Merge given arrays, overriding $defaults array with values from $args array recursively.
*
* @author ckchaudahry
*
* @param $args array
* @param $defaults array
*
* @return array
@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'},
<li class="bbp-body">
<?php while ( bbp_topics() ) : bbp_the_topic(); ?>
<?php bbp_get_template_part( 'loop', 'single-topic' ); ?>
<?php endwhile; ?>
</li>
<?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; ?>
<?php if( function_exists( 'bbpresslmt_loadmore_button' ) ): ?>
<?php bbpresslmt_loadmore_button(); ?>
<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>
/*
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