Skip to content

Instantly share code, notes, and snippets.

View rmpel's full-sized avatar

Remon Pel rmpel

View GitHub Profile
@rmpel
rmpel / .editorconfig
Last active August 10, 2026 13:15
Editor Config for WordPress coding standards
# https://gist.github.com/rmpel/a54ffc349ecdba57c5dd7f33b81263dd
#
# This file is for unifying the coding style for different editors and IDEs
# Or at least; that is the plan. Currently FULLY supported IDEs are:
# - phpStorm
#
# Tried and failed;
# - VS Code (Supports .editorConfig, but does not support any extended rule-set)
#
# More information on the file format:
@rmpel
rmpel / lbl.sh
Last active August 8, 2026 17:12
Local Lightning - The unofficial CLI for the new Local 5.x and 6.x version - this is work in progress.
#!/usr/bin/env bash
#########
## Configuration:
## Set your primary and secondary development paths.
## YOU CANNOT HAVE SPACES IN THE PRIMARY PATH - If you have, then most tooling here will fail because of limitations in macOS Terminal.
## AND NO - This tool is not built to use a different terminal.
##
PRIMARY_LOCATION=~/Development
SECONDARY_LOCATION=/Volumes/Macintosh\ SD/Development
@rmpel
rmpel / zsh-auto-localwp.sh
Last active July 7, 2026 07:02
zsh automatic LocalWP context switcher when navigating folders of projects on MacOS
# this is a zsh script to automatically switch to the localwp shell when you enter a
# directory that contains a LocalWP website installation
# it is designed to trigger on any directory deeper or exactly the app/ folder of a localwp site.
# this code is FAR FROM perfect, but it works! Feel free to suggest/improve/etc
#
# this file is to be sourced in your .zshrc .
#
# Suggested install method:
# cd ~ ; mkdir -p .zsh ; git clone https://gist.github.com/f5c220b5e49baf0df4f5bbf5b7e76fdf.git .zsh/zsh-auto-localwp
# echo "source ~/.zsh/zsh-auto-localwp/zsh-auto-localwp.sh" >> ~/.zshrc
@rmpel
rmpel / downgrade-kicad-to-v9.php
Created March 22, 2026 07:19
downgrade kicad files to V9
<?php
// usage: php downgrade-kicad-to-v9.php -in path/to/schematic/or/pcb/file -out path/to/schematic/or/pcb/file/new-version
// This is in a "Works on nmy machine" state
// Use at own risk
$in = 'php://stdin';
$out = 'php://stdout';
$dryRun = false;
@rmpel
rmpel / validate-acf-php-files.php.sh
Created October 9, 2025 12:51
ACF-PHP File validator
#!/usr/bin/env php
<?php
function acf_add_local_field_group($data) {
foreach ( $data as $array_key => $array_value ) {
if ( is_array($array_value) ) {
acf_add_local_field_group( $array_value );
}
else {
if ( 'key' === $array_key && false === strpos( $array_value, 'layout_' ) ) {
@rmpel
rmpel / class-uploads.php
Last active September 18, 2025 23:32
The definitive way to add more filetypes to WordPress Media.
<?php
/**
* Filters that assist in uploading additional filetypes.
*
* @package Your_Package
* @subpackage Your_Package/Includes
*/
namespace Your_Package\Includes;
@rmpel
rmpel / .htaccess
Created September 18, 2025 09:01
WordPress compatible Content-Security-Policy/Content-Type-Options rules Apache 2.4+
# BEGIN WP Security
<IfModule mod_headers.c>
#set header for all
Header set Content-Security-Policy "default-src 'self' *.googlesyndication.com vimeo.com *.vimeo.com *.vimeocdn.com *.amazonaws.com *.google-analytics.com *.yoast.com yoast.com *.diffuse.tools; connect-src 'self' *.googlesyndication.com google.com *.google.com vimeo.com *.vimeo.com *.linkedin.com *.vimeocdn.com *.amazonaws.com *.google-analytics.com *.yoast.com yoast.com *.diffuse.tools; frame-src 'self' vimeo.com *.vimeo.com *.vimeocdn.com youtube.com *.youtube.com *.googletagmanager.com *.youtube-nocookie.com *.google.com *.doubleclick.net; script-src 'unsafe-inline' 'unsafe-eval' 'self' *.yoast.com yoast.com *.gstatic.com google.com *.google.com googletagmanager.com *.googletagmanager.com *.googleapis.com google-analytics.com *.google-analytics.com *.googlesyndication.com code.diffuse.nl adservice.google.nl adservice.google.com *.googleadservices.com browser-update.org *.facebook.net snap.licdn.com *.doubleclick.net; style-src 'unsafe
#!/usr/bin/env bash
# usage; cron entry to run this script every minute.
# the script will take 3 snaps at most, at run, run+20, run+40. Next minute is a new iteration.
# script construction allows changes between snaps, as the script runs itself 3x.
cd "$(dirname "$0")"
# Set default values for environment variables
: "${HTTP_URL:=https://webcam.connect.prusa3d.com/c/snapshot}"
: "${DELAY_SECONDS:=20}"
@rmpel
rmpel / mu-plugin-mdms-prevent-password-rehashing.php
Created July 18, 2025 06:59
Prevent forced re-login on Multi-Domain Multisite in WordPress 6.8 and up
<?php
add_filter( 'password_needs_rehash', 'mu_plugin_mdms_prevent_password_rehashing', 11, 3 );
/**
* Maybe prevent password rehashing, limit rehashing to a set-up time-slot.
* This filter is only effective in WordPress 6.8 and up, and when not overriding the $wp_hasher global variable.
* This is to prevent the password rehashing from happening too often, which WILL cause users forced being logged in every time they switch to a different domain subsite.
*
* @param bool $needs_rehash Whether the password needs rehashing, defaults to true.
* While this could also be false; the way WordPress is set-up,
@rmpel
rmpel / i18n.sh
Last active July 10, 2025 06:26
Universal po mo php file script for WordPress plugins
#!/usr/bin/env bash
# https://gist.github.com/rmpel/969508c652de6a9bf33e4ac0f89996a4
cd "$(dirname "$0")" || exit 1
SCRIPTDIR="$(pwd)"
SCRIPTFILE="$(basename "$0")"
SCRIPTPATH="$(realpath "$SCRIPTDIR"/"$SCRIPTFILE")"