Skip to content

Instantly share code, notes, and snippets.

@leepettijohn
leepettijohn / functions.php
Last active January 11, 2024 23:16
Add Event to The Events Calendar from a Gravity Form
//The following section is an add-on to this tutorial - https://tri.be/gravity-forms-events-calendar-submissions/
//Shout to CreativeSlice.com for their initial work
/* Before Starting:
- Make sure you have these three plugins installed
- Gravity Forms
- The Events Calendar
- Gravity Forms + Custom Post Types
- Once Gravity Forms is installed, create a form with these fields
- Single Line Text (Event Title)
- Paragraph Text (Event Description)
@leepettijohn
leepettijohn / genesis-theme-settings.js
Last active May 4, 2022 00:54
Opening a 301 Redirect in a New Tab
/* Add this to your Genesis Theme Settings Page
in the Header and Footer Scripts Section
<script type="text/javascript"> //Be sure to add this before and after too */
jQuery(document).ready(function($){
$('a[href$="newtab"]').attr('target','_blank');
});
//</script>
@leepettijohn
leepettijohn / airtable_to_download_button.php
Last active January 10, 2022 16:34
Airtable API call to create a button to download results in CSV format
<?php
function replaceSpace($string){
$string = str_replace('%20',' ',$string);
return str_replace(' ','+',$string);
}
// C.I.N.N. = Comment if not needed
// Find a copy of the js file here - https://github.com/Airtable/airtable.js/blob/master/build/airtable.browser.js
$ATJS = 'https://yoursite.com/wp-content/themes/Divi/js/airtable.js';
// Table and data variables
@leepettijohn
leepettijohn / airtable_to_vega.php
Created June 11, 2021 13:30
Airtable to Vega Lite Graph
function replaceSpace($string){
return str_replace(' ','+',$string);
}
// Table and data variables
$baseid = '###'; //Required
$apikey = '###'; //Required
$tablename = '###'; //Required
$view = ''; //Optional
$lookupfieldname = ''; //Optional 1a
@leepettijohn
leepettijohn / graph.html
Created April 1, 2021 12:27
Airtable API and Vega Lite Rendering in a Web Page
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js'></script>
<script src="/airtable.js"></script> // https://github.com/Airtable/airtable.js/blob/master/build/airtable.browser.js
<script src="https://cdn.jsdelivr.net/npm/vega@5.19.1"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-lite@5.0.0"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-embed@6.15.1"></script>
<script>
// this variable allows you to pull variables from the URL - https://www.learningjquery.com/2012/06/get-url-parameters-using-jquery
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = window.location.search.substring(1), sURLVariables = sPageURL.split('&'), sParameterName, i;
@leepettijohn
leepettijohn / airtableapi.html
Last active April 1, 2021 12:04
Simple Airtable API pull to web page
<div id="results"></div>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js'></script>
<script src="/airtable.js"></script> // https://github.com/Airtable/airtable.js/blob/master/build/airtable.browser.js
<script>
// this allows you to pull variables from the URL - https://www.learningjquery.com/2012/06/get-url-parameters-using-jquery
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = window.location.search.substring(1),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
@leepettijohn
leepettijohn / custom.js
Created March 9, 2021 13:34
Divi - Disable jquery in Visual Builder
jQuery(document).ready(function($){
var isvisbuild = $('.et-fb-iframe-ancestor').length;
if (isvisbuild == 0){
// code to not run
}
});
@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 / 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 / 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 ) {