Skip to content

Instantly share code, notes, and snippets.

View aj-adl's full-sized avatar
💅
vibing

Alex James Bishop aj-adl

💅
vibing
View GitHub Profile
@aj-adl
aj-adl / facewp-multi-filter.js
Created July 7, 2020 08:39
Fix for Facet WP - enable the use of multiple instances of the same facet on a single page
/* Example shows how to do it with checkboxes */
$(document).on('facetwp-loaded', function {
/* deregister the click handler for the filter(s) you're targeting */
$(document).off( 'click', '.facetwp-type-checkboxes .facetwp-checkbox:not(.disabled)');
/* register our own */
$(document).on('click', '.facetwp-type-checkboxes .facetwp-checkbox:not(.disabled)', my_custom_handle_facet_click );
} );
@aj-adl
aj-adl / hide-admin.php
Created May 2, 2019 04:56
Hide the ACF menu in the Wordpress admin.
<?php
function my_namespace_remove_acf_from_admin_menu(){
/* How you determing if it's production or not is up to you, we set a constant */
if ( ! defined( 'WP_ENV' ) || WP_ENV !== 'production ) return;
/* You can whitelist some users by id, or with a little more code, their username etc*/
$whitlisted_users = [];
@aj-adl
aj-adl / git-deploy-branch.sh
Created February 13, 2018 06:51
Command to automate branch switching and merging when using deployment braches
#!/usr/bin/env bash
function gdpl (){
set -e
local RED=`tput setaf 1`
local GREEN=`tput setaf 2`
local BLUE=`tput setaf 6`
local YELLOW=`tput setaf 3`
local PURPLE=`tput setaf 5`
@aj-adl
aj-adl / excludes.conf
Created December 14, 2017 02:16
bitbucket-sage-rsync
/node_modules
/bower_components
/assets
.git*
@aj-adl
aj-adl / 0_reuse_code.js
Created November 4, 2015 05:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@aj-adl
aj-adl / jQuery-noConflict-wrapper.js
Created January 13, 2015 22:39
Standard jQuery noConflict wrapper - waits till $.ready event before executing. Very common in WP JS code
jQuery(document).ready(function($) {
// Inside of this function, $() will work as an alias for jQuery()
// and other libraries also using $ will not be accessible under this shortcut
// Put your code here e.g. $('#page').find('.comments').each( myFunc()); etc
});
@aj-adl
aj-adl / jQuery-noConflict-wrapper-immediate.js
Created January 13, 2015 22:37
jQuery noConflict wrapper that executes immediately instead of waiting for the ready event
(function($) {
// Inside of this function, $() will work as an alias for jQuery()
// and other libraries also using $ will not be accessible under this shortcut
// Put your code here e.g. $('#page').find('.comments').each( myFunc()); etc
})(jQuery);
@aj-adl
aj-adl / cf7-remove-custom.php
Last active June 22, 2018 02:08
Intermediate CF7 example of Style/JS removal
<?php
// Make sure you only use opening / closing tags if needed!!!
// Removes Contact Form 7 scripts and Styles except on contact-us page
add_action( 'wp', 'BSHP_cf7_conditionally_load_assets_custom' );
// returns false, used for setting filters to false
function return_false() {
return false;
}
@aj-adl
aj-adl / cf7-remove-styles-scripts.php
Last active August 29, 2015 14:13
Removes Contact Form 7 Styles and Scripts Except on the 'Contact Us' page
<?php
// Make sure you only use opening / closing tags if needed!!!
// Removes Contact Form 7 scripts and Styles except on contact-us page
add_action( 'wp', 'BSHP_cf7_conditionally_load_assets_simple' );
// returns false, used for setting filters to false
function return_false() {
return false;
}
<?php
// Make sure you only use opening / closing tags if needed!!!
// Late priority so WC can't jump back in and re-enqueue them
add_action( 'wp_enqueue_scripts', 'woocommerce_de_script', 100 );
// Removes WooCommerce Scripts on non shop/product/cart/checkout pages
function woocommerce_de_script() {
if ( function_exists( 'is_woocommerce' ) ) {
if ( !is_shop() && !is_cart() && !is_checkout() && !is_account_page() && !is_page_template( 'custom-template.php' ) {