Skip to content

Instantly share code, notes, and snippets.

View patrickfreitasdev's full-sized avatar

Patrick de Freitas patrickfreitasdev

View GitHub Profile
<?php
/**
* Plugin Name: OOM Elementor Query Trace
* Description: On a memory fatal, log the SELECT wpdb was fetching and who ran it.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
@patrickfreitasdev
patrickfreitasdev / defender-session-activity-fallback.php
Created October 30, 2026 00:49
Defender Session Activity Fallback
<?php
/**
* Plugin Name: Defender Session Activity Fallback
* Description: Keeps Defender's idle-activity timestamp in user meta when APCu drops the transient. Temporary bypass; does not modify Defender.
* Version: 1.0.0
*
* Install: copy this file to wp-content/mu-plugins/wpdef-session-activity-fallback.php
* It loads automatically. Set WPDEF_SESSION_ACTIVITY_FALLBACK to false to disable it.
*
* Remove this file once Defender stores last activity somewhere that survives an object-cache flush.
@patrickfreitasdev
patrickfreitasdev / cookie-logger.php
Created September 19, 2026 08:00
MU Cookie Debugger
<?php
/**
* Plugin Name: Hustle GDPR Cleanup Fix (staging)
* Description: Replaces hustle_general_data_protection_cleanup with a Forever-aware, batched callback. Does not edit plugin files.
* Version: 1.0.0
*
* Install: copy this file to wp-content/mu-plugins/hustle-gdpr-cleanup-fix.php
*
* What it changes:
* - Skips work when retention is Forever (string/int safe).
@patrickfreitasdev
patrickfreitasdev / hustle-gdpr-cleanup-logger.php
Created September 19, 2026 04:49
hustle-gdpr-cleanup-logger
<?php
/**
* Plugin Name: Hustle GDPR Cleanup Logger
* Description: Staging diagnostics for hustle_general_data_protection_cleanup. Logs settings, row counts, timings, and query progress.
* Version: 1.0.0
*
* Install: copy this file to wp-content/mu-plugins/hustle-gdpr-cleanup-logger.php
*
* Log file: wp-content/hustle-gdpr-cleanup-debug.log
*
@patrickfreitasdev
patrickfreitasdev / defender-cron-cli-debug.php
Last active October 23, 2026 00:34
[Defender Pro] Cron and CLI debug
<?php
/**
* Plugin Name: [Defender Pro] Cron / WP-CLI / deactivation debug (Rev.2)
* Description: Logs each PHP runtime that runs cron / WP-CLI and every Defender deactivation with its caller. Must be in wp-content/mu-plugins/.
* Version: 2.0.0
* Author: WPMU DEV Support
* License: GPLv2 or later
* Requires PHP: 7.2
*
* Adapted from https://gist.github.com/wpmudev-sls/3600f4c2f5e1c93d4b4afa81b0423f4c
<?php
// Update new posts to have the correct publication URL
add_filter('wp_insert_post_data', 'update_post_file_to_append_proxy', 10, 1);
function update_post_file_to_append_proxy(array $data): array
{
// We don't need to take actions for publications, any other post type we will proceeed.
if($data['post_type'] == 'publications'){
<?php
add_action('admin_init', 'fix_duplicated_post_meta');
function fix_duplicated_post_meta()
{
if (!isset($_GET['fix-divi-duplicated-post-meta'])) return;
$post_meta = '_et_pb_use_builder';
<?php
/**
* Plugin Name: Forminator
* Description: Decrease user balance on form submission.
* Author: Patrick Freitas @ WPMUDEV
* Author URI: https://premium.wpmudev.org
* License: GPLv2 or later
*/
<?php
// Under development
if (!defined('ABSPATH')) {
exit;
}
class WDEV_Smush_GrapghQL_Support
{