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 / functions.php
Last active Nov 24, 2016
Shows out of stock message when a variable product has all variations out of stock
View functions.php
<?php
//Shows out of stock message when a variable product has all variations out of stock
add_filter('wp_footer', function(){
if(is_product()){
global $product;
if($product->is_type('variable')){
if(!$product->is_in_stock()){
?>
<script>
jQuery(window).load(function(){
@pablo-sg-pacheco
pablo-sg-pacheco / functions.php
Last active Nov 24, 2016
Replaces product price by out of stock message in case a variable product is out of stock (Woocommerce)
View functions.php
<?php
//Replaces product price by out of stock message in case a variable product is out of stock (optional)
add_action('woocommerce_before_single_product_summary',function(){
if(is_product()){
global $product;
if(!$product->is_in_stock()){
remove_action('woocommerce_single_variation','woocommerce_single_variation');
remove_action('woocommerce_single_product_summary','woocommerce_template_single_price');
add_action('woocommerce_single_product_summary',function(){
?>
@pablo-sg-pacheco
pablo-sg-pacheco / auth.json
Last active Nov 22, 2016
Origgami Wordpress Install (using Odin and Oggone Themes)
View auth.json
{
"http-basic": {
"bitbucket.org": {
"username": "email@origgami.com.br",
"password": "senhanobitbucket"
}
}
}
@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 / functions.php
Last active Aug 24, 2016
Converts content in Contact Details fields. Ex: {{email}}
View functions.php
<?php
//Converts content in Contact Details fields. Ex: {{email}}
add_filter( 'the_content', function($content){
$contactDetails = get_option('contact');
foreach ( $contactDetails as $key => $detail ) {
if ( !empty($detail) ) {
if(strpos($detail, '@')!==false){
$content = str_replace('{{'.$key.'}}', '<a href="mailto:' . $detail . '">' . $detail . '</a>', $content);
}else if(strpos($detail, 'http://')!==false){
$content = str_replace('{{'.$key.'}}', '<a target="_blank" href="' . $detail . '">' . $detail . '</a>', $content);
@pablo-sg-pacheco
pablo-sg-pacheco / functions.php
Last active Oct 5, 2016
Add default contact details fields
View functions.php
<?php
//Add default contact details fields
add_filter('contact_details', function( $details ) {
unset($details['phone']);
unset($details['fax']);
unset($details['email']);
unset($details['mobile']);
unset($details['address']);
@pablo-sg-pacheco
pablo-sg-pacheco / functions.php
Last active Aug 29, 2019
Wordpress - Password protect a custom post type programmatically
View functions.php
<?php
//Password Protect programmatically
function passwordProtectPosts($post_object) {
//Checks if current post is a specific custom post type
if ($post_object->post_type!='tutorial')) {
return;
}
//Checks if current post is from a specific category
@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 / 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 / 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.