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 / Orbit slider with RWD techniques (basic example)
Last active December 11, 2015 09:59
This gist relates to zurb's foundation framework (3.4.2 at the time of writing). It gives a couple of examples on how you can use the built in visibility classes to show and hide content within an orbit slider in such a manner that it will actually restrict unnecessary asset downloading as per the method outlined in Tim Kadlec's article here htt…
<html>
<!-- Example slide to be used within an orbit slider -->
<!-- Be sure to set the fluid ratio in your javascript when using divs in orbit, see the docs for details -->
<!--Example 1: Do not download image on mobile, show text slide instead -->
<div id="slide-1" class="orbit-slide">
<div class="small-slide show-for-mobile"
<h2> A title </h2>
<p> This text will be displayed to mobile users </p>
</div>
<!-- this is the parent wrapper element with the visibility conditions applied to it -->
@aj-adl
aj-adl / gist:1a89da217645855035b1
Last active August 29, 2015 14:01
Display an ACF field below the product tile in the WooCommerce product loop
<?php
// don't include this opening PHP tag if you're copying this into your functions.php file etc
/**
* Renders a Product Subtitle
*
* Can change the html/classes etc as much as you want
*
* Requires Advanced Custom Fields to work
@aj-adl
aj-adl / testimonial_widget.php
Last active August 29, 2015 14:01
Testimonial Widget for question on WordPress Stack Exchange
<?php
// don't include opening php tag unless necessary
function testimonial_widget($args, $instance) {
global $post;
$current_page_id = $post->ID;
$current_page_id_string = strval($post->ID);
// This queries for post_type of testimonal with a
@aj-adl
aj-adl / gist:9880b04497130cb5ca72
Created May 19, 2014 23:28
Some CSS for a Stackexchange fix/explanation
/* Targets the base menu item, so all menu items,
Then we override this with other styles later for more specific cases like the current page or when we hover
I've used the ID of the menu here to make sure nothing overrides it as ID = more specific than Classes
*/
/* RULE 1 - ALL ITEMS IN THIS MENU */
#menu-menu-1 .menu-item {
@aj-adl
aj-adl / query_function.php
Last active August 29, 2015 14:01
Wine query - find terms based off posts in $a term and then get all matching posts grouped by $b term
<?php
// put these functions in your themes function file or similar (plugin file maybe?)
function find_all_producers_in_this_region( $region_slug ) {
global $post;
/*
* This function is written to work on any page as long as it is supplied the region slug somehow
*
* If this is being displayed/used on a region's archive page, this 1st query is superflous
@aj-adl
aj-adl / dequeue-woo.php
Last active August 29, 2015 14:13
Removed WooCommerce Scripts if not needed
<?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() ) { // if we're not on a Woocommerce page, dequeue all of these scripts
<?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' ) {
@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;
}
@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 / 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);