Skip to content

Instantly share code, notes, and snippets.

@keithdevon
keithdevon / relevanssi-custom-functions.php
Last active January 25, 2024 12:51
Relevanssi job search
// filter relevanssi based on job_region query
add_filter('relevanssi_modify_wp_query', 'region_tax_query');
function region_tax_query($query) {
$tax_query = array();
if (!empty($query->query_vars['job_region'])) {
$tax_query[] = array(
'taxonomy' => 'region',
'field' => 'id',
'terms' => $query->query_vars['job_region']
@keithdevon
keithdevon / manual-gravity-forms
Created September 25, 2014 21:05
Manually create entries and send notifications with Gravity Forms
<?php
// Manually create entries and send notifications with Gravity Forms
$form_id = 10;
// add entry
$entry = array(
"form_id" => $form_id,
"1" => "Entry for field ID 1",
@keithdevon
keithdevon / hd-gutenberg-column-fix.css
Last active December 18, 2020 22:26
Gutenberg columns block alignment fix
:root {
--gutter: 32px;
}
@media screen and (min-width: 782px) {
/* For the '25's' in the 25 / 50 / 25 variation */
.wp-block-column[style='flex-basis:25%'] {
flex-basis: calc(var(--gutter) * 2) !important;
@keithdevon
keithdevon / custom-template.php
Created September 24, 2014 10:27
Load WordPress page templates from a plugin
// This is the page template file
@keithdevon
keithdevon / _layout.scss
Last active March 27, 2018 09:55
Updated _layout.scss file to output all Neat grid settings at each breakpoint
/*
* Layout debugging display
*/
body {
&.env--local {
.site-wrapper {
&:after {
content: 'default';
position: fixed;
@keithdevon
keithdevon / _layout.scss
Last active March 27, 2018 09:53
Adds breakpoint debugging output when using Neat 2 grid system
/*
* Layout debugging display
*/
body {
&.env--local {
&:after {
content: 'default';
position: fixed;
bottom: 0;
right: 0;
@keithdevon
keithdevon / _grid-overlay.scss
Created March 27, 2018 09:39
Styling for the Neat 2 grid overlay
/*
* Layout debugging display
*/
body {
&.env--local {
.grid-overlay {
display: none;
position: fixed;
z-index: 99999999;
@keithdevon
keithdevon / grid-overlay.php
Created March 27, 2018 09:33
Function to append a grid overlay div to the body depending on the environment
<?php
/**
* This function appends a grid overlay div to the body depending on the environment.
*
*/
function tgf_add_grid_overlay_debugging_helper() {
if ( WP_LOCAL ) {
// echo the script
<?php
/**
* This function appends a class to the body depending on the environment.
*
* @param array $classes current body classes.
*
* @return array $classes any modification to the class array.
*/
function tgf_add_environment_class( $classes ) {
@keithdevon
keithdevon / lazy-load
Last active December 22, 2017 00:52
Lazy loading WordPress images
// make sure this script is called in the footer of your document
function inView(image){
var $image = jQuery(image),
view_top = jQuery(window).scrollTop() - 300,
view_bottom = view_top + jQuery(window).height() + 600,
height = $image.height(),
_top = $image.offset().top,
_bottom = _top + height;
return height > 0 && _top <= view_bottom && _bottom >= view_top;