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 / Remove joined group notification from sitewide activity.php
Created September 26, 2014 13:42
Remove joined group notification from sitewide activity
<?php
add_action('bp_has_activities','my_denied_activity_new_member', 999, 2 );
function my_denied_activity_new_member( $a, $activities ){
foreach( $activities->activities as $key => $activity ){
if ( $activity->type =='joined_group') {
unset( $activities->activities[$key] );
$activities->activity_count = $activities->activity_count-1;
$activities->total_activity_count = $activities->total_activity_count-1;
$activities->pag_num = $activities->pag_num -1;
@bappi-d-great
bappi-d-great / Add cart in menu with quantity and price.php
Last active August 3, 2017 09:27
Add cart in menu with quantity and price
<?php
add_filter( 'wp_nav_menu_items', 'add_cart_link', 10, 2 );
function add_cart_link( $items, $args ) {
$cart = MP_Cart::get_instance();
$items .= '<li class="menu_cart">'.mp_cart_link( false, false, 'Cart <span class="mp_custom_cart_icon"></span> (<span class="mp_custom_cart_details"> ' . $cart->item_count( false, false ) . ' - £' . $cart->total( false ) . ' </span>)' ).'</li>';
return $items;
}
add_action( 'wp_footer', 'add_cart_value' );
@bappi-d-great
bappi-d-great / Get current page url in php.php
Created October 4, 2014 09:22
Get current page url in php
<?php
function current_page_url() {
$url = 'http';
if ($_SERVER["HTTPS"] == "on")
$url .= "s";
$url .= "://";
if ($_SERVER["SERVER_PORT"] != "80")
$url .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
else
@bappi-d-great
bappi-d-great / hexa-to-rgb.php
Last active August 29, 2015 14:07
How to convert hexa color value to RGB value
<?php
function hex2rgb($hex) {
$hex = str_replace("#", "", $hex);
if(strlen($hex) == 3) {
$r = hexdec(substr($hex,0,1).substr($hex,0,1));
$g = hexdec(substr($hex,1,1).substr($hex,1,1));
$b = hexdec(substr($hex,2,1).substr($hex,2,1));
} else {
@bappi-d-great
bappi-d-great / Defer parsing of javascript to improve performance in wordpress.php
Created October 4, 2014 21:44
Defer parsing of javascript to improve performance in wordpress
<?php
function defer_parsing_of_js ( $url ) {
if ( FALSE === strpos( $url, '.js' ) ) return $url;
if ( strpos( $url, 'jquery.js' ) ) return $url;
return "$url' defer ";
}
add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );
@bappi-d-great
bappi-d-great / Get all subsites of an user in WordPress.hp
Created November 3, 2014 18:11
Get all subsites of an user in WordPress
<?php
function show_my_sites_cb( ) {
if( ! is_user_logged_in() ){
return '';
}
else{
$blogs = '<ul>';
$user_ID = get_current_user_id();
$user_blogs = get_blogs_of_user( $user_id );
@bappi-d-great
bappi-d-great / Shortcode to show instructor lists in WPMU coursepress pro.php
Last active August 29, 2015 14:09
Shortcode to show instructor lists in WPMU coursepress pro
<?php
/*
* use [get_all_instructors]
* Change wp-content/plugins/ to correct plugins folder if you use a separate folder for plugins at line 9
*/
add_shortcode( 'get_all_instructors', 'get_all_instructors_cb' );
function get_all_instructors_cb() {
include ABSPATH . 'wp-content/plugins/coursepress/includes/classes/class.instructorsearch.php';
if ( isset( $_GET['page_num'] ) ) {
@bappi-d-great
bappi-d-great / Sharing site info across the network.php
Created November 20, 2014 05:56
Sharing site info across the network
<?php
/*
Plugin Name: Share across network
Plugin URI: http://premium.wpmudev.org/
Description: A very simple widget plugin to share info across the network
Version: 1.0.1
Author: Ashok (Incsub)
Author URI: http://bappi-d-great.com
License: GNU General Public License (Version 2 - GPLv2)
Network: true
@bappi-d-great
bappi-d-great / Send email to admin when an appointment is cancelled.php
Created November 22, 2014 17:36
Send email to admin when an appointment is cancelled
<?php
function my_app_email_on_appointment_cancelled ($app_id) {
global $appointments;
$to = $appointments->get_admin_email();
wp_mail($to, 'An appointment has been cancelled', "An appointment with ID {$app_id} has just been cancelled.");
}
add_action('app-appointments-appointment_cancelled', 'my_app_email_on_appointment_cancelled');
@bappi-d-great
bappi-d-great / WPMU Directory plugin shortcode to exclude listing category.php
Created November 24, 2014 13:29
WPMU Directory plugin shortcode to exclude Listing category
<?php
/*
*
* [dr_list_categories_with_exclude style="list" exclude="14"] where 14 is the listing category ID
*
*/
function list_categories_sc_custom($atts, $content = null)
{