Skip to content

Instantly share code, notes, and snippets.

@leepettijohn
leepettijohn / functions.php
Last active January 6, 2021 15:00
Gravity Forms - Dynamic Checkboxes
<?php
/*-----------------------------------------------------------------------------------*/
/* Putting Locations in Checkboxes */
/* Helpful article - https://www.gravityhelp.com/documentation/article/dynamically-populating-drop-down-fields/ */
/*-----------------------------------------------------------------------------------*/
$location_form_id = 9;
add_filter( 'gform_pre_render_'.$location_form_id, 'populate_posts' );
add_filter( 'gform_pre_validation_'.$location_form_id, 'populate_posts' );
add_filter( 'gform_pre_submission_'.$location_form_id, 'populate_posts' );
add_filter( 'gform_pre_submission_filter_'.$location_form_id, 'populate_posts' );
@leepettijohn
leepettijohn / flex.html
Created July 3, 2017 13:04
Flex boxes - Size Changes & Number in rows
<style>
.parent{
display:flex;
flex-wrap:wrap;
margin: -10px 0 0 -10px;
}
.child{
display:inline-block;
margin: 10px 0 0 10px;
flex-grow:1;
@leepettijohn
leepettijohn / index.html
Last active April 16, 2019 14:05
vertically align divs and images
<!-- source: http://jsfiddle.net/kizu/4RPFa/4570/ -->
<!-- my test: https://jsfiddle.net/leepettijohn/fdor13vd/ -->
<style>
.frame {
height: 100px; /* equals max image height */
width: 160px;
border: 1px solid red;
white-space: nowrap;
text-align: center; margin: 1em 0;
}
@leepettijohn
leepettijohn / functions.php
Last active September 11, 2017 05:24
Gravity Forms - Add names to BCC field
<?
//source: https://www.gravityhelp.com/documentation/article/gform_pre_send_email/#4-copy-to-to-bcc
add_filter( 'gform_pre_send_email', function ( $email, $message_format, $notification ) {
if ( $notification['name'] != 'User Email' ) {
return $email;
}
$email['headers']['Bcc'] = 'Bcc: ' . $email['to'];
$email['to'] = 'name@somedomain.com';
@leepettijohn
leepettijohn / functions.php
Created February 3, 2017 18:14
Gravity Forms - Get comma separated list of checkbox selections
<?php
/* link - http://wordpress.stackexchange.com/questions/210060/get-selected-values-from-checkboxes-and-radio-buttons-via-gravity-forms-gform-af*/
$field_id = 4;
$field = GFFormsModel::get_field( $form, $field_id );
$field_selections = is_object( $field ) ? $field->get_value_export( $entry ) : '';
?>
@leepettijohn
leepettijohn / functions.php
Last active May 1, 2020 15:56
Gravity Forms - Pre-Populate List Field
<?php
/* Change form ID */
$location_form_id = 9;
add_filter( 'gform_pre_render_'.$location_form_id, 'populate_list' );
add_filter( 'gform_pre_validation_'.$location_form_id, 'populate_list' );
add_filter( 'gform_pre_submission_'.$location_form_id, 'populate_list' );
add_filter( 'gform_admin_pre_render_'.$location_form_id, 'populate_list' );
function populate_list( $form ) {
@leepettijohn
leepettijohn / functions.php
Last active April 14, 2018 18:25
From Gravity Form List to ACF Repeater Field
<?php
/* Going from Gravity Form list to ACF Repeater functionality */
add_action( 'gform_after_submission_9', 'list_to_repeater', 1, 2 );
function list_to_repeater( $entry, $form ) {
/* Set the field ids for the custom list fields */
$list_key = 'field_585ae03ad9aab';
/* get and unserialize the list */
@leepettijohn
leepettijohn / functions.php
Created December 20, 2016 19:19
Update Custom Field after Gravity Form Submission
<?php /* *** Change form id on next line *** */
add_action( 'gform_after_submission_10', 'update_wdi_approved', 10, 2 );
function update_wdi_approved( $entry, $form ) {
/* *** Get the field result *** */
$get_title = rgar($entry,'1');
$get_wdi_date = rgar($entry,'2');
/* *** Get the custom post type 'clip_order' id *** */
$orderid = get_page_by_title($get_title,'OBJECT','clip_order');
@leepettijohn
leepettijohn / functions.php
Last active July 28, 2020 09:24
Gravity Forms - Dynamic Dropdown, Radio Button, Multi Select
<?php
/*-----------------------------------------------------------------------------------*/
/* Putting Locations in a Dropdown, Radio Button, or Multi-Select */
/* Helpful article - https://www.gravityhelp.com/documentation/article/dynamically-populating-drop-down-fields/ */
/*-----------------------------------------------------------------------------------*/
$location_form_id = 9;
add_filter( 'gform_pre_render_'.$location_form_id, 'populate_posts' );
add_filter( 'gform_pre_validation_'.$location_form_id, 'populate_posts' );
add_filter( 'gform_pre_submission_'.$location_form_id, 'populate_posts' );
add_filter( 'gform_pre_submission_filter_'.$location_form_id, 'populate_posts' );
@leepettijohn
leepettijohn / script.js
Created December 1, 2016 19:05
Find class that starts with string and return the rest
$("div[class*='fa-']").each(function(){
var check = "fa-";
// Get array of class names
var cls = $(this).attr('class').split(' ');
for (var i = 0; i < cls.length; i++) {
// Iterate over the class and log it if it matches
if (cls[i].indexOf(check) > -1) {
console.log(cls[i].slice(check.length, cls[i].length));
return cls[i].slice(check.length, cls[i].length);
}