Skip to content

Instantly share code, notes, and snippets.

View New0's full-sized avatar

Nicolas Figueira New0

View GitHub Profile
@New0
New0 / DS-no-margins.css
Created September 28, 2017 16:14
Remove margin arround Direct Stripe button
.direct-stripe { margin: 0; }
@New0
New0 / CF-reset-password-link-independant.php
Last active April 2, 2020 10:09
Two examples to add a reset password link in Caldera Forms, first uses main mailer, second sends an independant email
@New0
New0 / CF-add-image-next-to-checbox.css
Last active October 26, 2017 10:21
Add the image via the media library and copy the image url into the src parameter of the img tag in an html field. Position the html field just below the checkbox field.
/** All the sizes need to be adjusted to the webpage design and image size **/
/* Add the class image_checkbox to the checkbox field and the class image_display to the html field that contains the image */
.image_checkbox label,
.image_display img
{
max-width: none;
}
.image_display {
position: absolute;
margin-top: -2.5rem;
@New0
New0 / DS-add-currency-symbol.php
Last active October 31, 2017 17:58
Add a Currency symbol before the donation input field in Direct Stripe
add_filter( 'direct_stripe_donation_input', function( $input ){
$symbol = '<span style="font-size: 1.2em;">$ </span>'; // Edit the symbol to suit your currency
$input = $symbol . $input;
return $input;
});
@New0
New0 / CF-patterns-examples.php
Last active November 17, 2017 14:50
Set a pattern for min and max length of fields, combined with the required field option.
<?php
//Use caldera_forms_field_attributes filter hook
add_filter( 'caldera_forms_field_attributes', function( $attrs, $field, $form ){
//REPLACE fld_******* BY YOUR OWN FIELD IDs
//Min and max 5
if( 'fld_4009904' === $field[ 'ID' ] ) {
$attrs[ 'pattern' ] = ".{5,5}";
}
@New0
New0 / CF-count-textarea-words-insert-hidden-field-value.js
Created November 20, 2017 11:30
Count words in a textarea field and print the value in a hidden field
$(document).ready(function() {
//CHANGE THE IDs TO MATCH YOUR FIELDS, these are frontend IDs, usually the field ID looking like fld_7683514 will be transformed as #fld_7683514_1
var textarea = "#fld_7683514_1"; //ID of the textarea we want to count words
var hidden_value = '#fld_9053892_1'; //ID of the hidden field we want to print count in value parameter
$(textarea).keyup(function() { word_count( textarea, hidden_value ) });
});
@New0
New0 / CF-toggle-img-replacement.css
Last active December 18, 2017 22:30
Change Caldera Forms Toggle Switch Buttons To Images
/*
* Change Caldera Forms Toggle Switch Buttons To Images
* Read https://gist.github.com/New0/7e385d497052a4fd171314b299f3dd13#file-cf-toggle-img-replacement-md
*/
/* Hide original Toggle Field */
.cf-toggle-group-buttons a {
visibility: hidden;
}
/* First toggle option */
.cf-toggle-group-buttons a:nth-child(1):before {
@New0
New0 / CF-field-group-tabindex.php
Created December 29, 2017 13:19
Use jQuery to add tabindex to field group attributes
//Replace #fld_8768091_1-wrap by the field ID found with developer console.
add_action( 'wp_footer', function(){
echo "<script>
jQuery(document).ready(function(){
jQuery('#fld_8768091_1-wrap').attr('tabindex','0');
jQuery('#fld_9970286_1-wrap').attr('tabindex','1');
jQuery('#fld_6009157_1-wrap').attr('tabindex','2');
});
</script>";
}, 10 );
@New0
New0 / CF-gil-jQuery-calculation-example.php
Created January 4, 2018 11:46
Example to add the calculation needed to Gil's form
add_action( 'wp_footer', function(){
echo "<script>
jQuery(document).ready(function() {
//CHANGE THE IDs TO MATCH YOUR FIELDS, these are frontend IDs, usually the field ID looking like fld_7683514 will be transformed as #fld_7683514_1
var textarea = '#fld_7683514_1'; //ID of the textarea we want to count words
var hidden_value = '#fld_8293824_1'; //ID of the hidden field we want to print count in value parameter
@New0
New0 / cf-custom-code.php
Last active January 26, 2018 11:42
Add and remove a class to .caldera-grid .CF5a5fc16500e92 .checkbox Label on click event using jQury in the footer
<?php
/*
* Plugin Name: CF custom code
*/
add_action( 'wp_footer', function() {
echo '<script>
jQuery( ".caldera-grid .CF5a5fc16500e92 .checkbox Label" ).click(function() {
$( this ).toggleClass( "checked" );
});
</script>';