Skip to content

Instantly share code, notes, and snippets.

View dark7.js
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)') {
var windowPrefersDark = window.matchMedia('(prefers-color-scheme: dark)');
var systemColorMode = windowPrefersDark.matches ? 'dark' : 'light';
// need to check in case doesn't exist like with Safari 13.x
if (
'addEventListener' in windowPrefersDark &&
typeof windowPrefersDark.addEventListener === 'function'
) {
windowPrefersDark.addEventListener('change', (event) => {
View dark6.css
:root.dark {
color-scheme: light dark;
}
View dark4.js
const dark = window.matchMedia &&
window.matchMedia('(prefers-color-scheme: dark)') &&
window.matchMedia('(prefers-color-scheme: dark)').matches;
View dark5.js
if (color_mode == 'dark') {
document.body.classList.add('dark');
document.documentElement.classList.add('dark');
} else {
document.body.classList.remove('dark');
document.documentElement.classList.remove('dark');
}
View dark2.html
<body class="dark">
my app
</body>
View dark.css
@media (prefers-color-scheme: dark) {
background: black;
}
@bryceadams
bryceadams / gist:925a183619376feb5dcf5de9a84bcdd8
Created Jul 21, 2018
Metorik - Move add cart popup placement.
View gist:925a183619376feb5dcf5de9a84bcdd8
add_filter('metorik_acp_placement', function() {
return 'left';
});
@bryceadams
bryceadams / gist:4bcfce7f1ff341f9b1ad8cc98b3417bb
Last active Jul 20, 2018
Metorik - Stop cart checkout button 'popup' appearing.
View gist:4bcfce7f1ff341f9b1ad8cc98b3417bb
add_filter('metorik_acp_checkout_button', '__return_false');
@bryceadams
bryceadams / add-cart-email-form.php
Created Jul 5, 2018
Metorik Helper 1.0.0 - Add Cart Email Form template file
View add-cart-email-form.php
<?php
/**
* Metorik: Add cart email form template.
*
* This template can be overriden by copying this file to your-theme/metorik/add-cart-email-form.php
*
* Variables available:
* 1. $title - Title (set in Metorik).
* 2. $email_usage_notice - Email usage notice (if enabled in Metorik and customer didn't opt-out).
*
View wc-custom-meta-get.php
<?php
$order_id = 125;
echo get_post_meta( $order_id, 'payment_gateway_fee', true ); // 1.60