Skip to content

Instantly share code, notes, and snippets.

@sbrajesh
sbrajesh / hide-admins-subscribers.php
Created July 1, 2013 20:28
hide admins and subscribers
add_action('bp_ajax_querystring','bpdev_exclude_users',20,2);
function bpdev_exclude_users($qs=false,$object=false){
//list of users to exclude
$excluded_user=join(',', bpdev_get_subscriber_admin_user_ids());//comma separated ids of users whom you want to exclude
if($object!='members')//hide for members only
return $qs;
@freekrai
freekrai / related.class.php
Last active January 4, 2016 03:49
Related Posts without a plugin.
@corsonr
corsonr / Add CPTs to search
Created October 13, 2012 09:54
Add CPTs to search
@mathetos
mathetos / ssl-for-images.php
Last active July 3, 2018 08:21
Force http/s for images in WordPress
/**
*
* Force http/s for images in WordPress
*
* Source:
* https://core.trac.wordpress.org/ticket/15928#comment:63
*
* @param $url
* @param $post_id
*
@opattison
opattison / gallery.html
Last active January 21, 2020 08:11
A Jekyll photo gallery sample, using a for loop in liquid and collections in YAML front matter. This is sort of pseudo-code, but is in a working state in this project: https://github.com/opattison/jeancflanagan 2013-08-13
@kloon
kloon / functions.php
Last active November 26, 2020 02:21
WooCommerce set tax exemption based on user role
<?php
add_filter( 'init', 'wc_tax_exempt_user_roles' );
function wc_tax_exempt_user_roles() {
if ( ! is_admin() ) {
global $woocommerce;
if ( current_user_can('wholesaler') || current_user_can('distributor') ) {
$woocommerce->customer->set_is_vat_exempt(true);
} else {
$woocommerce->customer->set_is_vat_exempt(false);
}
@messaoudi-mounir
messaoudi-mounir / exclude-members-by-roles.php
Last active December 15, 2020 12:42
Buddypress Exclude members by roles
function get_user_ids_by_role($role){
$users=array();
$founded_users = get_users( array( 'role' => $role ) );
if(!empty($founded_users)){
foreach((array)$founded_users as $user)
$users[]=$user->ID;
}
return $users;
}
@mikejolley
mikejolley / gist:2044101
Last active May 18, 2021 17:02
WooCommerce - Show number of items in cart and total
<a class="cart-contents" href="<?php echo wc_get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf ( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?> - <?php echo WC()->cart->get_cart_total(); ?></a>
@JDGrimes
JDGrimes / debug-hooks.php
Created February 15, 2014 14:42
WordPress plugin providing some functions to debug actions and filters.
<?php
/**
* Plugin Name: Debug Hooks
* Author: J.D. Grimes & Some other guy on the net
* Version: $ver$
* Description: Adds some functions you can use to debug actions and filters.
*/
/**
@g3d
g3d / gist:2709563
Last active February 7, 2024 15:21 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan