Skip to content

Instantly share code, notes, and snippets.

View apermo's full-sized avatar

Christoph Daum apermo

View GitHub Profile
@apermo
apermo / test-smtp.php
Created September 5, 2025 08:27
Simple Script to run and debug tests for smtp mail on WordPress
<?php
/**
* This is used to test and debug the Bedrock Environment Mailer
* https://github.com/hackur/bedrock-env-mailer
*
* Code is derived from it.
* License: MIT
*/
@apermo
apermo / english
Created July 10, 2025 11:08
Custom Word Sets for https://skribbl.io/ - Pop-culture, Nerd-culture, music, IT etc
Keyboard
Mouse
Screen
Laptop
Server
Cloud
Database
Programmer
Code
Bug
<?php
add_filter( 'heartbeat_settings', 'filter_heartbeat', 10, 1 );
/**
* Filter the heartbeat interval based on the current request.
*
* Called on the 'heartbeat_settings' filter.
*
* @param array $settings The Heartbeat settings. By Default an empty array.
*
<?php
/**
* A class to create custom tables within WordPress.
*
* @see https://gist.github.com/apermo/0fb0cbca1f57625ba6753ef3b7f73ffa
*
* @version 1.0.1
*/
namespace apermo\WPTools;
@apermo
apermo / anonymize_users.php
Created April 20, 2025 17:30
Anonymizing WordPress Database
<?php
/**
* Plugin Name: User Migration CLI Command (MU)
* Author: Christoph Daum
* Author URL: https://christoph-daum.com
* Description: Adds a WP-CLI command 'migrate' to anonymize user data, reset passwords, and update meta.
*
* Version: 1.0
* License: GPL2
*/
<?php
/**
* This is a snippet if your WordPress plugin uses composer autoloading.
*
* Instead of just dying, it will fail gracefully and add an admin notice to the backend,
* informing the dev to run the autoloader.
*
* Could also be adjusted to check for other things like a /build/ folder or similar things.
*
@apermo
apermo / selfdesctruct_info.php
Last active March 27, 2025 12:15
A small snippet around the phpinfo(); to have a self destructing phpinfo that deletes itself if older than one hour.
<?php
// File is older than 1 hour, better delete this.
if ( filemtime( __FILE__ ) + 3600 < time() ) {
unlink( __FILE__ );
header( "HTTP/1.0 404 Not Found" );
exit();
}
phpinfo();
@apermo
apermo / wp-gutenberg-reusable-block-interface.php
Last active November 4, 2024 07:29 — forked from mrpritchett/wp-gutenberg-reusable-block-interface.php
Gutenberg Reusable Block Editor Interface
function custom_add_interface_to_wp_block( $args, $post_type ) {
global $pagenow;
if ( 'wp_block' !== $post_type ) {
return $args;
}
$changed_args = array(
'show_ui' => true,
'show_in_menu' => true,
@apermo
apermo / category_mover.php
Created November 11, 2021 11:14
Bulk move and delete Categories in WordPress
<?php
if ( ! defined( 'PHP_SAPI' ) || PHP_SAPI !== 'cli' ) {
exit( 'You shall not pass' );
// echo '<pre>';
// set_time_limit( 0 );
}
$dir = $argv[1] ?? __DIR__;
// Load wp-config to make sure we can use WordPress.
@apermo
apermo / session-debugger.php
Created November 4, 2021 07:03
Simple WordPress User Session debugger
<html>
<head>
<style type="text/css">
textarea {
width: 100%;
height: 300px;
}
td {
border: 2px dashed grey;
padding: 1em;