Skip to content

Instantly share code, notes, and snippets.

@henshaw
henshaw / functions.php
Last active Oct 19, 2021
The WordPress HTTP header must have cache-control set to must-revalidate for Signed Exchanges (SXG) to work with Cloudflare on Google Search. This code must be added to the theme's functions.php file. Additionally, the Browser Cache TTL on Cloudflare must be set to Respect Existing Headers.
View functions.php
/**
* Add cache-control headers to response
*/
function add_cache_control_headers() {
if (!is_admin()) {
header("Cache-Control: public, must-revalidate, max-age=3600");
}
}
add_action( 'template_redirect', 'add_cache_control_headers' );
@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');
@henshaw
henshaw / qrcode-link.php
Created Aug 23, 2021
QR code for WordPress template
View qrcode-link.php
@henshaw
henshaw / qrcode-link.html
Created Aug 23, 2021
QR code HTML output
View qrcode-link.html
View qrcode.css
.qrcode { display:none; }
/* Printer Friendly */
@media print {
.qrcode { display:block;text-align:center; }
}
@henshaw
henshaw / cloudflare-firewall-rule.txt
Created Aug 23, 2021
Cloudflare Firewall rule expression for blocking hotlinking for a specific folder
View cloudflare-firewall-rule.txt
(http.request.full_uri contains "/path/to/qrcode/" and not http.referer contains "yourdomain.com")
@henshaw
henshaw / qr-code-generator.txt
Created Aug 24, 2021
Example QR code generator link
View qr-code-generator.txt
/wp-content/themes/coywolf/qrcode/php/qr_img.php?d=QR%20codes%20are%20fun"
@henshaw
henshaw / qr-code-script-path.txt
Created Aug 24, 2021
QR code generator script path
View qr-code-script-path.txt
/wp-content/themes/coywolf/qrcode/php/qr_img.php
@henshaw
henshaw / trademark-exceptions.php
Created Aug 14, 2021
WordPress Plugin Directory Trademark Abuse
View trademark-exceptions.php
// Domains from which exceptions would be accepted.
$trademark_exceptions = array(
'yoast.com' => array( 'yoast' ),
'automattic.com' => array( 'akismet', 'akismet-', 'jetpack', 'jetpack-', 'wordpress', 'wp-', 'woo', 'woo-', 'woocommerce', 'woocommerce-' ),
'facebook.com' => array( 'facebook', 'instagram', 'oculus', 'whatsapp' ),
'support.microsoft.com' => array( 'bing-', 'microsoft-' ),
'trustpilot.com' => array( 'trustpilot' ),
'microsoft.com' => array( 'bing-', 'microsoft-' ),
);
@henshaw
henshaw / multiple-authors.json
Created Aug 9, 2021
Author structured data for multiple authors for a single article using an array
View multiple-authors.json
"author": [
{
"@type": "Person",
"name": "Jon Henshaw",
"url":"https://www.coywolf.news/jon-henshaw/"
},
{
"@type": "Person",
"name": "Tamara Scott",
"url":"https://www.coywolf.news/tamara-scott/"