Skip to content

Instantly share code, notes, and snippets.

View vfontjr's full-sized avatar

Victor M. Font Jr. vfontjr

View GitHub Profile
<script>
jQuery(document).ready(function($) {
"use strict";
/* self-executing function */
( function($) {
/* this function is a workaround for an apparent Firefox bug
* where the default values are sometimes not being displayed
* the test form works Safari, Chrome, and Firefox Developer Edition.
<script>
jQuery(document).ready(function($) {
"use strict";
/* add "display: grid" to field's div.frm_opt_container
* change frm_field_1142_container to the id of your field's container
*/
$('div#frm_field_1142_container > div.frm_opt_container').css('display', 'grid');
/* loop through each radio button to assign it to a grid column
* change wild card selector [id^="frm_radio_1142-"] to the id
<script>
jQuery(document).ready(function($) {
"use strict";
/* this script demonstrates a prototype integration for
* to display dynamic ChartJS graphs from Formidable Forms data.
*/
function masterminds_calc_fv( deposit_value, interest_rate, monthly_contribution ) {
const values = [deposit_value];
var chart_years = 30,
/* this code is a multi-selector variation of the example found
* in Formidable's knowledge base article:
* https://formidableforms.com/knowledgebase/javascript-examples/#kb-format-a-slider-field-value-as-a-currency
*
* it uses the Intl.NumberFormat function that's built into JavaScript. No external libraries required.
* to learn more about Intl.NumberFormat see:
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat
*/
$("#field_id1 ~ .frm_range_value, #field_id2 ~ .frm_range_value").on('DOMSubtreeModified' , function() {
var field_id = $(this)[0].previousSibling.id,
<?php
/* directory search form custom where filter */
add_filter('frm_view_order', 'masterminds_directory_search_filter', 10, 2);
/**
* masterminds_directory_search_filter() callback for frm_view_order filter
*
* this function is where you create custom SQL for any view
*
* @param array $query contains the SQL query created by Formidable
<?php
add_shortcode( 'count_entries', 'fm_count_entry_records' );
function fm_count_entry_records( $atts ) {
/* define/use variables to access WordPress database functions
* and Formidable's tables
*/
global $wpdb;
$prefix = $wpdb->prefix;
$frm_items = $prefix . 'frm_items';
<script>
/* disables copy and paste */
document.getElementById("field_conf_29yf4d2").addEventListener('paste', e => e.preventDefault());
/* disables drag and drop */
document.getElementById("field_conf_29yf4d2").addEventListener('drop', e => e.preventDefault());
/* disables browser autocomplete */
document.getElementById("field_conf_29yf4d2").addEventListener('autocomplete', e => e.preventDefault());
<script>
jQuery(document).ready(function($) {
"use strict";
/* Format link phone number */
$("#field_devdir_country_code, #field_devdir_primary_contact_phone").on("change", function() {
var link_number = $("#field_devdir_country_code").val() + $("#field_devdir_primary_contact_phone").val();
$("#field_devdir_link_phone_number").val( link_number.replace(/\D/g,'') );
});
});
</script>
<?php
add_filter( 'simple_social_default_profiles', 'my_custom_simple_social_default_profiles' );
function my_custom_simple_social_default_profiles() {
$glyphs = array(
'bloglovin' => '&#xe60c;',
'dribbble' => '&#xe602;',
'email' => '&#xe60d;',
'facebook' => '&#xe606;',
'flickr' => '&#xe609;',
@vfontjr
vfontjr / browser-storage.js
Created February 25, 2022 22:40
Broser Storage jQuery
/* functions to create a persistent form */
function browser_supports_storage() {
return ( typeof(Storage) !== "undefined" ) ? true : false;
}
function local_data_exists() {
return ( localStorage.getItem('data') ) ? true : false;
}
function cookie_is_used_for_persistence() {