All my extensions are here: https://marketplace.visualstudio.com/items?itemName=omthemes.om-extension-pack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_shortcode('reading-time', 'reading_time'); | |
function reading_time() { | |
$content = get_post_field( 'post_content', $post->ID ); | |
$word_count = str_word_count( strip_tags( $content ) ); | |
$readingtime = ceil($word_count / 200); | |
if ($readingtime == 1) { | |
$timer = " minuto"; | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'gform_pre_render', 'populate_referral_url' ); | |
add_filter( 'gform_pre_validation', 'populate_referral_url' ); | |
add_filter( 'gform_pre_submission_filter', 'populate_referral_url' ); | |
add_filter( 'gform_admin_pre_render', 'populate_referral_url' ); | |
function populate_referral_url( $form ){ | |
if ( $form['id'] != 2 && $form['id'] != 3) { | |
return $form; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const inputCpfCnpj = document.querySelector('.cpf_cnpj input'); | |
function handleInputCpfCnpj() { | |
let value = inputCpfCnpj.value.replace(/\D/g, ''); | |
let mask = ''; | |
if (value.length <= 3) { | |
mask = value; | |
} else if (value.length <= 6) { | |
mask = value.slice(0, 3) + '.' + value.slice(3); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const inputTelefoneComDdd = document.querySelector('.telefone_com_ddd input'); | |
function handleInputTelefoneComDddd() { | |
let value = inputTelefoneComDdd.value.replace(/\D/g, ''); // Remove todos os caracteres não numéricos | |
let mask = ''; | |
if (value.length <= 1) { | |
mask = '(' + value; | |
} else if (value.length <= 5) { | |
mask = '(' + value.slice(0, 2) + ') ' + value.slice(2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const inputCnpj = document.querySelector('.cnpj input'); | |
function handleInputCnpj() { | |
let value = inputCnpj.value.replace(/\D/g, ''); | |
let mask = ''; | |
if (value.length <= 2) { | |
mask = value; | |
} else if (value.length <= 5) { | |
mask = value.slice(0, 2) + '.' + value.slice(2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).on("gform_post_render", function (event, form_id, current_page) { | |
// code here | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'gform_pre_submission', 'pre_submission_handler' ); | |
function pre_submission_handler( $form ) { | |
foreach ( $form['fields'] as &$field ) { | |
if ( $field->cssClass == 'cpf' || $field->cssClass == 'cnpj' ) { | |
// Obtém o valor do campo do formulário | |
$field_value = rgpost( "input_{$field->id}" ); | |
// Remove todos os caracteres não numéricos | |
$cleaned_value = preg_replace( '/[^0-9]/', '', $field_value ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('gform_validation', 'validar_cpf_e_cnpj'); | |
function validar_cpf_e_cnpj($validation_result) { | |
$form = $validation_result['form']; | |
foreach ($form['fields'] as $field) { | |
$value = rgpost("input_{$field['id']}"); | |
$isActive = isActive($field, $form); | |
if ($isActive) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'gform_pre_render', 'form_debug' ); | |
function form_debug( $form ) { | |
foreach ( $form['fields'] as &$field ) { | |
echo '<pre>'; | |
var_dump($field); | |
echo '</pre>'; | |
} | |
return $form; | |
} |
OlderNewer