Skip to content

Instantly share code, notes, and snippets.

View robwent's full-sized avatar
💭
Doing 'stuff'

Robert Went robwent

💭
Doing 'stuff'
View GitHub Profile
@robwent
robwent / blacklist-ips.conf
Created March 24, 2024 20:06
Integrating AbuseIPDB with Nginx bad bot blocker https://github.com/robwent/abuseipdb-bad-bot-blocker. Whitelisting Search Engines again.
include /etc/nginx/bots.d/abuseipdb;
# BingBot
13.66.139.0/24 0;
13.66.144.0/24 0;
13.67.10.16/28 0;
13.69.66.240/28 0;
13.71.172.224/28 0;
139.217.52.0/28 0;
@robwent
robwent / update-abuseipdb.sh
Created March 24, 2024 19:51
Integrating AbuseIPDB with Nginx bad bot blocker https://github.com/robwent/abuseipdb-bad-bot-blocker
#!/bin/bash
# Save this file as /usr/local/sbin/update-abuseipdb.sh
# Edit api key and confidence level
# Make it Executable chmod 700 /usr/local/sbin/update-abuseipdb.sh
# Daily Cron as root (every 4 hours)
# 0 */4 * * * /usr/local/sbin/update-abuseipdb.sh > /dev/null 2>&1
# Include the output in /etc/nginx/bots.d/blacklist-ips.conf
# include /etc/nginx/bots.d/abuseipdb;
@robwent
robwent / sitemap-test.php
Created February 18, 2024 17:39
Example of Yoast update changing custom query vars
<?php
/*
* Plugin Name: Sitemap Test
* Description: A simple plugin to test Yoast sitemap integration.
*/
function add_to_yoast_sitemap( $custom_sitemaps ) {
$custom_sitemaps .= '<sitemap><loc>' . site_url() . '/my-custom-sitemap.xml</loc></sitemap>';
return $custom_sitemaps;
@robwent
robwent / some-block.php
Created September 2, 2023 14:48
Get child pages in ACF block
<?php
$args = array(
'post_type' => 'any',
'post_status' => 'publish',
'posts_per_page' => - 1,
'post_parent' => $post_id, // Available in ACF blocks by default
'order' => 'ASC',
'orderby' => 'menu_order',
'suppress_filters' => false,
@robwent
robwent / wp-config.php
Created July 22, 2023 14:13
Disable WordFence Live Traffic
<?php
######### Disable WordFence Live Traffic ########
define( 'WORDFENCE_DISABLE_LIVE_TRAFFIC', true );
#################################################
@robwent
robwent / forcing-w3-total-cache-to-clear-parent-category-listing-pages-on-post-save.php
Last active May 13, 2024 13:26
Forcing W3 Total Cache to Clear Parent Category Listing Pages on Post Save
<?php
/**
* Clear Total Cache term listing pages for a post
* @param $post_id
* @param $post
*
* @return void
*/
function rw_clear_total_cache_terms_pages( $post_id, $post ) {
if ( function_exists( 'w3tc_flush_url' ) ) {
@robwent
robwent / wp-change-posts-to-projects.php
Created November 29, 2021 17:55
Changes WordPress Post labels to Projects
<?php
/**
* Change the label of posts
*/
function prefix_change_post_object() {
$get_post_type = get_post_type_object('post');
$labels = $get_post_type->labels;
$labels->name = 'Projects';
$labels->singular_name = 'Projects';
$labels->add_new = 'Add Projects';
<?php
/**
* Change min password strength.
*
* @author James Kemp (Iconic)
* @link http://iconicwp.com/decrease-strength-required-woocommerce-passwords/
* @param int $strength
* @return int
*/
function myclass_min_password_strength( $strength ) {
<wpml-config>
<admin-texts>
<key name="wp_2fa_email_settings">
<key name="enforced_email_subject"/>
<key name="enforced_email_body"/>
<key name="login_code_email_subject"/>
<key name="login_code_email_body"/>
<key name="user_account_locked_email_subject"/>
<key name="user_account_locked_email_body"/>
<key name="user_account_unlocked_email_subject"/>
@robwent
robwent / yoast-schema.php
Created April 24, 2019 21:28
Extends Yoast schema to add event data
<?php
include ("classes/Schema_Event.php");
add_filter( 'wpseo_schema_graph_pieces', 'PREFIX_add_graph_pieces', 11, 2 );
/**
* Adds Schema pieces to our output.
*
* @param array $pieces Graph pieces to output.