Skip to content

Instantly share code, notes, and snippets.

# Delete all users with a role of "subscriber" from a WordPress database.
#
# Assumes the `wp_` table prefix
DELETE FROM wp_users WHERE ID IN ( SELECT user_id FROM wp_usermeta WHERE meta_key = 'wp_capabilities' AND meta_value LIKE '%subscriber%' );
DELETE FROM wp_usermeta WHERE user_id IN ( SELECT user_id FROM wp_usermeta WHERE meta_key = 'wp_capabilities' AND meta_value LIKE '%subscriber%' );
@philipjohn
philipjohn / watch_sync.sh
Last active May 6, 2025 09:57
Watch the current folder for changes and sync them to somewhere
# USAGE: watch_sync [destination_folder]
# Watch and sync a folder
watch_sync() {
# The first and only argument is the folder to sync to.
TO=$(echo "$1" | sed 's/\/$//')
# We assume the current folder is the one to sync from.
FROM=$(pwd)
@philipjohn
philipjohn / core-post-template.js
Created May 19, 2025 09:47
Attempting to override the core/query and core/post-template WordPress blocks
/**
* WordPress dependencies
*/
import { unregisterBlockVariation, registerBlockVariation } from '@wordpress/blocks'
import { addFilter } from '@wordpress/hooks';
import { registerPlugin } from '@wordpress/plugins';
import { select, subscribe } from '@wordpress/data';
/**
* Internal dependencies
@philipjohn
philipjohn / .wp-env.json
Created June 6, 2025 08:31
RawHTML adds a wrapper div when it shouldn't
{
"plugins": [ "." ],
"themes": [ "WordPress/twentytwentyfive" ]
}
#!/bin/bash
# iterate-by-date.sh - A template script for looping through days/months/years and running a command that takes
# before and after arguments.
#
# Usage: ./iterate-by-date.sh [iterate_by] [start_date] [end_date]
#
# Options:
# - iterate_by: The granularity of the operation - day, month or year (default: day).
# - start_date: The start date for the operation in YYYY-MM-DD format (default: 30 days ago).