Skip to content

Instantly share code, notes, and snippets.

View jacquesletesson's full-sized avatar

Jacques Letesson jacquesletesson

View GitHub Profile
@jacquesletesson
jacquesletesson / tweak-woocommerce-hide-coupon-field.php
Created November 29, 2015 14:30
WooCommerce : Hide coupon code fields on checkout if no coupon publish.
<?php
add_filter( 'woocommerce_coupons_enabled', 'restofrais_coupons_enabled_checkout' );
if( ! function_exists('restofrais_coupons_enabled_checkout')){
function restofrais_coupons_enabled_checkout($coupons_enabled){
$args = array(
'post_type' => 'shop_coupon',
'post_status' => 'publish',
@jacquesletesson
jacquesletesson / tweak-asp.php
Created March 20, 2015 08:49
Tweak Ajax Search Pro
function filter_asp_results($results){
$new_results = array();
foreach($results as $result){
if($result-&gt;post_type == 'artists'){
$id = $result-&gt;id;
$tax = wc_attribute_taxonomy_name(&quot;artist&quot;);
$x = get_term_by('name', $id, $tax);
$result-&gt;link = get_permalink( woocommerce_get_page_id( 'shop' ) ) . &quot;?filter_artist=&quot; . $x-&gt;term_id;
$new_results[] = $result;
} else {
@jacquesletesson
jacquesletesson / wpsl-load-custom-style.php
Created March 14, 2015 08:36
WPSL Load Custom Stylesheet
<?php
/**
* Load the required css styles
*
* @since 2.0
* @return void
*/
public function add_frontend_styles() {
$min = '';
@jacquesletesson
jacquesletesson / wp-output-additional-image-sizes.php
Last active August 29, 2015 14:15
wordpress-output-additional-image-sizes.php
<?php
global $_wp_additional_image_sizes;
print '<pre>';
print_r( $_wp_additional_image_sizes );
print '</pre>';
?>
@jacquesletesson
jacquesletesson / convert-bytes-to-unit.php
Created January 21, 2015 08:55
Convert bytes to human-friendly unit
// ------------------------------------------------------------
// :: Convert bytes to human-friendly unit
// :: Source: http://php.net/manual/en/function.filesize.php#106569
// ------------------------------------------------------------
function human_filesize($bytes, $decimals = 2) {
$sz = 'BKMGTP';
$factor = floor((strlen($bytes) - 1) / 3);
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$sz[$factor];
}
@jacquesletesson
jacquesletesson / wp-event-calendar-permalink-with-date.php
Last active October 20, 2016 00:20
The Event Calendar - Permalink with starting date injected automatically.