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 | |
add_filter('woocommerce_get_shop_coupon_data', 'fix_wc_coupon_discount_amount', 10, 3); | |
function fix_wc_coupon_discount_amount( $false, $data, $coupon ) { | |
if ( | |
'yes' !== get_option( 'wcj_multicurrency_compatibility_wc_coupons', 'no' ) | |
|| is_admin() | |
|| empty( $coupon_id = wc_get_coupon_id_by_code( $data ) ) | |
|| 'fixed_cart' != get_post_meta( $coupon_id, 'discount_type', true ) | |
) { | |
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
<?php | |
// Custom deactivation/activation hooks. | |
$activation_hook = 'plugin_prefix_on_activation'; | |
$deactivation_hook = 'plugin_prefix_on_deactivation'; | |
register_activation_hook( __FILE__, function () use ( $activation_hook ) { | |
add_option( $activation_hook, 'yes' ); | |
} ); | |
register_deactivation_hook( __FILE__, function () use ( $deactivation_hook ) { | |
do_action( $deactivation_hook ); | |
} ); |
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 array to string. | |
* | |
* @param $arr | |
* @param array $args | |
* | |
* @return string | |
*/ | |
function convert_array_to_string( $arr, $args = array() ) { |
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
<?php | |
add_action('wp_footer',function(){ | |
if ( !WCJ()->modules['price_by_country']->is_enabled() ) { | |
return; | |
} | |
$country = WCJ()->modules['price_by_country']->core->get_customer_country_by_ip(); | |
$group = WCJ()->modules['price_by_country']->core->get_customer_country_group_id(); | |
$the_result = array('country'=>$country,'group'=>$group); | |
?> | |
<script> |
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 | |
/** | |
* Adds CNPJ and Company Name fields on the Thank You page and Order Received Email when using 'Direct Bank Transfer' payment gateway. | |
*/ | |
add_filter( 'woocommerce_bacs_account_fields', function ( $fields ) { | |
$fields['cnpj']['label'] = __( 'CNPJ', 'domain' ); | |
$fields['cnpj']['value'] = '99.999.999/9999-99'; | |
$fields['company_name']['label'] = __( 'Razao Social', 'domain' ); | |
$fields['company_name']['value'] = 'Uma empresa doce e bacana Ltda'; | |
return $fields; |
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 | |
/** | |
* Deletes transients that match a specific prefix. | |
* | |
* @author Pablo Pacheco <pablo.sg.pacheco@gmail.com> | |
* @param string $prefix prefix to search for. | |
* @return int|bool Boolean true for CREATE, ALTER, TRUNCATE and DROP queries. Number of rows affected/selected for all other queries. Boolean false on error. | |
*/ | |
function delete_transients_by_prefix($prefix){ |
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 | |
// Remove the Tax Line item from the cart. | |
function wc_remove_cart_tax_totals( $tax_totals, $instance ) { | |
if( is_cart() ) { | |
$tax_totals = array(); | |
} | |
return $tax_totals; | |
} |
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
<tr><td><div><label for="%field_id%">%title%</label></div>%field%</td></tr> |
NewerOlder