Skip to content

Instantly share code, notes, and snippets.

View leocaseiro's full-sized avatar
💭
I',m probably studying...

Leo Caseiro leocaseiro

💭
I',m probably studying...
View GitHub Profile
functions.php
<?php
function custom_rewrite_rules() {
global $wp_rewrite;
// Define the param estado
add_rewrite_tag( '%estado%', '([^&]+)' );
//For this result: empresas-garimpeiras/estado/pernambuco
<?php
$params = array('post_type' => 'garimpeiros', 'paged' => $paged);
if (isset($wp_query->query_vars['estado']) && '' != $wp_query->query_vars['estado'] ) :
$params['tax_query'] = array(
array(
'taxonomy' => 'estado',
'field' => 'slug',
'terms' => array($wp_query->query_vars['estado']),
)
);
<?php
$params = array('post_type' => 'garimpeiros', 'paged' => $paged);
if (isset($wp_query->query_vars['estado']) && '' != $wp_query->query_vars['estado'] ) :
$params['meta_query'] = array(
array(
'key' => 'estado',
'compare' => '=',
'value' => $wp_query->query_vars['estado'],
)
function get_tweets($tweet_count, $username) {
if (empty($username))
return false;
$list = get_transient('list_of_tweets');
if (!$list) {
return fetch_tweets($tweet_count, $username);
function codeAddress(address) {
geocoder = new google.maps.Geocoder();
geocoder.geocode({
'address': address
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var myOptions = {
zoom: 14,
center: results[0].geometry.location,
disableDoubleClickZoom: true, //not zoom
@leocaseiro
leocaseiro / leocaseiro.terminal
Created June 24, 2014 04:49
Mac My Own Terminal
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BackgroundAlphaInactive</key>
<real>0.73665552745664742</real>
<key>BackgroundBlur</key>
<real>0.091763005780346824</real>
<key>BackgroundColor</key>
<data>
@leocaseiro
leocaseiro / datetime.php
Created June 25, 2014 06:51
Create timestamp from dd/mm/yyyy H:m with PHP >= 5.3
<?php
$datetime = '01/06/1985 15:45';
$timestamp = DateTime::createFromFormat('d/m/Y H:i', $datetime)->getTimestamp();
echo $timestamp;
$datetime = date('d-m-Y H:i', $timestamp);
var_dump($datetime);
@leocaseiro
leocaseiro / hosts
Last active August 29, 2015 14:03
Apache PHP VHOSTS on Maverick 10.9
## /private/etc/hosts
#
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
@leocaseiro
leocaseiro / jquery-ui-sortable-remove-dragged-item-out.js
Created July 4, 2014 00:12
jQuery UI Sortable Remove Dragged Item out
$( "#sortable" ).sortable({
forcePlaceholderSize: true,
tolerance: 'pointer',
cursor: 'pointer',
over: function () {
removeIntent = false;
},
out: function () {
removeIntent = true;
},
functions.php
<?php
function my_custom_queries($query) {
//Never in admin mode, only the main query(the URL one) and in this case on custom post 'event'
if ( !is_admin() && $query->is_main_query() && $query->is_post_type_archive('event')) {
$paged = ( get_query_var( 'page' ) ) ? absint( get_query_var( 'page' ) ) : 1; //URL /page