This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(){ | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"http-basic": { | |
"bitbucket.org": { | |
"username": "[email protected]", | |
"password": "senhanobitbucket" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace OOPFunctions\MetaBoxes\GenericBox; | |
if ( !class_exists('\OOPFunctions\MetaBoxes\GenericBox\GenericBox') ) { | |
/** | |
* Description of GenericBox | |
* | |
* @author Pablo Pacheco <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Password protects a custom post type programmatically. | |
* | |
* @param $post | |
*/ | |
add_action( 'the_post', function( $post ){ | |
if ( $post->post_type != 'post' ) { | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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%); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace OOPFunctions\MetaBoxes\Gallery; | |
if ( !class_exists('\OOPFunctions\MetaBoxes\Gallery\Gallery') ) { | |
/** | |
* Description of Gallery | |
* | |
* @author Pablo Pacheco <[email protected]> |
OlderNewer