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 / 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 / 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 / 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;
#!/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 / 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 / yoast-remove-searchaction.php
Created November 26, 2024 20:30
Remove Yoast Sitelinks Search Box Schema Piece
<?php
/**
* Remove the SearchAction schema from the graph.
*/
add_filter( 'wpseo_schema_website', function( $website ) {
if ( isset( $website['potentialAction'] ) && is_array( $website['potentialAction'] ) ) {
foreach ( $website['potentialAction'] as $key => $action ) {
if ( isset( $action['@type'] ) && $action['@type'] === 'SearchAction' ) {
unset( $website['potentialAction'][$key] );
@robwent
robwent / elementor-form-submission-listener.html
Created January 18, 2025 16:36
Elementor Form Submission Listener
<script>
if (window.jQuery) {
jQuery(document).ready(function() {
jQuery(document).on('submit_success', '.elementor-form', function(event) {
// Push the event to the dataLayer for Google Tag Manager
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'elementor_form_submission',
formName: event.target.getAttribute('name') ||
(event.target.querySelector('[name="form_id"]') ? event.target.querySelector('[name="form_id"]').value : 'unknown') ||
@robwent
robwent / wp-rest-cache-cf7.php
Last active April 24, 2025 20:00
Caching Contact Form 7 Schema Requests
<?php
add_filter( 'wp_rest_cache/allowed_endpoints', function ( $allowed_endpoints ) {
if ( ! isset( $allowed_endpoints['contact-form-7/v1'] ) ) {
$allowed_endpoints['contact-form-7/v1'] = [];
}
if ( ! in_array( 'contact-forms', $allowed_endpoints['contact-form-7/v1'], true ) ) {
$allowed_endpoints['contact-form-7/v1'][] = 'contact-forms';
}