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 / register-theme-directory.inc.php
Last active October 3, 2021 12:24
Registers a custom theme directory as an alternative to the default WP theme directory.
<?php
/**
* Plugin Name: EggMUP: Register Custom Theme Directory
* Plugin URI: https://gist.github.com/ianpegg/fedff025099e5db13e618c5bc6c0c597
* Description: Register an alternative theme directory.
* Version: 1.0.0
* Author: Ian Pegg
* Author URI: https://eggcupwebdesign.com
* php version 7.4.15
*
@ianpegg
ianpegg / disable-wp-cron.inc.php
Last active December 1, 2021 12:31
DISABLE_WP_CRON on its own does not prevent the wp-cron script from being executed via HTTP, meaning it is still vulnerable to exploitation by DDOS attacks. This script terminates any attempt to run wp-cron by any means other than the command line.
<?php
/**
* Plugin Name: EggMUP: Disable WP Cron
* Plugin URI: https://gist.github.com/ianpegg/36568e85cf692d3a901b475e4a14204e
* Description: Prevents wp-cron from being run via HTTP.
* DISABLE_WP_CRON on its own does not prevent the wp-cron script from being
* executed via HTTP, meaning it is still vulnerable to exploitation by DDOS attacks.
*
* Version: 1.0.0
* Author: Ian Pegg
@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 / 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
@ianpegg
ianpegg / .htaccess
Created April 15, 2022 11:30
Prevent search engines from indexing documents by file extension - useful for keeping promos secret
# ----------------------------------------------------------------------
# Prevent search engines from indexing documents by file extension - useful for keeping promos secret
# ----------------------------------------------------------------------
<IfModule mod_headers.c>
<FilesMatch "(\.(pdf|doc|docx|odt)|~)$">
Header set X-Robots-Tag "noindex, noarchive, nosnippet"
</FilesMatch>
</IfModule>
@ianpegg
ianpegg / .gitconfig
Created May 13, 2022 13:49
Basic gitconfig for local user profile.
[push]
default = simple
[user]
name = Your Name
email = you@example.com
[init]
defaultBranch = main
@ianpegg
ianpegg / .gitignore
Created May 13, 2022 13:51
.gitignore for WordPress & cPanel environment.
# -----------------------------------------------------------------
# .gitignore for WordPress
#
# This file is tailored for a WordPress project
# using the default directory structure
#
# This file specifies intentionally untracked files to ignore
# http://git-scm.com/docs/gitignore
#
# NOTES:
@ianpegg
ianpegg / user-customizations.sh
Created May 13, 2022 13:54
Basic user customisation script for the Homestead virtual machine.
#!/bin/sh
# Set the default command line text editor:
sudo update-alternatives --set editor /usr/bin/vim.basic
# Set the default GIT push method:
git config --global push.default simple
# Set GIT user name and email in the global scope:
git config --global user.name "Your Name"