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 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 / 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
//Usage
try {
$(window).on('load', function() {
equalize_height($('#parent'), '.element');
});
$(window).resize(function(){
equalize_height($('#parent'), '.element');
});
} catch(err) {console.log(err);}
(function($) {
if ($.fn.style) {
return;
}
// Escape regex chars with \
var escape = function(text) {
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
};
@leocaseiro
leocaseiro / metabox-table.html
Created October 20, 2014 03:48
Metabox Table HTML Form example
<table class="form-table">
<tbody>
<tr>
<th scope="row"><label>Example:</label></th>
<td>
<select name="select-name-whenever">
<option>1</option>
<option>lorem</option>
</select>
</td>
@leocaseiro
leocaseiro / custom-comments-pagination.php
Created January 23, 2015 05:29
Comments Pagination WordPress
<?php
$comments_per_page = 2;
$page = 2;
//MYSQL: LIMIT offset, number
$params = array(
'post_id' => $post_id,
'offset' => (--$page) * $comments_per_page,
'number' => $comments_per_page,
);