Skip to content

Instantly share code, notes, and snippets.

View timothyjensen's full-sized avatar

Tim Jensen timothyjensen

View GitHub Profile
@timothyjensen
timothyjensen / functions.php
Last active April 24, 2024 18:20
Enforce anti-spam honeypot on all Gravity Forms forms
<?php
/**
* Enforce anti-spam honeypot on all Gravity forms.
*
* @param array $form
*
* @return array $form
*/
add_filter( 'gform_form_post_get_meta', function ( $form ) {
@timothyjensen
timothyjensen / jquery.js
Last active November 3, 2020 10:01
Wrap sibling groups using jQuery.
$(document).ready(function() {
$(':not(.sibling-element) + .sibling-element, * > .sibling-element:first-of-type').
each(function() {
$(this).
nextUntil(':not(.sibling-element)').
addBack().
wrapAll('<div class="sibling-wrapper" />');
});
});
@timothyjensen
timothyjensen / functions.php
Last active October 13, 2019 05:14
Retrieves all post meta data according to the structure in the $config array. Provides a convenient and more performant alternative to ACF's `get_field()`. This function is especially useful when working with ACF repeater and flexible content fields. See details at https://www.timjensen.us/acf-get-field-alternative.
<?php
/**
* Retrieves all post meta data according to the structure in the $config
* array.
*
* Provides a convenient and more performant alternative to ACF's
* `get_field()`.
*
* This function is especially useful when working with ACF repeater fields and
* flexible content layouts.
@timothyjensen
timothyjensen / template-grid-two-categories.php
Last active June 4, 2019 19:22
Genesis page template. Two rows of posts, with each row being a different category. Three posts per row and no pagination.
<?php
/**
* Template Name: Two Categories in Two Rows
*
*/
//* Remove the standard loop
remove_action( 'genesis_loop', 'genesis_do_loop' );
//* Add classes to display the posts in a grid
@timothyjensen
timothyjensen / Gulpfile.js
Created May 25, 2016 19:53
Automate compiling Sass to CSS and browser refresh using BrowserSync
// Require our dependencies
var gulp = require('gulp');
var sass = require('gulp-sass');
var browserSync = require('browser-sync').create();
gulp.task('styles', function(){
return gulp.src('sass/style.scss')
.pipe(sass({
outputStyle: 'expanded', // Options: nested, expanded, compact, compressed
indentType: 'tab',
@timothyjensen
timothyjensen / parallax.js
Created May 30, 2016 00:20 — forked from srikat/parallax.js
Applying Parallax effect from Parallax Pro in any Genesis theme. http://sridharkatakam.com/apply-parallax-effect-parallax-pro-genesis-theme/
//* Register widget areas
genesis_register_sidebar( array(
'id' => 'parallax-section-below-header',
'name' => __( 'Parallax Section Below Header', 'your-theme-slug' ),
'description' => __( 'This is the parallax section below header.', 'your-theme-slug' ),
) );
genesis_register_sidebar( array(
'id' => 'parallax-section-above-footer',
'name' => __( 'Parallax Section Above Footer', 'your-theme-slug' ),
<?php
add_filter( 'template_include', 'your_custom_cpt_template', 99 );
/**
* Load an alternative template file for a given post type
*
* @param string $template path to the default template
* @return string $template path to the default template
* @return string $custom_template path to the custom template
*/
function your_custom_cpt_template( $template ) {
<?php
add_action( 'before_genesis_site-inner_wrap', 'do_full_width_page_header' );
/**
* Adds a div with a background image before the site-inner wrap.
*/
function do_full_width_page_header() {
printf( '<div class="full-width-page-header" style="background: url(\'%s\');"></div>',
wp_get_attachment_image_url( 2623, 'full' )
);
@timothyjensen
timothyjensen / functions.php
Last active June 4, 2019 19:22
Change the default Genesis read more link
<?php
add_filter( 'get_the_content_more_link', 'prefix_change_more_link_text' );
/**
* Replaces the default Genesis [Read More...] with Read More.
*
* @param string $more_link The content more link.
*
* @return string
*/
function prefix_change_more_link_text( $more_link ) {
@timothyjensen
timothyjensen / cpt-registration.php
Last active June 4, 2019 19:22
Change the placeholder text for the post title field.
<?php
// Add 'title_placeholder' to the array of arguments when registering the custom post type.
$cpt_args = array(
'title_placeholder' => 'Team member name',
);
register_post_type( 'team_members', $cpt_args );