Skip to content

Instantly share code, notes, and snippets.

View thiagotmendes's full-sized avatar

Thiago Mendes thiagotmendes

View GitHub Profile
<?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');
<?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'];
<?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');
<?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' );
<?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;
<p id="breadcrumbs"><span xmlns:v="http://rdf.data-vocabulary.org/#"><span typeof="v:Breadcrumb"><a href="//localhost:3000/" rel="v:url" property="v:title">Home</a> » <span class="breadcrumb_last">Microcity</span></span></span></p>
<?php
function jQuery3(){
// Apenas para mudar a versão automaticamente
$date = date("dmy");
// Le a função apenas no front do site
if (!is_admin()){
// Tira o registro do Jquery que estava funcionando
wp_deregister_script('jquery');
// Registra o novo script
wp_register_script('jquery', "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js", false, $date);
@thiagotmendes
thiagotmendes / wordpress-valet-install.md
Created April 10, 2018 12:55 — forked from orumad/wordpress-valet-install.md
How to install Wordpress from command line in Valet

How to install Wordpress from command line in Valet

I use Valet as my local web development environment (PHP, Laravel, Wordpress, ...)

This gist is my own recipe to install Wordpress from the command line to use it with Valet. Maybe this is useful for you too.

Install 'WP-CLI' command line tool

<div class="container">
<?php
$terms = get_terms( 'categoria-cursos', array(
'hide_empty' => false,
) );
// var_dump($terms);
$('a[href*="#"]:not([href="#"])').click(function () {
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
$("#links-do-menu .active").removeClass('active');
$(this).parent().addClass('active');
/* if($(".navbar-collapse").hasClass("active")) {
$(".navbar-collapse").removeClass("active");
}*/