Skip to content

Instantly share code, notes, and snippets.

View pedrorvidal's full-sized avatar

Pedro Vidal pedrorvidal

  • Porto Alegre, Brazil.
View GitHub Profile
#!/bin/bash
# requires lynx,grep,awk,uniq,sort,egrep,head,xargs,wget,tar adn rm
lynx -dump http://br.wordpress.org/releases | /bin/grep "\.tar\.gz$" | awk -F'http://' '{ print "http://"$2 }' | uniq | sort -r | /bin/egrep -v 'RC|beta' | head -n1 | xargs wget -O wordpress-br.tar.gz
tar -xvf wordpress-br.tar.gz
/bin/rm wordpress-br.tar.gz
#GIT#
git checkout -b branch-name master
git status
git add <some-file>
git commit
git push -u origin branch-name
@pedrorvidal
pedrorvidal / wordpress-post-thumbnail-or-first-image-or-default.php
Last active August 29, 2015 14:26 — forked from brajeshwar/wordpress-post-thumbnail-or-first-image-or-default.php
Wordpress - Get the Image from Post Thumbnail or the First Image of a post or else use a default Image.
/*
* Display Image from the_post_thumbnail or the first image of a post else display a default Image
* Chose the size from "thumbnail", "medium", "large", "full" or your own defined size using filters.
* USAGE: <?php echo my_image_display(); ?>
*/
function my_image_display($size = 'full') {
if (has_post_thumbnail()) {
$image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id, $size);
@pedrorvidal
pedrorvidal / Gruntfile.js
Created July 6, 2016 19:32 — forked from jshawl/Gruntfile.js
Grunt + Sass + Autoprefixer
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dist: {
options:{
style:'compressed'
},
files: {
'css/style.css' : 'scss/style.scss'
@pedrorvidal
pedrorvidal / gist:bb97b3a9711c54b3aca411380028ce86
Created January 30, 2017 19:50 — forked from danielbachhuber/gist:7126249
Include posts from authors in the search results where either their display name or user login matches the query string
<?php
/**
* Include posts from authors in the search results where
* either their display name or user login matches the query string
*
* @author danielbachhuber
*/
add_filter( 'posts_search', 'db_filter_authors_search' );
function db_filter_authors_search( $posts_search ) {
@pedrorvidal
pedrorvidal / fix-wordpress-permissions.sh
Last active March 3, 2017 01:15 — forked from Adirael/fix-wordpress-permissions.sh
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
#
# RODAR USANDO ./fix-wordpress-permissions.sh <nome_da_pasta_wordpress>
#
@pedrorvidal
pedrorvidal / spotify_keybindings
Created July 4, 2017 19:16 — forked from jbonney/spotify_keybindings
Spotify - Linux key bindings. From XFCE / Ubuntu keyboard shortcuts configuration, assign the control command to their key. http://shkspr.mobi/blog/2011/12/linux-spotify-keybindings/
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause" XF86AudioPlay
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop" XF86AudioStop
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next" XF86AudioNext
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous" XF86AudioPrevious
@pedrorvidal
pedrorvidal / functions.php
Created July 28, 2019 19:08
Estados e cidades brasileiras populados em uma taxonomia do wordpress.
<?php
// É aconselhável criar um backup do banco antes
// crie a taxonomia cidade na functions do tema
add_action('init', 'register_locations');
function register_locations() {
register_taxonomy( 'cidade',array (
0 => 'locais',
),
array( 'hierarchical' => true,