Skip to content

Instantly share code, notes, and snippets.

View gbot's full-sized avatar
🏠
Working from home

GB gbot

🏠
Working from home
View GitHub Profile
@gbot
gbot / jail.local
Last active February 18, 2025 20:00
Fail2Ban filter, jail and action (Slack message) for WordPress login failures on Spinup WP servers
[wordpress]
enabled = true
filter = wordpress
action = iptables-multiport[name="wordpress", port="http,https"]
slack-notify[name="wordpress"]
logpath = /sites/*/logs/access.log
/var/log/nginx/access.log
maxretry = 5
backend = polling
@gbot
gbot / wp_multisite_cron.sh
Last active September 1, 2021 00:02
Call wp-cron.php on WP Multisite installations
#!/bin/bash
# Call wp-cron.php on WP Multisite installations
# Requires WP-CLI
# Looks for WP_PATH in {user_home}/wp-cli.yml, otherwise must pass in as $1
# Set up cron job with crontab -e
# Use MAILTO to send output to email or write to a log file 'bash ~/wp_multisite_cron.sh >> crontab.log'
# [email protected]
# */1 * * * * bash ~/wp_multisite_cron.sh [WP_PATH]
@gbot
gbot / hash_password.php
Created October 16, 2018 22:16
Hash a string with PHP's password_hash() function.
<?php
// Hash a password
// by Gavin Botica
// requires PHP 5.5+
define("RQD_PHP_VER", "5.5");
// check php version
if (version_compare(PHP_VERSION, RQD_PHP_VER) == -1 ) {
echo "<p><b>ERROR:</b> PHP <i>" . RQD_PHP_VER . "</i> required. Version <i>" . PHP_VERSION . "</i> installed.</p>";
@gbot
gbot / wp_offload_media_db_migrate.json
Last active March 20, 2023 20:24
Migrate a WordPress database so that existing media items are served from Amazon S3 or CloudFront. Requires the WP Offload S3 Lite plugin.
{
"use_https": "",
"purge_amazonS3_info": ""
}
@gbot
gbot / woocommerce-login-logout-redirects.php
Last active November 16, 2021 10:11
WP: Redirect to home page for WooCommerce login and logout. #ST3
/*----------------------------------------------------------------------------*/
// redirects for login / logout
/*----------------------------------------------------------------------------*/
add_filter('woocommerce_login_redirect', 'login_redirect');
function login_redirect($redirect_to) {
return home_url();
}