Skip to content

Instantly share code, notes, and snippets.

View jessedmatlock's full-sized avatar
🏠
Working from home

Jesse Matlock jessedmatlock

🏠
Working from home
View GitHub Profile
@jessedmatlock
jessedmatlock / ACF-load-flex-fields-new-posts.php
Created August 24, 2022 17:39
Load specific ACF Flexible Content fields for new Posts
// "flexible_content" below, is the name of the Flexible Content field
add_filter('acf/load_value/name=flexible_content', 'add_fields', 10, 3);
function add_fields($value, $post_id, $field) {
if ($value !== NULL) { // $value will only be empty for New Posts
return $value;
}
// lead layouts
$value = array(
array(
@jessedmatlock
jessedmatlock / givewp-add-heart-to-recurring-option.php
Last active August 24, 2022 16:04
GiveWP - add a heart SVG icon to recurring option box that animates when a recurring donation is selected
// Inject an SVG icon (heart) into recurring selection box via JS
function override_givewp_js() {
if( ! is_admin() ) { ?>
<script type="text/javascript">
jQuery(document).ready( function($) {
$('.give-btn.advance-btn').on('click', function(){
if( $('.give-recurring-donors-choice').length ){
$('.give-recurring-donors-choice').append('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 255.96 256" data-inject-url="http://vertex2022.local/wp-content/themes/vertex-ranch-2022/assets/img/icons/solid/love.svg" class="svg-inject icon-svg icon-svg-sm solid-mono text-red me-4 mb-5 mb-md-0"><path class="fill-primary" d="M96 186.67A90.77 90.77 0 01186.63 96a89.82 89.82 0 0138.9 8.9 64.28 64.28 0 00-95.3-86L120 29.15l-10.28-10.27a64.21 64.21 0 00-90.93 0 64.56 64.56 0 000 91.06L96 187.28z"></path><path class="fill-secondary" d="M186.63 117.33A69.34 69.34 0 10256 186.67a69.41 69.41 0 00-69.37-69.34zm30.19 55.73l-30.54 37.32a8.06 8.06 0 01-5.92 3h-.27a8 8 0 01-5.84-2.53l-17.46-18.67a8 8 0 0111.7-10.95l11.2
@jessedmatlock
jessedmatlock / wp_special_enqueue_script.php
Created May 1, 2022 00:57
Creates custom script and style loading for Wordpress to all adding Defer, Async, and Lazy Load attributes
<?php
/**
* Reusable loaders
*/
$specialLoadHnds = (object) array(
'scripts' => (object) array(
'async' => array(),
'defer' => array()
),
'styles' => (object) array(
@jessedmatlock
jessedmatlock / deregister_GiveWP_scripts_styles.php
Last active April 26, 2022 02:17
GiveWP loads ALL scripts and styles, regardless if a form is present on the page. This script removes them, unless a GiveWP form iframe is present, speeding up your site and reducing load times, etc.
/**
* Deregister and dequeue all GiveWP scripts and styles, unless we're loading them for a GiveWP forms iframe.
**/
function give_deregister_script() {
$deregister = false;
/**
* example gleaned from https://www.boilingpotmedia.com/education/wordpress-conditional-tag-if-url-contains-a-string/
* though that example uses split() [deprecated]
@jessedmatlock
jessedmatlock / acf-first-row.php
Created September 17, 2021 18:20 — forked from neilgee/acf-first-row.php
ACF Repeater - Grab First/LAst or Random Single Data Row
<?php
//My ACF Fields for reference
//testimonials - field group
//testimonial - sub-field
//testimonial_header - sub-field
//First Repeater Row in Array
$rows = get_field( 'testimonials', 348 );// grab all rows from page ID
@jessedmatlock
jessedmatlock / breadcrumbs-code-without-plugin.php
Created June 11, 2021 14:23 — forked from techpulsetoday/breadcrumbs-code-without-plugin.php
By adding this to functions.php to display the menu, just use this function to display it wherever you want.
<?php
/*=============================================
BREADCRUMBS
=============================================*/
// to include in functions.php
function the_breadcrumb()
{
$showOnHome = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show
$delimiter = '&raquo;'; // delimiter between crumbs
$home = 'Home'; // text for the 'Home' link
@jessedmatlock
jessedmatlock / gw-gravity-forms-submit-to-access.php
Created April 21, 2021 21:16 — forked from spivurno/gw-gravity-forms-submit-to-access.php
Gravity Wiz // Gravity Forms // Submit to Access
<?php
/**
* Gravity Wiz // Gravity Forms // Submit to Access
*
* Require that a form be submitted before a post or page can be accessed.
*
* @version 1.7
* @author David Smith <[email protected]>
* @license GPL-2.0+
* @link https://gravitywiz.com/submit-gravity-form-access-content/
@jessedmatlock
jessedmatlock / gw-gravity-forms-redirect-if-email-exists.php
Created April 21, 2021 17:35 — forked from spivurno/gw-gravity-forms-redirect-if-email-exists.php
Gravity Wiz // Gravity Forms // Redirect if Email Exists
<?php
/**
* Gravity Wiz // Gravity Forms // Redirect if Email Exists
*
* Redirect to a specified URL if the the submitted email address matches an existing user.
*
* Note: Does not work with AJAX-enabled forms.
*
* @version 0.1
* @author David Smith <[email protected]>
<?php
/**
* Gravity Wiz // Gravity Forms // User Registration // Skip Registration if Email Exists
*
* If submitted email is already registered, skip registration.
*
* @version 0.4
* @author David Smith <[email protected]>
* @license GPL-2.0+
* @link http://gravitywiz.com/
@jessedmatlock
jessedmatlock / jquery.pageload-scroll.js
Last active April 20, 2021 16:38
Scroll to URL Hash element on page load
/*
* Scroll the page to the URL Hash, IF URL contains one
* Author: Jesse Matlock - @revivemarketing
*/
if (window.location.hash) {
var element = window.location.hash;
if ($(element).length) {
$('html, body').animate({
scrollTop: $(element).offset().top // IF header is fixed, add height of header in px. eg. '- 140'