Skip to content

Instantly share code, notes, and snippets.

View cpswsg's full-sized avatar

Cynthia Swain-Sugarman cpswsg

View GitHub Profile

Keybase proof

I hereby claim:

  • I am cynthiapereira on github.
  • I am cynthiapereira (https://keybase.io/cynthiapereira) on keybase.
  • I have a public key ASBU3Mj3edxb3fvkBXcOH3ofxePvt2ICuwKzrtXezojr6Ao

To claim this, I am signing this object:

@cpswsg
cpswsg / Git Hard Reset
Created June 6, 2015 06:38
Reseta e sincroniza repositório com o original remoto.
git remote add upstream <url-do-repositorio-original>
git fetch upstream
git checkout master
git reset --hard upstream/master
git push origin master --force
@cpswsg
cpswsg / categoria_por_parentesco.php
Created July 18, 2013 19:40
WordPress - Exibe a categoria-pai do post.
<?php
//Pega todas as categorias do post
$cats = get_the_category($post->ID);
//Verifica a primeira categoria retornada e pega seu parentesco.
//Se um post tem múltiplas categorias que levam a parentescos separados, retornará o primeiro parentesco pertencente à primeira categoria retornada.
$parent = get_category($cats[0]->category_parent);
//Se obtiver uma mesnagem de erro, significa que já estamos na categoria-pai.
if (is_wp_error($parent)){
@cpswsg
cpswsg / Favicon MetaTags
Created June 23, 2013 03:33
Meta Tags for Favicon
<!-- Favicon -->
<meta name="msapplication-TileImage" content="images/favicons/tile.png"> <!-- Windows 8 -->
<meta name="msapplication-TileColor" content="#00CCFF"/> <!-- Windows 8 color -->
<!--[if IE]><link rel="shortcut icon" href="images/favicons/favicon.ico"><![endif]-->
<link rel="icon" type="image/png" href="images/favicons/favicon.png">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="images/favicons/apple-touch-icon-precomposed-144x144.png"><!-- iPad Retina-->
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="images/favicons/apple-touch-icon-precomposed-114x114.png"><!--iPhone Retina -->
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="images/favicons/apple-touch-icon-precomposed-72x72.png"><!-- iPad 1 e 2 -->
<link rel="apple-touch-icon-precomposed" href="images/favicons/apple-touch-icon-precomposed-57x57.png"><!-- iPhone, iPod e Android 2.2+ -->
@cpswsg
cpswsg / widgets.php
Created June 15, 2013 19:01
WordPress Widget Recent Posts personalizado.
class My_Recent_Posts_Widget extends WP_Widget_Recent_Posts {
function widget($args, $instance) {
extract( $args );
$title = apply_filters('widget_title', empty($instance['title']) ? __('Tópicos recentes') : $instance['title'], $instance, $this->id_base);
if( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )
$number = 5;
$r = new WP_Query( apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) );
if( $r->have_posts() ) :
@cpswsg
cpswsg / functions.php
Created June 15, 2013 18:57
Adiciona os CPTs ao Box "Agora" no Painel de Administração do WordPress
add_action( 'right_now_content_table_end' , 'my_right_now_content_table_end' );
function my_right_now_content_table_end() {
$args = array(
'public' => true ,
'_builtin' => false
);
$output = 'object';
$operator = 'and';
$post_types = get_post_types( $args , $output , $operator );
@cpswsg
cpswsg / functions.php
Created June 15, 2013 18:55
Twitter Bootstrap Pagination para WordPress
function page_navi($pages = '', $range = 2){
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == ''){
global $wp_query, $wpdb;
$pages = $wp_query->max_num_pages;
@cpswsg
cpswsg / functions.php
Created June 15, 2013 18:54
Twitter Bootstrap Nav Menu para WordPress.
class Bootstrap_Walker_Nav_Menu extends Walker_Nav_Menu {
function start_lvl( &$output, $depth ) {
//In a child UL, add the 'dropdown-menu' class
$indent = str_repeat( "\t", $depth );
$output .= "\n$indent<ul class=\"dropdown-menu\">\n";
}
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
@cpswsg
cpswsg / functions.php
Created June 15, 2013 18:51
Formata o título do site no WordPress.
add_filter('wp_title', 'my_wp_title', 10, 2);
function my_wp_title($title, $sep){
global $paged, $page;
if (is_feed()) {
return $title;
}
// Add o nome do site.
$title .= get_bloginfo('name');
@cpswsg
cpswsg / atualizadb.sql
Created June 15, 2013 18:49
Atualiza o banco de dados do WordPress para uma nova URL.
UPDATE wp_options
SET option_value = REPLACE(option_value, 'http://localhost/site', 'http://www.site.com.br')
WHERE option_name = 'home'
OR option_name = 'siteurl';
UPDATE wp_posts
SET guid = REPLACE (guid, 'http://localhost/site', 'http://www.site.com.br');
UPDATE wp_posts
SET post_content = REPLACE (post_content, 'http://localhost/site', 'http://www.site.com.br');