Skip to content

Instantly share code, notes, and snippets.

View jetsloth's full-sized avatar

JetSloth jetsloth

View GitHub Profile
@jetsloth
jetsloth / add_colors_to_taxonomy_choices.php
Created August 15, 2020 01:55
Add color choices to field dynamically populated by the Gravity Forms + Custom Post Types plugin, where colors are set as the text of each taxonomy term
<?php
function add_colors_to_taxonomy_choices( $form ) {
global $gf_cpt_addon;
if ( empty($gf_cpt_addon) ) {
return $form;
}
foreach( $form['fields'] as &$field ) {
$taxonomy = $gf_cpt_addon->get_field_taxonomy( $field );
$colorPickerEnabled = ( isset($field['colorPicker_enableColors']) && !empty($field['colorPicker_enableColors']) );
/*///////////////////
JetSloth.com
Display your Collapsible Sections in tabs with this CSS updates
Full article at https://jetsloth.com/labs/display-your-form-with-tabs-using-collapsible-sections/
////////////////////*/
/* /////////////////// Form wrapper /////////////////// */
.form-has-collapsible-sections_wrapper {
margin: 0 auto;
text-align: left;
<img class="demo-product" src="https://jetsloth.com/wp-content/uploads/2018/09/Artboard-3-Copy-12.png"/>
<img class="demo-product" src="https://jetsloth.com/wp-content/uploads/2018/09/Artboard-3-Copy-13.png"/>
<img class="demo-product"" src="https://jetsloth.com/wp-content/uploads/2018/09/Artboard-3-Copy-14.png"/>
<img class="demo-product" src="https://jetsloth.com/wp-content/uploads/2018/09/Artboard-3-Copy-15.png"/>
<img class="demo-artwork" src="https://jetsloth.com/wp-content/uploads/2018/09/I-heart-Jetsloth-1.svg"/>
<img class="demo-artwork" src="https://jetsloth.com/wp-content/uploads/2018/09/logo.svg"/>
<img class="demo-artwork" src="https://jetsloth.com/wp-content/uploads/2018/09/sloth-logo-royalty-free_defiant-sloth.png"/>
<img class="demo-artwork" src="https://jetsloth.com/wp-content/uploads/2019/07/JetSloth-Logo-dark.png"/>
<script type="text/javascript">
jQuery(document).bind('gform_post_render', function(e, formId, currentFormPage) {
var $form = jQuery('#gform_' + formId);
$form.find(".gform_body li.preview-area img" ).css('display','none');
$form.find(".gform_body li.preview-area .demo-product:eq(0)" ).css('display','block');
$form.find(".gform_body li.preview-area .demo-artwork:eq(1)" ).css('display','block');
// On color swatch click/secltion
$form.find("li.color-picker-choice " ).click(function() {
var $radioIndex = $form.find("li.color-picker-choice ").index(this);
var $imageRef = $form.find(".gform_body li.preview-area .demo-product");
/*///////////////////////////////////////*/
/* Outter form wrapper */
.gform_body {
background:#f6f6f6;
border-radius:10px;
margin-bottom:40px;
overflow:hidden;
padding:50px 0px;
}
<img class=”product” src=”https://yourwebsite.com/link_to_your_image/my_image1.png“/>
<img class=”product” src=”https://yourwebsite.com/link_to_your_image/my_image2.png“/>
<img class=”product” src=”https://yourwebsite.com/link_to_your_image/my_image3.png“/>
<img class=”product” src=”https://yourwebsite.com/link_to_your_image/my_image4.png“/>
/*///////////////////
JS
Build a simple product visualiser with Gravity Forms Color Picker
Full article at https://jetsloth.com/labs/build-a-simple-product-visualiser-with-gravity-forms-color-picker/
////////////////////*/
<script type="text/javascript">
jQuery(document).bind('gform_post_render', function(e, formId, currentFormPage) {
// Hide all the product images
jQuery( ".gform_body li.preview-area img" ).css('display','none');
/*///////////////////
CSS
Build a simple product visualiser with Gravity Forms Color Picker
Full article at https://jetsloth.com/labs/build-a-simple-product-visualiser-with-gravity-forms-color-picker/
////////////////////*/
/* Outter form wrapper */
.gform_body {
background:#f6f6f6;
border-radius:10px;
/*
Gravity Forms Image Choices - Custom Style - Floating
Find out more at
https://jetsloth.com/support/gravity-forms-image-choices/custom-styles-floating/
*/
.gform_wrapper .image-choices-field {
display: block;
max-width: 640px;
width: 100%;
}
@jetsloth
jetsloth / image-choices-hide-labels-fix.css
Created February 13, 2020 00:10
Fix to hide image choices labels on mobile when 'Show labels' settings is off
@media only screen and (max-width: 641px) {
.image-choices-field:not(.image-choices-show-labels) .image-choices-choice-text {
display: none !important;
}
}