Skip to content

Instantly share code, notes, and snippets.

@Frique
Frique / functions.php
Created April 18, 2021 12:33
WCSSM: Force the native sale-price overwrite
// Force the native sale-price overwrite
add_filter( 'get_post_metadata', 'wcssm_markus_filter_sale_price_meta', 11, 4 );
function wcssm_markus_filter_sale_price_meta( $value, $object_id, $meta_key, $single ) {
if ( $meta_key === '_sale_price' ) {
remove_filter( 'get_post_metadata', 'wcssm_markus_filter_sale_price_meta', 11, 4 );
if ( $sale = WCSSM::get_applicable_sale( $object_id ) ) {
$value = $sale['price'];
@Frique
Frique / functions.php
Created April 18, 2021 12:30
WCSSM: Support for the Woodmart Countdown timer
// Force the native sale-price-end-date overwrite
add_filter( 'get_post_metadata', 'wcssm_woodmart_filter_sale_price_meta', 11, 4 );
function wcssm_woodmart_filter_sale_price_meta( $value, $object_id, $meta_key, $single ) {
if ( $meta_key === '_sale_price_dates_to' ) {
remove_filter( 'get_post_metadata', 'wcssm_woodmart_filter_sale_price_meta', 11, 4 );
if ( $sale = WCSSM::get_applicable_sale( $object_id ) ) {
$schedule = array_shift( $sale['schedule'] );
@Frique
Frique / functions.php
Created January 13, 2019 13:58
Clientside: conditionally disable admin theming
add_filter( 'clientside-is-themed', function( $bool ) {
if ( $_GET['page'] === 'my-admin-page' ) {
$bool = false;
}
return $bool;
} );
@Frique
Frique / functions.php
Created January 3, 2019 00:13
WCSSM: Do not apply sales to out-of-stock products
add_filter( 'wcssm-applicable-sales', function( $value, $product ) {
if ( ! $product->is_in_stock() ) {
$value = null;
}
return $value;
}, 10, 2 );
@Frique
Frique / functions.php
Last active December 29, 2018 16:50
wcssm woocs support
// Scheduled Sale Manager for WooCommerce support for Currency Switcher for WooCommerce by RealMag777
// Prevents incorrect sale price when the "Advanced > Is multiple allowed" option is enabled.
if ( class_exists( 'WOOCS' ) ) {
global $WOOCS;
add_filter( 'woocommerce_product_get_price', function( $price, $product_object ) {
global $WOOCS;
$is_manual_sale = $product_object->get_sale_price( 'edit' ) && $product_object->get_sale_price( 'edit' ) == WCSSM::get_product_sale_price( $product_object->get_sale_price( 'edit' ), $product_object );
@Frique
Frique / example_fancybox-gallery.html
Created October 31, 2015 05:16
Etalage example: fancybox with gallery
@Frique
Frique / functions.php
Last active August 29, 2015 14:23
Prevent WP update checking
// Tell WP everything is up to date
add_filter( 'pre_site_transient_update_core', 'le_prevent_update_checks' );
add_filter( 'pre_site_transient_update_plugins', 'le_prevent_update_checks' );
add_filter( 'pre_site_transient_update_themes', 'le_prevent_update_checks' );
function le_prevent_update_checks() {
global $wp_version;
return (object) array(
'last_checked' => time(),
@Frique
Frique / gist:b94f285ea6014398bbf6
Created February 11, 2015 07:41
Aspect ratio mixin
/* Source: http://css-tricks.com/snippets/sass/maintain-aspect-ratio-mixin/ */
@mixin aspect-ratio($width, $height) {
position: relative;
&:before {
display: block;
content: "";
width: 100%;
padding-top: ($height / $width) * 100%;
}
@Frique
Frique / gist:6212779
Created August 12, 2013 16:53
IE specific HTML classes
<!--[if lte IE 6]><html class="ie ie6 lte9 lte8 lte7"><![endif]-->
<!--[if IE 7]><html class="ie ie7 lte9 lte8 lte7"><![endif]-->
<!--[if IE 8]><html class="ie ie8 lte9 lte8"><![endif]-->
<!--[if IE 9]><html class="ie ie9 lte9"><![endif]-->
<!--[if gt IE 9]><html><![endif]-->
<!--[if !IE]><!--><html><!--<![endif]-->
@Frique
Frique / keep-focus.js
Last active December 19, 2015 15:38 — forked from drublic/keep-focus.js
var tabbableElements = 'a[href], area[href], input:not([disabled]),' +
'select:not([disabled]), textarea:not([disabled]),' +
'button:not([disabled]), iframe, object, embed, *[tabindex],' +
'*[contenteditable]';
function keepFocus($context){
var $allTabbableElements = $context.find(tabbableElements);
var $firstTabbableElement = $allTabbableElements.first();
var $lastTabbableElement = $allTabbableElements.last();
$context.on('keydown', function(event){