Skip to content

Instantly share code, notes, and snippets.

View admcfajn's full-sized avatar

Adam McFadyen admcfajn

View GitHub Profile
if ( class_exists( 'Give_Cache_Setting' ) ) {
$settings = Give_Cache_Setting::get_settings();
// $version = Give_Cache_Setting::get_option( 'give_version' );
}
@admcfajn
admcfajn / fancy-owl-carousel.js
Last active June 3, 2021 23:35
Owl Carousel with media-players, youtube api, and fanciness
@admcfajn
admcfajn / add-menu-items-acf.php
Created November 4, 2020 19:55 — forked from erikawithak/add-menu-items-acf.php
Spit out the top menu items for a WP nav menu
// Load Top Level Nav Items into Radio Fields
function acf_load_field_choices( $field ) {
// reset choices
$choices = [];
$locations = get_nav_menu_locations();
$menu = get_term($locations['menu-1'], 'nav_menu');
$menu_items = wp_get_nav_menu_items($menu->term_id);
@admcfajn
admcfajn / acf_url_as_html.php
Last active January 14, 2021 21:18 — forked from paulsheldrake/acf_url_as_html.php
Output an ACF url field as html. Also allow for extra attributes.
/**
* Output ACF url field as HTML.
*
* Optionally add attributes to the link as an array.
*
* Example:
*
* acf_format_link('cp_flex_tab_1', ['class' => 'btn btn-large', 'data-id' => 123]);
*
* Will render the field like so.
@admcfajn
admcfajn / build_url_object.js
Last active June 30, 2020 07:10
Build URL Object
/*
* Build URL Object
* Returns dest: current url-base, sub_params_out: json-object with get-params as names & arrays built from csv-string
**/
function build_url_object(){
let
dest = window.location.origin + window.location.pathname,
params = window.location.search.replace( '?', '' ),
sub_params = null,
@admcfajn
admcfajn / accessible-facetwp-checkboxes.php
Created June 28, 2020 21:47
Accessible FacetWP Checkboxes
<?php
/*
* Accessible FacetWP Checkboxes
* Adds tab-index=0 to checkbox facets for keyboard-tab accessability
*/
add_filter( 'facetwp_facet_html', function( $output, $params ) {
if ( 'checkboxes' == $params['facet']['type'] ) {
$output = str_replace( 'data-value', 'tabindex="0" data-value', $output );
}
return $output;
@admcfajn
admcfajn / jquery-scrollto-id.js
Created November 14, 2019 02:26
jQuery to smooth-scroll to name/id/hash-anchors on link-click & page load
$("a[href*='#']").on('click',function(e){
e.preventDefault();
var $self = $(this);
if ( $( '#'+$self.attr('href').split('#').pop() ).length ) {
window.setTimeout(function(){
$('html, body').animate({
scrollTop: $( '#'+$self.attr('href').split('#').pop() ).offset().top -140
@admcfajn
admcfajn / hex-to-rgba.php
Last active March 20, 2021 00:56
RGB HEX #FF0000 to RGB 255 ( 255, 0, 0 ) in PHP
<?php
/**
* Convert RGB HEX to RGB 255 in PHP
*/
function hex_to_rgb ( $color_code ) {
$hex_string = str_replace( '#', '', $color_code );
$hex = [
@admcfajn
admcfajn / pmpro_woo_giftcode
Created April 9, 2014 06:29
PaidMembershipsPro Coupon Code on WooCommerce Checkout
/*
Add to your theme's functions.php or a plugin.
Requires PaidMembershipsPro, WooCommerce, & PMPro WooCommerce
This adds custom checkout fields to the woocommerce-checkout (The name & email of the person recieving the coupon-code)
& generates & emails a new coupon-code to the gift-recipient's email whenever a woo-commerce order is completed.
*/
/**
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
#bar{
width:200px;
height:25px;
border:1px solid black;
position:relative;