/(\d{1,2}\% \d{1,2}\%)/g
This file contains hidden or 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
const not = { | |
inert: ':not([inert]):not([inert] *)', | |
negTabIndex: ':not([tabindex^="-"])', | |
disabled: ':not(:disabled)', | |
} | |
export const FOCUSABLE_SELECTORS = [ | |
`a[href]${not.inert}${not.negTabIndex}`, | |
`area[href]${not.inert}${not.negTabIndex}`, | |
`input:not([type="hidden"]):not([type="radio"])${not.inert}${not.negTabIndex}${not.disabled}`, |
This file contains hidden or 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
// console.log(getTextLines(querySelector('span'))) | |
// returns number of lines | |
function collapseWhiteSpace(value) { | |
return value.trim().replace(/\s+/g, ' ') | |
} | |
function getTextLines(textNode) { | |
if (textNode.nodeType !== 3) { | |
return false // Only text nodes allowed |
This file contains hidden or 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
const ThemeNamespace = 'my-theme' | |
wp.hooks.addFilter('blocks.registerBlockType', ThemeNamespace, function (settings) { | |
if (settings.name === 'core/paragraph') { | |
settings.attributes = Object.assign(settings.attributes, { | |
expirationDate: { | |
type: 'string', | |
default: null, | |
}, | |
}) |
This file contains hidden or 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
const warnAbout = [ | |
{ | |
id: 'single_quote_notice', | |
needle: '"', | |
haystack: 'text', | |
message: "Content includes simple quotation marks: '. Did you mean ’ ?", | |
dispatched: false, | |
}, | |
{ | |
id: 'double_quote_notice', |
This file contains hidden or 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 | |
/** | |
* Limit image srcset width | |
* @link https://developer.wordpress.org/reference/hooks/max_srcset_image_width/ | |
*/ | |
function limit_image_srcset_width( $max_width = 2048, $size_array = [] ) { | |
$saveData = (isset($_SERVER["HTTP_SAVE_DATA"]) && stristr($_SERVER["HTTP_SAVE_DATA"], "on") !== false) ? true : false; | |
return $saveData ? 652 : $max_width; | |
} |
This file contains hidden or 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
import React from 'react' | |
import { Animated } from 'react-native' | |
import Canvas, { Image as CanvasImage } from 'react-native-canvas' | |
const TransparentImage = ({ source, width, height, backgroundColor }) => { | |
const fadeAnim = React.useRef(new Animated.Value(0)).current | |
return ( | |
<Animated.View | |
style={{ |
This file contains hidden or 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
const API_KEY = 'XXXXXXXXXXXXXXXXX' | |
export const fetchStock = async (productId = '') => { | |
try { | |
const response = await fetch(`https://app.snipcart.com/api/products/${productId}`, { | |
headers: { | |
'Authorization': 'Basic ' + Buffer.from(API_KEY + ':').toString('base64'), | |
'Accept': 'application/json', | |
}, | |
}).then(res => res.json()) |
This file contains hidden or 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 default output of og:image from yoast | |
*/ | |
add_filter('wpseo_frontend_presenter_classes', function ($filter) { | |
$presenter_to_remove = [ | |
'Yoast\WP\SEO\Presenters\Open_Graph\Image_Presenter' | |
]; |
This file contains hidden or 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 | |
if ( ! function_exists( 'get_attachment_id_from_url' ) ) { | |
/** | |
* Get the attachment ID for a given file url | |
* | |
* @link http://wordpress.stackexchange.com/a/7094 | |
* @param string $url | |
* @return boolean|integer | |
*/ |
NewerOlder