Skip to content

Instantly share code, notes, and snippets.

View chrismcintosh's full-sized avatar

Chris Mcintosh chrismcintosh

View GitHub Profile
<?php
/*
Change cancellation to set expiration date for next payment instead of cancelling immediately.
Assumes orders are generated for each payment (i.e. your webhooks/etc are setup correctly).
Since 2015-09-21 and PMPro v1.8.5.6 contains code to look up next payment dates via Stripe and PayPal Express APIs.
*/
//before cancelling, save the next_payment_timestamp to a global for later use. (Requires PMPro 1.8.5.6 or higher.)
<?php
/**
* WC Ajax Product Filter by Category
*/
if (!class_exists('WCAPF_Tag_Filter_Widget')) {
class WCAPF_Tag_Filter_Widget extends WP_Widget {
/**
* Register widget with WordPress.
*/
function __construct() {
@chrismcintosh
chrismcintosh / pmp_pro_echo_body_class.php
Last active December 28, 2017 20:45
If you need to target specific elements with css based on membership level in paid memberships pro here's a snippet.
<?php
/* Dont Include This Comment or the opening <?php tag */
/*************************************
*
* Add a body class correlating to the users
* memberhsip level in Paid Memberships Pro
* looks like - 'member-level-1'
*
**************************************/
<?php
add_action('genesis_setup', 'residence_post_meta_setup');
function residence_post_meta_setup() {
/* Set the post type */
add_action( 'pre_get_posts', 'set_residence_post_meta' );
function set_residence_post_meta( $query ) {
$query->set( 'post_type', 'residence');
$query->set( 'posts_per_page', -1 );
}
<?php
$image = get_sub_field('background_image');
if( !empty($image) ):
// thumbnail
$size = 'large';
$thumb = $image['sizes'][ $size ];
endif;
<?php
// Define ACF component markup
function sby_display_flexible_content() {
// loop through the rows of data
while ( have_rows('flexible_content') ) : the_row();
// List Components for ACF Page Builder
if( get_row_layout() == 'department_intro' ) {
include get_stylesheet_directory() . '/lib/acf/flexible-components/department-intro.php';
} elseif( get_row_layout() == 'featured_actions' ) {
include get_stylesheet_directory() . '/lib/acf/flexible-components/featured-actions.php';
@chrismcintosh
chrismcintosh / acf_populate_custom_tax.php
Last active April 30, 2017 15:59
Some boilerplate code for populating an ACF select box with custom taxonomies and then querying a custom post type using the result of that select box.
<?php
/*
Assumes a custom post type called 'staff'
Assumes that there is a custom taxonomy called 'department'.
Every department that has at least one staff member assigned to it will
populate a select field that is specified in Advanced Custom Fields.
Using that Select field we can then do a query on a custom post type
in this case staff and grab only the staff with our selected department.
jQuery(document).ready(function ($) {
//On load run the function defined below
slickActionsScreenSize();
//Run the function on window resize
jQuery( window ).resize( function() {
slickActionsScreenSize();
});
@chrismcintosh
chrismcintosh / independant-off-canvas-size
Created December 6, 2016 17:15
If you would like to set each off-canvas area separately you can use the below code as a model for modify a single off-canvas area
/* Set foundation 6 off canvas size independant of global settings*/
$offcanvas-right-size: 300px;
.is-open-right {
-webkit-transform: translateX(-$offcanvas-right-size);
-ms-transform: translateX(-$offcanvas-right-size);
transform: translateX(-$offcanvas-right-size);
}