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 / variaveis_url.tpl
Last active December 20, 2015 04:29
Fast codes smarty
{if $smarty.server.QUERY_STRING == "dispatch=products.view&product_id=301&stg"}
{foreach from=$navigation.tabs item=tab key=key name=tabs}
{if ((!$tabs_section && !$tab.section) || ($tabs_section == $tab.section)) && !$key|in_array:$empty_tab_ids}
{if !$active_tab}
{assign var="active_tab" value=$key}
{/if}
<div class="tabs clear cm-j-tabs">
<ul {if $tabs_section}id="tabs_{$tabs_section}"{/if}>
<li id="{$key}" class="{if $tab.js}cm-js{elseif $tab.ajax}cm-js cm-ajax{/if}{if $key == $active_tab} cm-active{/if}"><a{if $tab.href} href="{$tab.href|fn_url}"{/if}>{$tab.title}</a></li>
@luisfdeandrade
luisfdeandrade / fechar_aba_js.js
Created August 9, 2013 17:08
OnClose Window = Antes de fechar a página
window.onbeforeunload = function(e) {
return "Atençao, existe uma tarefa em execuçao";
};
@luisfdeandrade
luisfdeandrade / gist:7679271
Created November 27, 2013 17:04
CSS - uma linha só
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
@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: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 / 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' );

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 / 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
@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 / 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