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 | |
function ajusta_url_imovel($rules) { | |
$new_rules = array( | |
'imoveis/([^/]+)/([^/]+)/?$' => 'index.php?post_type=$matches[1]&$matches[1]=$matches[2]', | |
); | |
$rules = array_merge($new_rules,$rules); | |
exit; |
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 | |
// Verifica se não existe nenhuma função com o nome tutsup_session_start | |
if ( ! function_exists( 'tutsup_session_start' ) ) { | |
// Cria a função | |
function tutsup_session_start() { | |
// Inicia uma sessão PHP | |
if ( ! session_id() ) session_start(); | |
} | |
// Executa a ação | |
add_action( 'init', 'tutsup_session_start' ); |
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 | |
function jQuery3(){ | |
$date = date("dmy"); | |
if (!is_admin()){ | |
wp_deregister_script('jquery'); | |
wp_register_script('jquery', get_template_directory_uri()."/assets/js/jquery.min.js", false, $date); | |
wp_enqueue_script('jquery'); | |
} | |
} | |
add_action('wp_enqueue_scripts', 'jQuery3'); |
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
<?php | |
$user_ip = getenv('REMOTE_ADDR'); | |
$geo = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=$user_ip")); | |
var_dump($geo); | |
$pais = $geo["geoplugin_countryName"]; | |
$cidade = $geo["geoplugin_city"]; | |
$estado = $geo['geoplugin_region']; |
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 | |
function custom_theme_scripts() { | |
$date = date("dmy"); // apenas gera uma numeração de versão aleatória | |
// seta seu principal arquivo javascript | |
wp_enqueue_script( 'funcoes', get_template_directory_uri() . '/assets/js/scripts.min.js', array('jquery'), $date, true ); | |
// registra uma função js para localizar uma função PHP | |
wp_localize_script( 'funcoes', 'disparaLoad', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) ); | |
} | |
add_action('wp_enqueue_scripts', 'custom_theme_scripts'); |
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
<!-- carrega os posts --> | |
<div id="load-questions" class="row load-questions"></div> | |
<p class="text-center section-btn"> | |
<!-- Realiza o clique sempre adicionando 1 --> | |
<a href="" class="btn btn-site btn-load-questions" data-pagination="1"> | |
<i class="icon icon-plus"></i> Perguntas | |
</a> | |
</p> |
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 | |
// executa o load de questões na home do site | |
add_action('wp_ajax_load', 'load'); | |
add_action('wp_ajax_nopriv_load', 'load' ); // aparentemente não é obrigatorio utilizar este action | |
// funcao propriamente dita | |
function load(){ | |
$paged = $_GET['paged']; |
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 a variavel em 1 pois é a primeira carga | |
var resultPagination = 1; | |
// executa o load de acordo com o click no botao | |
$(document).on('click', '.btn-load-questions',function(){ | |
var pagination = $(this).data('pagination'); // recebe o valor do data-pagination no html | |
// recebe o data-pagination e acrescenta o valor inicial + ele mesmo | |
resultPagination = resultPagination + 1; | |
// cria um efeito de load com gif | |
carregaGifLoad(true); |