Gravity Forms JavaScript Helpers

jQuery(function($) { $(‘.gform_wrapper FORM’).on(‘change’, ‘.post-code INPUT’, function(evt) { evt.stopImmediatePropagation(); const field = $(this), postCode = field.val(); $.get({ url: `https://apis.postcode-jp.com/api/v6/postcodes/${postCode}?apiKey=BJ7qtSrq0iYgWj9AV0P4esvTTX1gmq48813DoE1&normalize=true&fields=allAddress,prefCode,city,town` }).always(function(response) { console.log(‘RESPONSE:’, response); if(!Array.isArray(response)) return; const form = field.closest(‘FORM’), result = response[0]; if(result.prefCode) $(‘.prefecture SELECT’, form).val(result.prefCode); if(result.city) $(‘.street INPUT’, form).val(`${result.city}${result.town}`);…Continue reading

Gravity Forms Custom CSS

.gform_required_legend { display: none; } .gfield_required { .gfield_required_custom { display: inline-block; background-color: #c01921; color: white; padding: 0.35em 0.65em; border-radius: 0.375rem; } }Continue reading

FB Events App.js

window.fbAsyncInit = function() { FB.init({ appId : ‘247399214359492’, cookie : true, xfbml : true, version : ‘v16.0’ }); FB.AppEvents.logPageView(); }; (function(d, s, id){ var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = “https://connect.facebook.net/en_US/sdk.js”;…Continue reading

Login / logout

function agregar_login_logout_al_menu( $items, $args ) { // Verifica si el usuario está logueado if ( is_user_logged_in() ) { // Obtén el nombre del usuario $current_user = wp_get_current_user(); $user_name = $current_user->display_name; // Enlace de “Cerrar sesión” con el nombre de usuario…Continue reading

Modern CSS Reset

/* 1. Use a more-intuitive box-sizing model */ *, *::before, *::after { box-sizing: border-box; } /* 2. Remove default margin */ * { margin: 0; } body { /* 3. Add accessible line-height */ line-height: 1.5; /* 4. Improve text…Continue reading

Thanksgiving popup

(function(w, d, t, h, s, n) { w.FlodeskObject = n; var fn = function() { (w[n].q = w[n].q || []).push(arguments); }; w[n] = w[n] || fn; var f = d.getElementsByTagName(t)[0]; var v = ‘?v=’ + Math.floor(new Date().getTime() / (120 *…Continue reading