Skip to content

Instantly share code, notes, and snippets.

View larbous's full-sized avatar

Luiz Sobral larbous

View GitHub Profile
@larbous
larbous / options-values-in-code.php
Created July 10, 2024 14:51 — forked from MjHead/options-values-in-code.php
Get option values for JetEngine options pages inside the PHP code
<?php
/**
* Method 1
* Can be used for: Any storage type
*
* page-slug - replace this with your Option Page slug
* option-name - replace this with your option Name/ID
*/
$value = jet_engine()->listings->data->get_option( 'page-slug::option-name' );
@larbous
larbous / custom-dynamic-field-callback.php
Created July 9, 2024 01:11 — forked from Crocoblock/custom-dynamic-field-callback.php
JetEngine Dynamic Field add custom callback (for example, add callback that partially masks an email with * or other symbols)
<?php
//filter to add a callback to the list
add_filter( 'jet-engine/listings/allowed-callbacks', 'add_custom_dynamic_field_callbacks' );
//filter to specify which arguments will the callback have
add_filter( 'jet-engine/listing/dynamic-field/callback-args', 'add_custom_dynamic_field_callbacks_args', 0, 3 );
//filter to add controls
//controls arguments are set as in Elementor controls
@larbous
larbous / mautic-form-preload.js
Last active June 15, 2023 20:48 — forked from stevedrobinson/mautic-form-preload.js
Pre-populate Mautic Form Data from Query String Parameters
<script>
(function(document){
function populateForms(){
if (document.readyState == 'interactive') {
if (document.forms.length !== 0 && location.search) {
var query = location.search.substr(1);
query.split('&').forEach(function (part) {
if (part.indexOf('=') !== -1) {
var item = part.split('=');
var key = item[0];
@larbous
larbous / validatorCNH.js
Last active January 13, 2023 13:01 — forked from danielnass/gist:d41d47a9b6e05918a56c
jQuery Validation Additional Method CNH - Carteira Nacional de Habilitação - Carteira de Motorista
$.validator.addMethod('CNH', function(value, element) {
var ret,
cnh = value,
firstChar = cnh.charAt(0);
if (cnh.replace(/[^\d]/g, '').length === 11 && firstChar.repeat(11) !== cnh) {
var dsc = 0;
for (var i = 0, j = 9, v = 0; i < 9; ++i, --j) {
@larbous
larbous / Validate_cpf_cnpj
Last active January 13, 2023 11:10 — forked from fjcunha/Validate_cpf_cnpj
jQuery validator methods to validate cpf and cnpj
jQuery.validator.addMethod("cnpj", function (value, element) {
var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais;
if (value.length == 0) {
return false;
}
value = value.replace(/\D+/g, '');
digitos_iguais = 1;