Skip to content

Instantly share code, notes, and snippets.

View rodrigoea's full-sized avatar
🏠
Working from home

Rodrigo Antinarelli rodrigoea

🏠
Working from home
View GitHub Profile
@rodrigoea
rodrigoea / fields.php
Last active August 29, 2015 14:06
Dynamic Custom Fields With Custom Metaboxes - Wordpress
//download
$meta_boxes[] = array(
'id' => 'meta_marcas_downloads',
'title' => 'Downloads',
'pages' => array( 'qd_marcas' ), // Post type
'context' => 'normal',
'priority' => 'high',
'show_names' => true, // Show field names on the left
'fields' => array(
@rodrigoea
rodrigoea / gist:e12a2bf8a7309d2fd65e
Last active October 19, 2015 01:32
How to use the simple and perfect Deployment Workflow with Git and SSH ~ Automated Deploy (Bitbucket)

#Learn how to use the simple and perfect Deployment Workflow with Git and SSH

###Requirements

  • Bitbucket Account (You can also use Github or other GIT service).
  • SSH access to the publishing server
  • Have tool git installed on the local environment and server

ro ##Step 1 - Create a local git repo

@rodrigoea
rodrigoea / gist:de0ea52ac5227fe88a19
Created August 28, 2014 14:09
Show Youtube title, description and views count with PHP
<?php
$youtube_id = 'JmRRawnSJEs';
$json_output = file_get_contents("http://gdata.youtube.com/feeds/api/videos/${youtube_id}?v=2&alt=json");
$json = json_decode($json_output, true);
//This gives you the video description
$video_description = $json['entry']['media$group']['media$description']['$t'];
//This gives you the video views count
$view_count = $json['entry']['yt$statistics']['viewCount'];
@rodrigoea
rodrigoea / count.html
Last active August 29, 2015 14:05
Show number of comments from Disqus
<a href="#disqus_thread"><span class="show-comments" data-disqus-url="CURRENT_URL">0 Comentários</span></a>
@rodrigoea
rodrigoea / functions.php
Created August 26, 2014 18:50
How to get submenu items from a WordPress menu based on parent or sibling
// add hook
add_filter( 'wp_nav_menu_objects', 'my_wp_nav_menu_objects_sub_menu', 10, 2 );
// filter_hook function to react on sub_menu flag
function my_wp_nav_menu_objects_sub_menu( $sorted_menu_items, $args ) {
if ( isset( $args->sub_menu ) ) {
$root_id = 0;
// find the current menu item
foreach ( $sorted_menu_items as $menu_item ) {
@rodrigoea
rodrigoea / CF - Estados
Last active August 29, 2015 14:05
Estados do Brasil - Wordpress & HTML
array(
'name' => 'Estado',
'desc' => '',
'id' => $prefix . 'oc_estado',
'type' => 'select',
'options' => array(
array( 'name' => 'Selecione um Estado', 'value' => '', ),
array( 'name' => 'Acre', 'value' => 'Acre', ),
array( 'name' => 'Alagoas', 'value' => 'Alagoas', ),
array( 'name' => 'Amapá', 'value' => 'Amapá', ),
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
@rodrigoea
rodrigoea / gist:26e3de0bf13af853565b
Last active August 29, 2015 14:05
Make local repository same as remote

git fetch --all

git reset --hard origin/master

@rodrigoea
rodrigoea / gist:bb91d6d8323318995cab
Last active August 29, 2015 14:04
Procedimentos para clonar um repositório no servidor via SSH

##Procedimentos para clonar um repositório no servidor via SSH

Para todo novo repositório deve ser gerado uma chave pública SSH para que a conexão seja permitida.

##Criar chave pública SSH

ssh-keygen

##Copiar chave pública para o clipboard

@rodrigoea
rodrigoea / gist:817479ef9913e91735c5
Created June 25, 2014 13:11
Update Wordpress URL in Database
UPDATE wpQd1_options SET option_value = replace(option_value, 'http://oldurl/', 'http://newurl/') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wpQd1_posts SET guid = replace(guid, 'http://oldurl','http://newurl');
UPDATE wpQd1_posts SET post_content = replace(post_content, 'http://oldurl', 'http://newurl');
UPDATE wpQd1_postmeta SET meta_value = replace(meta_value,'http://oldurl','http://newurl');