Skip to content

Instantly share code, notes, and snippets.

View claudiosanches's full-sized avatar
👨‍💻

Claudio Sanches claudiosanches

👨‍💻
View GitHub Profile
@claudiosanches
claudiosanches / sample-plugin.php
Created August 9, 2012 02:41
Base para criar um novo plugin
<?php
/*
Plugin Name: Nome do plugin
Plugin URI: Link para a página do plugin (preencha com o endereço do seu blog ou de onde você pegou o código)
Description: Uma breve descrição do que o plugin faz
Version: Versão do plugin, por exemplo 1.0
Author: Nome do Autor do plugin
Author URI: Link do autor (Coloque o endereço do seu blog por exemplo)
*/
@claudiosanches
claudiosanches / favicon.php
Created August 9, 2012 02:53
Colocar um favicon no wordpress
<?php
/*
Plugin Name: Adicionar favicon no blog
Plugin URI: http://www.ferramentasblog.com/2010/02/como-trocar-favicon-blogger-wordpress.html
Description: Adiciona facilmente um favicon no Wordpress
Version: 1.0
Author: Marcos Lemos, Claudio Sanches
Author URI: http://www.ferramentasblog.com/
*/
@claudiosanches
claudiosanches / paginated-gallery.php
Created August 16, 2012 00:15
Galeria com Páginação
@claudiosanches
claudiosanches / functions.php
Created August 16, 2012 16:53
Manipulate Child Pages to Use Parent Page Templates Automatically
<?php
// Manipulate Child Pages to Use Parent Page Templates Automatically
function switch_page_template() {
global $post;
// Checks if current post type is a page, rather than a post
if (is_page()) {
$current_page_template = get_post_meta($post->ID, '_wp_page_template', true);
if (!$current_page_template) {
@claudiosanches
claudiosanches / header.php
Created August 21, 2012 02:45
jQuery hide
<?php if (is_home() || is_front_page()): ?>
<script type="text/javascript">
$(document).ready(function() {
$('.content').hide();
});
</script>
<?php endif; ?>
@claudiosanches
claudiosanches / index.php
Created August 21, 2012 04:05
Current user is...
<?php
$current_user = wp_get_current_user();
if (isset($current_user->caps['administrator'])) {
echo 'Olá administrador';
}
if (isset($current_user->caps['editor'])) {
echo 'Olá editor';
}
@claudiosanches
claudiosanches / functions.php
Created August 21, 2012 04:16
WP Is Current User
<?php
/**
* Verifica o papel do usuário.
*
* Exempo de uso:
* if (is_current_user('administrator')) {
* echo 'Olá administrador';
* }
*
* @param string $user
@claudiosanches
claudiosanches / index.php
Created August 25, 2012 23:04
Get The Author ID
<?php
$author = get_the_author_meta('ID');
if ($author == 1) {
echo 'faça isso';
}
?>
@claudiosanches
claudiosanches / functions.php
Last active October 9, 2015 09:57
Wordpress: Automatically sets the post thumbnail
<?php
/**
* Automatically sets the post thumbnail.
*
* @global array $post WP post object.
*/
function odin_autoset_featured() {
global $post;
if ( isset( $post->ID ) ) {
@claudiosanches
claudiosanches / Grunt.sublime-build
Created August 27, 2012 01:12
Sublime Text 2: Grunt Build
{
"cmd": ["grunt", "default", "--no-color"],
"working_dir": "${project_path:${folder}}/src"
}