Skip to content

Instantly share code, notes, and snippets.

View ianpegg's full-sized avatar

Ian Pegg ianpegg

View GitHub Profile
@ianpegg
ianpegg / modify-data-types.inc.php
Created January 11, 2024 13:22
Functions that allow the modification of built-in data types.
<?php
/**
* Plugin Name: EggMUP: Modify Built-in Data Types
* Plugin URI: https://gist.github.com/ianpegg/
* Description: Functions that allow the modification of built-in data types.
* Version: 1.0.0
* Author: Ian Pegg
* Author URI: https://eggcupwebdesign.com
* php version 7.4.15
@ianpegg
ianpegg / contact-form.html
Last active December 7, 2023 17:21
HTML & shortcodes for Contact Form 7 form, using WordPress FSE styles.
<div class="form-group">
<label for="your-name" class="control-label required">Name</label>
[text* your-name autocomplete:name minlength:5 maxlength:70 id:your-name class:form-control]
</div>
<div class="form-group">
<label for="your-email" class="control-label required">Email</label>
[email* your-email autocomplete:email minlength:6 maxlength:254 id:your-email class:form-control]
</div>
@ianpegg
ianpegg / custom-data-types.inc.php
Last active September 25, 2023 16:43
EggMUP that registers a demo Custom Post Type and Custom Taxonomy. Edit the arrays to create your own, then drop into your mu-plugins directory.
<?php
/**
* Plugin Name: EggMUP: Register Custom Data Types
* Plugin URI: https://gist.github.com/ianpegg/
* Description: Defines and registers custom post types and custom taxonomies.
* Version: 1.0.0
* Author: Ian Pegg
* Author URI: https://eggcupwebdesign.com
* php version 8.0.28
*
@ianpegg
ianpegg / composer.json
Created September 23, 2023 12:31
Custom WordPress Composer configuration boilerplate.
{
"name": "eggcup-web-design/wordpress-boilerplate",
"type": "project",
"license": "MIT",
"description": "Custom WordPress Composer configuration boilerplate.",
"homepage": "https://eggcupwebdesign.com",
"authors": [
{
"name": "Ian Pegg",
"homepage": "https://eggcupwebdesign.com"
@ianpegg
ianpegg / .htaccess
Created February 3, 2023 17:16
Maintenance mode .htaccess rules
### Maintenance mode force redirect rules
# Note: based on source code from elsewhere, but I've lost the source.
# Let me know if you recognise any of this and want attribution!
# We don't need to tell everyone we're apache:
ServerSignature Off
# Set server admin email
ServerSignature EMail
SetEnv SERVER_ADMIN you@example.com
@ianpegg
ianpegg / wp-config.php
Last active December 8, 2022 14:28
Use X-Forwarded-For HTTP Header to Get Visitor's Real IP Address.
/**
* Use X-Forwarded-For HTTP Header to Get Visitor's Real IP Address.
*
* @link https://wordpress.org/support/topic/where-to-add-the-x-forwarded-for-code-in-wp-config-php/
*/
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$Arr_http_x_headers = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
$_SERVER['REMOTE_ADDR'] = $Arr_http_x_headers[0];
}
@ianpegg
ianpegg / .htaccess
Created November 16, 2022 17:41
Security: Block XMLRPC as it is deprecated
# ----------------------------------------------------------------------
# Security: Block XMLRPC as it is deprecated
# ----------------------------------------------------------------------
<Files xmlrpc.php>
Order Allow,Deny
Deny from all
</Files>
@ianpegg
ianpegg / .htaccess
Created September 16, 2022 11:01
Essential WordPress Apache .htaccess security snippets
# ----------------------------------------------------------------------
# Security: Block access to backup and source files
# ----------------------------------------------------------------------
<FilesMatch "(\.(bak|config|sql|fla|psd|ini|log|sh|inc|swp|dist)|~)$">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>
@ianpegg
ianpegg / remove-blog.inc.php
Last active September 16, 2022 11:02
WordPress started as a blogging platform - but not every site needs a blog!
<?php
/**
* Plugin Name: EggMUP: Remove Blog from WordPress
* Plugin URI: https://gist.github.com/ianpegg/011dbee31391f0a049ba46bbbd623bb8
* Description: WordPress started as a blogging platform - but
* not every site needs a blog! Note: at the moment, this MUP just hides
* post editing and creation in the dashboard as core post types cannot be disabled!
* Version: 1.0
* Author: Ian Pegg
@ianpegg
ianpegg / .htaccess
Last active June 20, 2022 15:37
WP Uploads directory .htaccess configuration: prevent code execution and load files from LIVE when in DEV environments.
################## Uploads directory .htaccess configuration #################
## Prevent code execution and load files from LIVE when in DEV environments ##
# BEGIN Uploads directory code execution protection
<IfModule mod_php5.c>
php_flag engine 0
</IfModule>
<IfModule mod_php7.c>
php_flag engine 0