Skip to content

Instantly share code, notes, and snippets.

View luisfdeandrade's full-sized avatar

Luís Felipe de Andrade luisfdeandrade

View GitHub Profile
@luisfdeandrade
luisfdeandrade / gist:a8a99cb75ce4361ee003
Created February 15, 2016 16:01
Remove big files on GIT
git rev-list --all --objects | \
sed -n $(git rev-list --objects --all | \
cut -f1 -d' ' | \
git cat-file --batch-check | \
grep blob | \
sort -n -k 3 | \
tail -n40 | \
while read hash type size; do
echo -n "-e s/$hash/$size/p ";
done) | \
<?php
/*
* This scripts changes all occurrences of a URL in your WordPress database.
*
* It will compare the $newUrl against the URL saved on you wp_options table (site_url), or in the domain column of the wp_sites table for a Multi Site installation.
*
* It will handle serialized data and Objects stored in the database.
*
*
*/
@luisfdeandrade
luisfdeandrade / command_line_sublime_text_3
Created January 29, 2015 12:45
Setting up Sublime to open in Mac command line
ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime
@luisfdeandrade
luisfdeandrade / INTERSECTION-TAXONOMY
Created October 21, 2014 11:58
Wordpress - Taxonomy Intersection
<?php
/**
* Get all terms of $tax_to taxonomy that posts in $term_from of $tax_from have.
*
* @param string $tax_from taxonomy name
* @param string $term_from term slug
* @param string $tax_to taxonomy name
*
@luisfdeandrade
luisfdeandrade / wp_sql_delete_orfans
Created May 23, 2014 20:23
Deleta postmeta orfãos
DELETE pm
FROM wp_postmeta pm
LEFT JOIN wp_posts wp ON wp.ID = pm.post_id
WHERE wp.ID IS NULL

Mostrar somente os últimos arquivos alterados no log do git

Esse exemplo mostra todos os arquivos alterados nos últimos dois dias, sem repetir:

git log --pretty=format: --name-only --since="2 days ago" | sort | uniq
@luisfdeandrade
luisfdeandrade / prioridade_yoast.php
Created March 12, 2014 14:12
Setting Yoast Metabox priority low
function lower_wpseo_priority( $html )
{
return 'low';
}
add_filter( 'wpseo_metabox_prio', 'lower_wpseo_priority' );
@luisfdeandrade
luisfdeandrade / gist:8578144
Created January 23, 2014 13:04
Mensagem validação custom post type
function save_post_representante() {
......
$representante = get_post($clientes[$cliente]);
$erro = 'O cliente "<strong> '. $representante->post_title. '</strong> " já está cadastrado para o representante "'. $post->post_title.'" ';
} set_transient( get_current_user_id().'missingfield', $erro );
function representante_validacao() {
if($out = get_transient( get_current_user_id().'missingfield' ) ) {
delete_transient( get_current_user_id().'missingfield' );
@luisfdeandrade
luisfdeandrade / gist:8577285
Last active January 4, 2016 05:49
Searching posts by multiple meta_key values.
// Change ids to int.
foreach ($clientes as $key => $value) {
$clientes[$key] = (int) $value;
}
$args = array(
'post_type' => 'clientes',
'post_status' => 'publish',
@luisfdeandrade
luisfdeandrade / gist:7679271
Created November 27, 2013 17:04
CSS - uma linha só
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;