Skip to content

Instantly share code, notes, and snippets.

View bappi-d-great's full-sized avatar

Bappi D great bappi-d-great

View GitHub Profile
@bappi-d-great
bappi-d-great / code.js
Created August 25, 2015 21:38
WPM Event+ - remove weekend dates from calendar
jQuery(function($) {
$('.eab-monthly_calendar .eab-calendar-title td[colspan=3]').removeAttr('colspan');
$('.eab-monthly_calendar thead tr').not('.eab-calendar-title').find('th').eq(-1).remove();
$('.eab-monthly_calendar thead tr').not('.eab-calendar-title').find('th').eq(-1).remove();
$('.eab-monthly_calendar tr').not('.eab-calendar-title').each(function() {
$(this).find('td').eq(-1).remove();
$(this).find('td').eq(-1).remove();
});
});
@bappi-d-great
bappi-d-great / code.php
Last active August 29, 2015 14:04
WPMU Pro Site - make the badge image clickable / add a link
<?php
add_action( 'wp_footer', 'make_clickable_image_in_pro_badge' );
function make_clickable_image_in_pro_badge() {
$link = "YOUR_DESIRED_LINK";
?>
<script type="text/javascript">
jQuery(function($){
$('.psts_widget')
.css({
'cursor': 'pointer'
@bappi-d-great
bappi-d-great / code.php
Created July 25, 2014 16:02
Show all upcoming events in events archive page
<?php
add_filter( 'eab-collection-upcoming-start_timestamp', '__all_events_start' );
add_filter( 'eab-collection-upcoming-end_timestamp', '__all_events_end' );
function __all_events_start() {
return date('Y-m-d') . ' 00:01';
}
function __all_events_end() {
@bappi-d-great
bappi-d-great / code.php
Last active August 29, 2015 14:04
Reorder or rearrange buddypress menu items
<?php
function my_change_profile_tab_order() {
global $bp;
$bp->bp_nav['settings']['position'] = 10;
$bp->bp_nav['activity']['position'] = 20;
$bp->bp_nav['friends']['position'] = 30;
$bp->bp_nav['groups']['position'] = 40;
$bp->bp_nav['blogs']['position'] = 50;
$bp->bp_nav['messages']['position'] = 60;
@bappi-d-great
bappi-d-great / code.php
Created July 25, 2014 16:04
Show messages in reverse order in buddypress message inbox
<?php
// Replace the code of /members/single/messages/single.php with this
?>
<div id="message-thread" role="main">
<?php do_action( 'bp_before_message_thread_content' ); ?>
<?php if ( bp_thread_has_messages(array('order'=>'DESC')) ) : ?>
@bappi-d-great
bappi-d-great / code.html
Created July 25, 2014 16:05
A very simple jQuery text slider
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.js"></script>
<script type="text/javascript">
jQuery(function($){
$('#main_imag').load(function() {
setTimeout(function() {
$('#text1').animate({
left: 0
})
}, 1000);
setTimeout(function() {
@bappi-d-great
bappi-d-great / code.php
Created July 25, 2014 16:09
WPM Pro Sites: Add pro level expire notice in admin bar for sub sites
<?php
add_action( 'admin_bar_menu', 'add_extension', 999 );
function add_extension($wp_admin_bar) {
if( !is_main_site() ) {
$id = get_current_blog_id();
$expire = ProSites::get_expire($id);
$diff = $expire - time();
$years = floor($diff / (365*60*60*24));
$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
@bappi-d-great
bappi-d-great / code.php
Created July 25, 2014 16:15
Replace duplicate nickname and display name with username in WordPress
<?php
// A dirty script by Ashok
/*
* adding action when user profile is updated
*/
add_action('personal_options_update', 'check_display_name');
add_action('edit_user_profile_update', 'check_display_name');
function check_display_name($user_id) {
global $wpdb;
// Getting user data and user meta data
@bappi-d-great
bappi-d-great / gist:46fdb003ffac3e043533
Created July 25, 2014 16:15
Protect Duplicate nickname and display name for user in WordPress
<?php
add_action('personal_options_update', 'check_display_name');
add_action('edit_user_profile_update', 'check_display_name');
function check_display_name($user_id) {
global $wpdb;
$err['display'] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(ID) FROM $wpdb->users WHERE display_name = %s AND ID <> %d", $_POST['display_name'], $_POST['user_id']));
$err['nick'] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(ID) FROM $wpdb->users as users, $wpdb->usermeta as meta WHERE users.ID = meta.user_id AND meta.meta_key = 'nickname' AND meta.meta_value = %s AND users.ID <> %d", $_POST['nickname'], $_POST['user_id']));
foreach($err as $key => $e) {
if($e >= 1) {
$err[$key] = $_POST['username'];
@bappi-d-great
bappi-d-great / code.php
Created July 25, 2014 16:16
How to detect bot in your website in php
<?php
function is_bot() {
$spiders = array(
"abot",
"dbot",
"ebot",
"hbot",
"kbot",