Skip to content

Instantly share code, notes, and snippets.

View claudiosanches's full-sized avatar
👨‍💻

Claudio Sanches claudiosanches

👨‍💻
View GitHub Profile
@claudiosanches
claudiosanches / plugin.php
Created December 24, 2012 14:54
Exemplo para o Marildo Vezaro.
<?php
function cs_display_custom_fields( $content ) {
// Recupera o objeto post.
global $post;
// Testa se é uma página simples e se o tipo do conteúdo é o seu.
if ( is_single() && $post->post_type == 'nome_do_seu_post_type_aqui' ) {
// Aqui como pegar as informações que foram salvas com o metabox:
@claudiosanches
claudiosanches / bom-finder.php
Created December 28, 2012 21:56
BOM Finder
<?php
// Tell me the root folder path.
// You can also try this one
// $HOME = $_SERVER["DOCUMENT_ROOT"];
// Or this
// dirname(__FILE__)
$HOME = dirname( __FILE__ );
// Is this a Windows host ? If it is, change this line to $WIN = 1;
$WIN = 0;
$sprites: sprite-map("sprites/*.png");
$sprites-retina: sprite-map("sprites-retina/*.png");
@mixin sprite-background($name) {
background-image: sprite-url($sprites);
background-position: sprite-position($sprites, $name);
background-repeat: no-repeat;
display: block;
height: image-height(sprite-file($sprites, $name));
width: image-width(sprite-file($sprites, $name));
@claudiosanches
claudiosanches / single.php
Last active December 10, 2015 13:08
Gist pra Van Soares
<header>
<h1 id="post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<div class="entry-info"><span class="info1"><?php the_time('d \d\e F \d\e Y'); ?> </span> <span class="info2"> Por: <?php echo '<a href="' . get_the_author_meta( 'user_url' ) . '" rel="me" title="' . get_the_author() . '">' . get_the_author() . '</a>'; ?></span>
<span class="cat1"><?php if ( count( get_the_category() ) ) : ?>
<?php printf( __( '<span class="%1$s">Arquivado em </span> %2$s'), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?> </span> <?php endif; ?></div>
</header>
<?php
function cs_custom_posts_per_page( $query ) {
$query->query_vars['posts_per_page'] = 9999;
return;
}
add_filter( 'pre_get_posts', 'cs_custom_posts_per_page' );
@claudiosanches
claudiosanches / fix_uploads.sql
Created January 6, 2013 16:44
Gist para o Paulo Beneton
# Update post_content
UPDATE wp_posts SET post_content = REPLACE(post_content,'http://localhost/wp-content/uploads/','http://localhost/wordpress/wp-content/uploads/');
# Update guid
UPDATE wp_posts SET guid = REPLACE(guid,'http://localhost/wp-content/uploads/','http://localhost/wordpress/wp-content/uploads/');
@claudiosanches
claudiosanches / personaliza-biografia.php
Last active December 10, 2015 17:38
Plugin Personalizar Biografia para o Rafael Carvalho
<?php
/*
* Plugin Name: Personaliza Biografia
* Plugin URI: http://claudiosmweb.com/
* Description: Personaliza Biografia.
* Version: 0.1
* Author: Claudio Sanches
* Author URI: http://claudiosmweb.com/
* License: GPLv2 or later
*/
@claudiosanches
claudiosanches / functions.php
Last active December 10, 2015 20:28
Excluir categorias da homepage.
<?php
/**
* Excluir categorias da homepage.
*
* @param object $query Query padrão.
*
* @return object Query sem algumas categorias.
*/
function cs_homepage_loop( $query ) {
// Funciona apenas na home.
@claudiosanches
claudiosanches / category-image-field.php
Last active November 18, 2017 19:23
Adds image field in category description.
<?php
/*
* Plugin Name: Category Image Field
* Plugin URI: http://claudiosmweb.com/
* Description: Adds image field in category description.
* Version: 0.1
* Author: Claudio Sanches
* Author URI: http://claudiosmweb.com/
* License: GPLv2 or later
*/
# Update post_content
UPDATE wp_posts SET post_content = REPLACE(post_content,'http://www.url-antiga.com.br/','http://www.url-nova.com.br/');
# Update guid
UPDATE wp_posts SET guid = REPLACE(guid,'http://www.url-antiga.com.br/','http://www.url-nova.com.br/');