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_sale_flash', 'percentage_woocommerce_sale_flash', 10, 3 ); | |
function percentage_woocommerce_sale_flash( $html, $post, $product ) { | |
if ( $html!='' ) { | |
$perc = round( 100 - ( $product->sale_price * 100 / $product->regular_price ) ); | |
if ( $perc>0 ) $html = '<span class="onsale">-'.$perc.'%</span>'; | |
} | |
return $html; | |
} |
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_localisation_address_formats','custom_woocommerce_localisation_address_formats'); | |
function custom_woocommerce_localisation_address_formats($formats) { | |
//$formats['default']="{name}\n{company}\n{address_1}\n{address_2}\n{postcode} {city}\n{state}\n{country}"; | |
$formats['PT']="{name}\n{company}\n{address_1}\n{address_2}\n{postcode} {city}\n{state}\n{country}"; | |
return $formats; | |
} | |
?> |
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( 'admin_head', 'style_cmb2_copy_fields_as_readonly', 9999 ); | |
function style_cmb2_copy_fields_as_readonly() { | |
$screen = get_current_screen(); | |
//var_dump($screen); | |
if ( $screen->base == 'post' ) { | |
global $post, $sitepress; | |
if ( isset($post) && isset($sitepress) ) { |
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 | |
/* Instant Articles (https://wordpress.org/plugins/fb-instant-articles/) - Use post excerpt as subtitle */ | |
add_filter( 'instant_articles_subtitle', 'hf_instant_articles_subtitle' ); | |
function hf_instant_articles_subtitle( $subtitle ) { | |
$excerpt = get_the_excerpt(); | |
if ( trim($excerpt)!='' ) $subtitle = trim($excerpt); | |
return $subtitle; | |
} |
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 | |
/* | |
* When migrating an old website to WordPress, you should store pages/posts/... URLs in a custom field | |
* Example: /studio.php | |
* You can create a metabox to manually insert the URL, on the post edit scree, or have it imported directly if you are exporting/importing from the old CMS to WordPress | |
* If some visitor lands on the old URL, you then hook into the template_redirect, check if it's a 404, and then try to redirect him to the correct page/post/... | |
* This is of extreme importance SEO wise | |
*/ |
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 | |
//Code goes in theme functions.php. | |
add_filter( 'woocommerce_defer_transactional_emails', '__return_true' ); |
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 the strings to search | |
$strings = array( | |
'_0xaae8', | |
); | |
//Exclude file extensions | |
$extensions_ignore = array( | |
'jpg', | |
'png', |
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 | |
function apg_sms_procesa_el_telefono( $pedido, $telefono, $servicio, $propietario = false, $envio = false ) { | |
if ( apply_filters( 'apg_sms_procesa_el_telefono_processar', true, $pedido, $telefono, $servicio, $propietario, $envio ) ) { //Filter added by Marco Almeida - Should return false if no processing should be done | |
$numero_de_pedido = is_callable( array( $pedido, 'get_id' ) ) ? $pedido->get_id() : $pedido->id; | |
$billing_country = is_callable( array( $pedido, 'get_billing_country' ) ) ? $pedido->get_billing_country() : $pedido->billing_country; | |
$shipping_country = is_callable( array( $pedido, 'get_shipping_country' ) ) ? $pedido->get_shipping_country() : $pedido->shipping_country; | |
$prefijo = apg_sms_prefijo( $servicio ); | |
$telefono = str_replace( array( '+','-' ), '', filter_var( $telefono, FILTER_SANITIZE_NUMBER_INT ) ); | |
if ( !$propietario ) { | |
if ( ( !$envio && $billing_country && ( WC()->countries->get_base_country() != $billing_country ) || $prefijo ) ) { |
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_enqueue_scripts', 'my_scripts'); | |
function my_scripts() { | |
// Add your JS file | |
wp_enqueue_script( 'my_script', get_template_directory_uri().'/js/functions.js' ); | |
// Localize your script with server side data | |
global $sitepress; | |
wp_localize_script( 'my_script', 'my_var', array( | |
'wpml_current_language' => $sitepress->get_current_language(), //On javascript use my_var.wpml_current_language to get this value |
OlderNewer