Skip to content

Instantly share code, notes, and snippets.

@ara303
ara303 / remove-wp-site-health-default-theme-check.php
Last active April 27, 2021 21:09
Remove the "you need a default theme" WP Site Health check, because it's unnecessary and annoying if you run one default theme that you *do* actively maintain
function YOURPREFIX_remove_default_theme_site_health( $tests ) {
unset( $tests['direct']['theme_version'] );
return $tests;
}
add_filter( 'site_status_tests', 'YOURPREFIX_remove_default_theme_site_health' );
@ara303
ara303 / tumblr-grid-theme-masonry.txt
Created December 3, 2018 18:18
tumblr-grid-theme-masnry.txt
<html lang="en">
<head>
<title>{block:TagPage}#{Tag} | {/block:TagPage}{Title}</title>
<meta type="description" content="{MetaDescription}">
<link rel="shortcut icon" href="{Favicon}">
<link rel="alternate" href="{RSS}">
<meta charset="utf-8">
<style>
body {
margin: 0;
@ara303
ara303 / tumblr-lightbox-for-photos-2018.html
Last active November 30, 2018 15:03
Use Tumblr's built-in lightbox for displaying high-resolution images in a lightbox, basically "free" by leveraging code already in Tumblr. Updated for 2018: no longer requires jQuery, gets `low_res` attribute from image `src`, use more modern JS standards than when this was originally written in 2014!
<script>
let clbPhotos = document.querySelectorAll('.page-index .photo-image[data-highres]'); // Replace this with the selector for whatever you want to be the trigger.
Array.prototype.forEach.call(clbPhotos, function(clbElement, i){
clbElement.addEventListener('click', function(){
let clbAttrs = clbElement.dataset;
let clbData = [{
"width": clbAttrs.highresWidth,
"height": clbAttrs.highresHeight,
"low_res": clbElement.src, // My trigger is the image element so I can take the existing src that is currently being displayed. This is quite good for performance because I know that version is already loaded in. If you make the trigger anything else, you'll need to find another way to provide the low resolution version, it's not optional.
"high_res": clbAttrs.highres
@ara303
ara303 / woocommerce_change_no_shipping_error.php
Created May 17, 2018 15:46
Change the "No shipping available" error message in WooCommerce
function wbsuk_change_no_shipping_error() {
return '<div class="no-shipping-text">Your order cannot be completed automatically. Please <a href="contact">contact us</a> and we will confirm a price to ship to you.</div>';
}
add_filter( 'woocommerce_cart_no_shipping_available_html', 'wbsuk_change_no_shipping_error' );
add_filter( 'woocommerce_no_shipping_available_html', 'wbsuk_change_no_shipping_error' );
@ara303
ara303 / tumblr-theme-required.html
Created November 26, 2015 15:38
Tumblr theme required HTML in order to be considered valid for submission. If you're failing the validation, check to make sure all these custom tags are in your theme file.
<html> <!-- There's no need to set a doctype, Tumblr automatically injects one. -->
<head>
<meta charset="utf-8">
<meta name="description" content="{MetaDescription}">
<link rel="alternate" href="{RSS}">
<link rel="icon" href="{Favicon}">
<style>
{CustomCSS}
</style>
</head>
/**
* Media query mixin so we don't need to duplicate breakpoints throughout stylesheets.
*
* It's better to use em for breakpoints instead of px where possible.
* http://bradfrost.com/blog/post/7-habits-of-highly-effective-media-queries/#relative
*
* .example {
* @include media-query(phone OR tablet OR desktop) {
* color: blue;
* }
@ara303
ara303 / detect-safari.js
Last active October 26, 2015 18:50
Detect Safari and add a class to the <html> element
if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) {
document.documentElement.classList.add('is-safari');
}
/**
* Credits:
* http://stackoverflow.com/questions/5899783/detect-safari-using-jquery
* https://developer.mozilla.org/en/docs/Web/API/Element/classList
*/
@ara303
ara303 / gist:9727836
Created March 23, 2014 18:55
Tumblr source & reblog attribution block
{block:ContentSource}(Source: <a href="{SourceURL}">{SourceTitle}</a>{block:RebloggedFrom}, via <a href="{ReblogParentURL}">{ReblogParentName}</a>{/block:RebloggedFrom}){/block:ContentSource}
@ara303
ara303 / sh-photoset.html
Last active January 4, 2016 15:19
My config for StyleHatch's jQuery plugin for Tumblr Photosets
{block:Photoset}
<div class="media{block:Caption} has-caption{/block:Caption}">
<div class="photoset-grid" data-layout="{PhotosetLayout}" style="visibility: hidden;">
{block:Photos}
<img src="{PhotoURL-500}" {block:HighRes}data-highres="{PhotoURL-HighRes}"{/block:HighRes} data-width="{PhotoWidth-HighRes}" data-height="{PhotoHeight-HighRes}" {block:Caption}alt="{Caption}"{/block:caption} />
{/block:Photos}
</div>
</div>
{block:Caption}
<div class="inner">
@ara303
ara303 / tumblr-posts.html
Created December 25, 2013 00:07
Complete HTML and Tumblr shortcodes to render all the post types. I often have to create this, and it's the same every time. Doing this will save me SO MUCH time!
<article class="{PostType}{block:Photoset}set{/block:Photoset}">
{block:Text}
<div class="inner">
<h2{block:Title} class="has-body"{/block:Title}>{Title}</h2>
<div class="body">
{Body}
</div>
</div>
{/block:Text}