Skip to content

Instantly share code, notes, and snippets.

@henshaw
henshaw / functions.php
Created October 10, 2024 02:27
This code, which goes in functions.php, forces WordPress to put jQuery links within the header.
function insert_jquery(){
wp_enqueue_script('jquery', false, array(), false, false);
}
add_filter('wp_enqueue_scripts','insert_jquery',1);
@henshaw
henshaw / manifest.json
Created October 6, 2024 17:18
Masked icons for PWA
{
"purpose": "maskable",
"sizes": "1024x1024",
"src": "/images/icons/maskable/maskable_icon.png",
"type": "image/png"
},
{
"purpose": "maskable",
"sizes": "512x512",
"src": "/images/icons/maskable/maskable_icon_x512.png",
@henshaw
henshaw / manifest.json
Created October 6, 2024 17:10
macOS icons for PWA manifest file
{
"purpose": "any",
"sizes": "1024x1024",
"src": "/images/icon_512x512@2x.png",
"type": "image/png"
},
{
"purpose": "any",
"sizes": "512x512",
"src": "/images/icon_512x512.png",
@henshaw
henshaw / apple-touch-icon.html
Created October 6, 2024 16:51
PWA icons for iOS and iPadOS
<link rel="apple-touch-icon" sizes="40x40" href="/images/icons/ios/Icon-Light-40x40.png">
<link rel="apple-touch-icon" sizes="58x58" href="/images/icons/ios/Icon-Light-58x58.png">
<link rel="apple-touch-icon" sizes="60x60" href="/images/icons/ios/Icon-Light-60x60.png">
<link rel="apple-touch-icon" sizes="76x76" href="/images/icons/ios/Icon-Light-76x76.png">
<link rel="apple-touch-icon" sizes="80x80" href="/images/icons/ios/Icon-Light-80x80.png">
<link rel="apple-touch-icon" sizes="87x87" href="/images/icons/ios/Icon-Light-87x87.png">
<link rel="apple-touch-icon" sizes="114x114" href="/images/icons/ios/Icon-Light-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/images/icons/ios/Icon-Light-120x120.png">
<link rel="apple-touch-icon" sizes="128x128" href="/images/icons/ios/Icon-Light-128x128.png">
<link rel="apple-touch-icon" sizes="136x136" href="/images/icons/ios/Icon-Light-136x136.png">
@henshaw
henshaw / google-web-cache.js
Created January 29, 2024 04:09
Bookmarklet URL for viewing a web page in Google's Web Cache
javascript: window.location = 'https://webcache.googleusercontent.com/search?q=cache:' + window.location.protocol + '//' + window.location.hostname + window.location.pathname;
@henshaw
henshaw / hide-label.css
Last active January 25, 2024 23:32
CSS for hiding the WordPress Search Form Label while maintaining accessiblity (not using display:none;)
.screen-reader-text:not(:focus):not(:active) {
position: absolute;
overflow: hidden;
clip: rect(0 0 0 0);
clip-path: inset(50%);
width: 1px;
height: 1px;
white-space:nowrap;
}
@henshaw
henshaw / open-graph-image.php
Created January 3, 2024 00:02
Open Graph Thumbnail Images for WordPress
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 150, 79, true );
add_image_size( 'single-post-thumbnail', 1200, 630 );
}
@henshaw
henshaw / remove-yoast-schema.php
Created January 3, 2024 00:01
Remove Yoast Schema output from WordPress
function remove_yoast_json($data){
$data = array();
return $data;
}
add_filter('wpseo_json_ld_output', 'remove_yoast_json', 10, 1);
@henshaw
henshaw / author-bio.php
Created January 3, 2024 00:00
Add a short author bio at the end of the articles
<?php echo get_the_author_meta('description'); ?>
@henshaw
henshaw / article-timestamp.php
Created January 2, 2024 23:59
Dynamically inserting the article timestamp in WordPress
<time datetime="<?php the_time('c'); ?>"><?php the_time('m/j/Y'); ?> <?php the_time('g:ia T'); ?></time>