Skip to content

Instantly share code, notes, and snippets.

Pablo dos Santos Gonçalves Pacheco pablo-sg-pacheco

Block or report user

Report or block pablo-sg-pacheco

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@pablo-sg-pacheco
pablo-sg-pacheco / GenericBox.php
Last active Apr 28, 2016
CMB2 - Generic Box - Group field (image, title, description, link, target, label)
View GenericBox.php
<?php
namespace OOPFunctions\MetaBoxes\GenericBox;
if ( !class_exists('\OOPFunctions\MetaBoxes\GenericBox\GenericBox') ) {
/**
* Description of GenericBox
*
* @author Pablo Pacheco <pablo.pacheco@origgami.com.br>
@pablo-sg-pacheco
pablo-sg-pacheco / center-v.css
Last active May 10, 2016
CSS - Center vertically
View center-v.css
.center-v-parent{
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
transform-style: preserve-3d;
}
.center-v {
position: relative;
top: 50%;
transform: translateY(-50%);
}
@pablo-sg-pacheco
pablo-sg-pacheco / functions.php
Last active May 31, 2016
Frete grátis por região (faixa de cep) - Woocommerce
View functions.php
<?php
//Testa uma faixa de cep
function checkCpfRange($valor, $intervalos) {
$v = (int) preg_replace("/\D+/", "", $valor);
foreach ($intervalos as $range):
list($min, $max) = $range;
if ($v >= $min && $v <= $max)
return true;
endforeach;
return false;
@pablo-sg-pacheco
pablo-sg-pacheco / functions.php
Last active Jun 7, 2016
Woocommerce - Reduz o estoque quando o pedido eh criado. Tem q ser usado com o plugin (https://wordpress.org/plugins/woocommerce-auto-restore-stock/).OBS: Só funciona corretamente com o Pagseguro. Outras formas de pagamento vão baixar o estoque 2 vezes
View functions.php
<?php
//Reduz o estoque quando o pedido eh criado
//Tem q ser usado com o plugin (https://wordpress.org/plugins/woocommerce-auto-restore-stock/)
//Lembrando que so vai funcionar corretamente com o pagseguro
add_action( 'woocommerce_thankyou', 'woocommerce_reduce_order_stock' );
function woocommerce_reduce_order_stock( $order_id ) {
global $woocommerce;
if ( !$order_id )
return;
$order = new WC_Order( $order_id );
@pablo-sg-pacheco
pablo-sg-pacheco / wp-config.php
Created Jun 20, 2016
(Wp-config) - Site relativo
View wp-config.php
<?php
$protocol = 'http://';
$http_host = $_SERVER['HTTP_HOST'];
$siteFolder = 'cool-magazine';
define('WP_HOME', $protocol.$http_host.'/'.$siteFolder);
define('WP_SITEURL', $protocol.$http_host.'/'.$siteFolder);
define('WP_CONTENT_URL', $protocol.$http_host.'/'.$siteFolder.'/wp-content');
define('DOMAIN_CURRENT_SITE', $http_host);
View VideoCmb.php
<?php
namespace OOPFunctions\MetaBoxes\VideoCmb;
if ( !class_exists('\OOPFunctions\MetaBoxes\VideoCmb\VideoCmb') ) {
/**
* Description of VideoCmb
*
* @author Pablo Pacheco <pablo.pacheco@origgami.com.br>
@pablo-sg-pacheco
pablo-sg-pacheco / functions.php
Created Jun 28, 2016
Set thumbnail by external image URL
View functions.php
<?php
function setThumbnailByUrl( $imgUrl, $post_id ) {
$post = get_post($post_id);
$media = media_sideload_image($imgUrl, $post_id, $post->post_title);
// therefore we must find it so we can set it as featured ID
if ( !empty($media) && !is_wp_error($media) ) {
$args = array(
'post_type' => 'attachment',
@pablo-sg-pacheco
pablo-sg-pacheco / Youtube.php
Created Jun 28, 2016
Class for get an image from a youtube video URL
View Youtube.php
<?php
namespace OOPFunctions\Youtube;
if ( !class_exists('\OOPFunctions\Youtube\Youtube') ) {
/**
* Description of Youtube
*
* @author Pablo Pacheco <pablo.pacheco@origgami.com.br>
@pablo-sg-pacheco
pablo-sg-pacheco / colorbox-youtube.js
Created Jun 28, 2016
Colorbox - Open youtube videos
View colorbox-youtube.js
jQuery(".a-video").colorbox({
rel: 'a-video',
iframe: true,
innerWidth: 640,
innerHeight: 390,
href: function () {
var videoId = new RegExp('[\\?&]v=([^&#]*)').exec(this.href);
if(videoId && videoId[1]){
return 'http://youtube.com/embed/' + videoId[1] + '?rel=0&wmode=transparent';
}
@pablo-sg-pacheco
pablo-sg-pacheco / Gallery.php
Last active Jul 4, 2016
CMB2 - Classe para criar uma galeria padrão, usando CMB2
View Gallery.php
You can’t perform that action at this time.