Skip to content

Instantly share code, notes, and snippets.

View ianpegg's full-sized avatar

Ian Pegg ianpegg

View GitHub Profile
# ----------------------------------------------------------------------
# Prevent search engines indexing production site whilst in testing
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# Remove before launch!
# ----------------------------------------------------------------------
<IfModule mod_headers.c>
Header set X-Robots-Tag "noindex, nofollow, noarchive"
<FilesMatch "\.(doc|pdf|png|jpe?g|gif)$">
Header set X-Robots-Tag "noindex, noarchive, nosnippet"
@ianpegg
ianpegg / .htaccess
Last active September 17, 2021 12:10
Fetch 'uploads' files from LIVE if not found on DEV
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteOptions Inherit
# If the requested URL doesn't match a directory or file...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
# Rewrite the request to be fetched from LIVE instead
RewriteRule wp-content/uploads/(.*)
## Be sure to replace 'example.com' with the domain name of LIVE ##
@ianpegg
ianpegg / disable-core-lazyloading.inc.php
Last active December 1, 2021 12:55
PHP MU plugin include that disables image and iframe lazy loading included in WordPress core since 5.4. There is no need to use this unless you know you need it!
<?php
/**
* Plugin Name: EggMUP: Disable Browser Lazyloading
* Plugin URI: https://gist.github.com/ianpegg/41fb0d5df8cb55f648b42e176b152012
* Description: Browser-based lazyloading is great, but not yet fully supported. If you are using a JS lazy loading solution, you don't need both. This must-use plugin disables browser lazy loading that was added in WP 5.4.
* Version: 1.0.0
* Author: Ian Pegg
* Author URI: https://eggcupwebdesign.com
* php version 7.4.15
*
@ianpegg
ianpegg / .htaccess
Last active September 22, 2022 11:36
Rewrite requests for non-HTTPs or naked domain variations to the https://www scheme with only one 301 redirect. The ruleset includes checks to ensure we are in a production environment and that Let's Encrypt requests can pass through unmodified.
# ----------------------------------------------------------------------
# If a URL is requested over an insecure connection or if the URL request
# contains the naked domain variation, redirect the request to the
# https://www scheme.
# N.B there's nothing wrong with using naked domains, this is a stystic choice
# Adapted from: https://wp-mix.com/htaccess-redirect-http-to-https/
# ----------------------------------------------------------------------
<IfModule mod_rewrite.c>
# Check whether the request was made over an insecure protocol
# N.B. CloudFlare & other reverse proxies don't always set https to on, so check HTTP:X-Forwarded-Proto too:
@ianpegg
ianpegg / deregister-jquery-migrate.inc.php
Last active June 14, 2022 14:15
Any plugin that declares 'jquery' as a dependency rather than 'jquery-core' will cause jQuery Migrate to be registered too. When we know that all theme & plugin JS is compatible with the latest release of jQuery then we can safely deregister jQuery Migrate.
<?php
/**
* Plugin Name: EggMUP: Deregister jQuery Migrate
* Plugin URI: https://gist.github.com/ianpegg/5aa9524ea2251ba8f3afc1ba56041616
* Description: Optimise WP for performance by removing jQuery Migrate if we don't need it.
* Version: 1.0.0
* Author: Ian Pegg
* Author URI: https://eggcupwebdesign.com
* php version 7.4.15
@ianpegg
ianpegg / security.inc.php
Last active September 16, 2022 11:05
Must-use plugin containing tools for improving site security. (WiP)
<?php
/**
* Plugin Name: EggMUP: Security
* Plugin URI: https://gist.github.com/ianpegg/e60d026fe2b8f4b7236855818dd36ab6
* Description: Must-use plugin tools for improving site security.
* Version: 1.0.0
* Author: Ian Pegg
* Author URI: https://eggcupwebdesign.com
* php version 7.4.15
*
@ianpegg
ianpegg / dashboard-setup.inc.php
Last active May 5, 2023 10:41
Modify the WP dashboard - remove dashboard widgets and other furniture we don't need.
<?php
/**
* Plugin Name: EggMUP: WP Admin Dashboard Setup
* Plugin URI: https://gist.github.com/ianpegg/0e3beb746757916d46f636f12b6d6a44
* Description: Modify the WP dashboard - remove dashboard widgets
* and other furniture we don't need.
* Version: 1.1.0
* Author: Ian Pegg
* Author URI: https://eggcupwebdesign.com
@ianpegg
ianpegg / performance.inc.php
Last active June 27, 2022 16:35
A lightweight way to improve performance by removing elements of WP core that we don't need.
<?php
/**
* Plugin Name: EggMUP: Performance
* Plugin URI: https://gist.github.com/ianpegg/53842447a5016ad5d3eac073dd2390d5
* Description: Optimise WP for performance by removing things we don't need.
* Version: 1.0.0
* Author: Ian Pegg
* Author URI: https://eggcupwebdesign.com
* php version 7.4.15
@ianpegg
ianpegg / utilities.inc.php
Last active January 10, 2024 18:30
Provides utilities for DEV and STAGING sites.
<?php
/**
* Plugin Name: EggMUP: Utilities
* Plugin URI: https://gist.github.com/ianpegg/b92324d6e1e1078bd47da0f27e300bf3
* Description: Provides utilities for DEV and STAGING sites.
* Version: 1.0.0
* Author: Ian Pegg
* Author URI: https://eggcupwebdesign.com
* Use this statement to include this library in other scripts
@ianpegg
ianpegg / email-validation.inc.php
Last active January 11, 2022 15:46
Tools to filter submitted form data.
<?php
/**
* Plugin Name: EggMUP: CF7 Email Validation
* Plugin URI: https://gist.github.com/ianpegg/f92a0e0b6b598c49ab56c5215028b150
* Description: Tools to improve CF7 spam and abuse filtering.
* Version: 1.1.0
* Author: Ian Pegg
* Author URI: https://eggcupwebdesign.com
* Submitted form data is sanitised and validated to some extent
* by the CF7 plugin. However, to combat spam, we