Skip to content

Instantly share code, notes, and snippets.

@henshaw
henshaw / external-link-style-image.css
Last active Aug 7, 2021
External link style that displays image/icon after the text
View external-link-style-image.css
@henshaw
henshaw / gist:5cf736e248e0f0edd6a1e195b9bd6852
Created Jul 21, 2021
WordPress WebP quality setting - Save in functions.php
View gist:5cf736e248e0f0edd6a1e195b9bd6852
// Use a quality setting of 75 for WebP images.
function filter_webp_quality( $quality, $mime_type ) {
if ( 'image/webp' === $mime_type ) {
return 75;
}
return $quality;
}
add_filter( 'wp_editor_set_quality', 'filter_webp_quality', 10, 2 );
@henshaw
henshaw / gravatar-alt-author-wordpress.php
Created Jul 18, 2021
Add ALT attribute with author name to Gravatar image in WordPress – Copy to functions.php
View gravatar-alt-author-wordpress.php
// Adds ALT attribute with author name to Gravatar image in WordPress
function replace_content($text)
{
$alt = get_the_author_meta( 'display_name' );
$text = str_replace('alt=\'\'', 'alt=\''.$alt.'\'',$text);
return $text;
}
add_filter('get_avatar','replace_content');
View breadcrumb list-emoji.json
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [{
"@type": "ListItem",
"position": 1,
"item": {
"@id": "https://coywolf.pro",
"name": "Coywolf"
@henshaw
henshaw / block-floc-wordpress.php
Last active Sep 29, 2021
Block FLoC in WordPress
View block-floc-wordpress.php
// Disable FLoC
function disable_floc($headers) {
$headers['Permissions-Policy'] = 'interest-cohort=()';
return $headers;
}
add_filter('wp_headers', 'disable_floc');
View accessible-number-input.html
<input type="text" pattern="[0-9]*" inputmode="numeric">
View breadcrumblist-schema-example.html
"breadcrumb": {
"@type": "BreadcrumbList",
"itemListElement":
[
{
"@type": "ListItem",
"position": 1,
"item":
{
"@id": "https://www.coywolf.news",
View functions-remove-yoast-json.php
function remove_yoast_json($data){
$data = array();
return $data;
}
add_filter('wpseo_json_ld_output', 'remove_yoast_json', 10, 1);
View link-colors.css
View intro-colors-elements.css
.intro { background:#eee; }
.intro h1 { color:#000; }
.intro p { color:#333; }