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('wp_ajax_insereDados', 'insereDados'); | |
add_action('wp_ajax_nopriv_insereDados', 'insereDados' ); // aparentemente não é obrigatorio utilizar este action | |
function insereDados(){ | |
echo $_POST['nome']; | |
} |
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( 'wp_enqueue_scripts', 'registra_script' ); | |
function registra_script(){ | |
$version = date("ymd-Gis"); | |
// registra o javascript | |
wp_enqueue_script( 'dispara-form-ajax', get_template_directory_uri() .'/caminhoDoSeuScript/disparaForm.js', array( 'jquery' ), $version, true ); | |
// declara que a url do arquivo faz parte do (wp-admin/admin-ajax.php) | |
wp_localize_script( 'dispara-form-ajax', 'funcaoRegistrada', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) ); | |
} |
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).ready(function($) { | |
$("#meu_formlario").submit(function(event) { | |
var dataForm = { | |
action: "insereDados", // Ação que irá receber os dados para inserção no banco de dados ou disparo por email da função em PHP | |
nome: $('#nome').val(), // dados disparo | |
}; | |
$.ajax({ | |
type : 'POST', | |
url : funcaoRegistrada.ajax_url, // funcao registrada que faz referencia ao admin-ajax e url |
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
<form method="post" id="meu_formulário" enctype="multipart/form-data"> | |
<label for="">Nome</label><br> | |
<input type="text" name="nome" value=""> | |
<button type="button" name="button"> Enviar </button> | |
</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
<?php | |
add_action( 'wp_enqueue_scripts', 'meu_script' ); | |
function meu_script(){ | |
$version = date("ymd-Gis"); | |
// registra o script.js que desejar | |
wp_enqueue_script( 'meu_script', get_template_directory_uri() .'/js/meu_script.js', array( 'jquery' ), '1.0.0', true ); | |
// localiaza e declara a variavel acessando o admin-ajax do wordpress loca | |
wp_localize_script( 'meu_script', 'VARjquery', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) ); | |
} |
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
// inicia o jquery validate | |
$('#indicalivro').validate({ | |
// regras de validação | |
rules:{ | |
nome: "required", | |
email: { | |
required: true, | |
email: true | |
} | |
}, |
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
// Get product attributes | |
$attributes = $product->get_attributes(); | |
if ( ! $attributes ) { | |
echo ""; | |
} | |
foreach ( $attributes as $attribute ) { | |
$taxonomia = $attribute['name']; |
NewerOlder