Skip to content

Instantly share code, notes, and snippets.

## START EXPIRES CACHING ##
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
<?php # https://keithgreer.uk/wordpress-code-completely-disable-comments-using-functions-php
/* PURPOSE
* Disable comments on ALL post types
* remove/hide any existing comments
* from displaying and hide forms.
*/
/* INSTALL
* Add into your active theme's functions.php file.
{%- unless template == 'index' or template == 'cart' or template == 'list-collections' or template == '404' -%}
{%- assign t = template | split: '.' | first -%}
<nav class="breadcrumbs" role="navigation" aria-label="breadcrumbs">
<ol class="breadcrumbs__list">
<li class="breadcrumbs__item">
<a class="breadcrumbs__link" href="/">Home</a>
</li>
{%- case t -%}
{%- when 'page' -%}
@keithgreer
keithgreer / numeric-country-code.php
Last active December 23, 2021 09:59
This code maps ISO 3166-1 alpha-2 country codes to their ISO 3166-1 numeric three-digit equivalents https://keithgreer.dev/global-payments-sca-3d-secure-2
/*
* Usage: $countries['GB'] will return "826", the UK's ISO 3166-1 numeric three-digit code.
*/
$countries = [
'AF' => '004',
'AX' => '248',
'AL' => '008',
'DZ' => '012',
'AS' => '016',
@keithgreer
keithgreer / telephone-country-codes.php
Last active December 23, 2021 09:59
Mapping international dialing codes to ISO 3166-1 alpha-2 country codes - https://keithgreer.dev/global-payments-sca-3d-secure-2
/*
* Usage: $calling_codes['GB'] will return "44", the UK's dialing code.
*/
$calling_codes = [
'BD' => '880',
'BE' => '32',
'BF' => '226',
'BG' => '359',
'BA' => '387',
<?php
// Initilise cURL
$ch = curl_init();
// Set the cURL Options
$optArray = array(
CURLOPT_URL => 'https://example.com/api/getInfo/',
CURLOPT_RETURNTRANSFER => true
);
@keithgreer
keithgreer / functions.php
Last active December 23, 2021 10:24
WordPress: Rename "Posts" to something else in Admin - https://keithgreer.dev/rename-wordpress-posts-admin
<?php
// Rename posts in the admin menu
function update_post_label() {
global $menu;
global $submenu;
$submenu['edit.php'][5][0] = 'Story';
$submenu['edit.php'][10][0] = 'Add Story';
$submenu['edit.php'][16][0] = 'Story Tags';
$menu[5][0] = 'Stories';
.eucookie-pop-up { display:none; position:fixed; z-index:9999; bottom:0; left:0; right:0; background:#dc143c; color:#fff; margin:1em; padding:0.5em; text-align:center; }
.eucookie-pop-up .dismiss { float:right; width:7% text-align:center; padding-top:1em; }
.eucookie-pop-up .dismiss a { color:#fff; cursor:pointer; font-weight:bold; font-size:150%; padding:1em; }
.eucookie-pop-up .content { float:left; width:92%; text-align:center; }
.eucookie-pop-up .content a { text-decoration: underline;color:#fff }
@keithgreer
keithgreer / deploy.php
Last active December 23, 2021 10:24 — forked from nichtich/README.md
How to automatically deploy from GitHub - https://keithgreer.dev/git-automatically-deploy-website-github
<?php
// Forked from https://gist.github.com/1809044
// Available from https://keithgreer.uk/git-automatically-deploy-website-github
// Check if client is allowed
$allowed_ips = array(
'207.97.227.', '50.57.128.', '108.171.174.', '50.57.231.', '204.232.175.', '192.30.252.', // GitHub
'123.123.123.123' // Your own IP address
);