Skip to content

Instantly share code, notes, and snippets.

@leepettijohn
leepettijohn / style.css
Created June 27, 2015 18:32
Gradients
// linear-gradient([direction], [stop] [% or px], <[stop] [% or px]>+)
// background: linear-gradient(left, rgba(255,0,0,0), red 50px, blue 100px, blue 200px, green );
#linear-grad {
//top to bottom
background: -webkit-linear-gradient(red, blue); /* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(red, blue); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(red, blue); /* For Firefox 3.6 to 15 */
background: linear-gradient(red, blue); /* Standard syntax */
@leepettijohn
leepettijohn / functions.php
Last active December 3, 2024 05:38
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 / functions.php
Created November 16, 2015 16:52
Automatically Populate Gravity Forms from Posts, Events, etc.
// Add scripts for Gravity Forms
gravity_form_enqueue_scripts( [gformid], true );
// Call function to add form to bottom of the entry
// *** This only works if you're using a Genesis theme ***
add_action( 'genesis_entry_footer', 'add_form_to_bottom', 5 );
// Return Gravity Form with specified ID to single listing CPT
function add_form_to_bottom() {
// bail if we aren't on a single listing CPT
// Change 'listing' to post type
@leepettijohn
leepettijohn / script.js
Created February 26, 2016 18:34
Revising all texts on a page in a certain selector
//Use correct selector
$('.your-selector').text(function(){
return $(this).text().substr($(this).text().indexOf('insert-your-break-point-here'));
});
@leepettijohn
leepettijohn / script.js
Created March 1, 2016 14:57
Select items not on the screen or only partially visible
// onScreen jQuery plugin v0.2.1
// (c) 2011-2013 Ben Pickles
//
// http://benpickles.github.io/onScreen
//
// Released under MIT license.
;(function($) {
$.expr[":"].onScreen = function(elem) {
var $window = $(window)
var viewport_top = $window.scrollTop()
@leepettijohn
leepettijohn / functions.php
Created April 20, 2016 11:03
Update a list field in Gravity Forms
// Update a List field in Gravity Forms
//Change the '6' at the end to the correct form id
add_action('gform_post_submission_6','update_list',10,2);
function update_list($entry, $form){
$entry_id = $entry['id'];
//print_r($entry);
$list_values = array(
array(
'Column 1' => 'one',
'Column 2' => 'two',
@leepettijohn
leepettijohn / functions.php
Created April 25, 2016 20:30
Extract a CSV in Gravity Forms and put in a textarea
// Change the '9' at the end to the id of your form
add_action('gform_post_submission_9','pullcsv',10,2);
function pullcsv($entry, $form){
//Fields to change
$file_field = 3;
$text_field = 4;
$entry_id = $entry['id'];
$csv = $entry[$file_field]; //this returns a url string to the uploaded csv
$row = 1;
if (!empty($csv)){
@leepettijohn
leepettijohn / script.js
Last active August 27, 2016 16:04
Remove text before each selection
//remove everything (and including) before ":"
<script type="text/javascript">jQuery(document).ready(function($){
$('.ai1ec-event-time').each(function(){
var str = $(this).html();
str = str.split(":").pop();
$(this).html(str);
});
});
</script>
@leepettijohn
leepettijohn / script.js
Created June 22, 2016 21:45
jQuery - Get GET variables
var $_GET = {};
document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () {
function decode(s) {
return decodeURIComponent(s.split("+").join(" "));
}
$_GET[decode(arguments[1])] = decode(arguments[2]);
});
//This will either alert the "id" variable in the URL or return 'undefined'