Skip to content

Instantly share code, notes, and snippets.

View rmpel's full-sized avatar

Remon Pel rmpel

View GitHub Profile
@rmpel
rmpel / build.sh
Last active March 21, 2023 11:19
Universal build script for themes/plugins - WORK IN PROGRESS
#!/usr/bin/env bash
# Usage: /path/to/build.sh target-environment-using-a-pipelines-variable
# Example: /path/to/build.sh production
# Expected behaviour; in production, build for production, for all else build uncompressed.
# For local (argo; NO environment given, or local specified) buld in debug mode.
### CONFIGURATION
NODE_VER=14
BUILD_TASK_PROD=production
BUILD_TASK_LOCAL=dev
@rmpel
rmpel / karabiner.json
Created March 16, 2023 22:20
My custom Karabiner map; swap ` and § for consistency with ANSI keyboards, disable CAPS unless used with Left CMD
{
"global": {
"ask_for_confirmation_before_quitting": true,
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false,
"unsafe_ui": false
},
"profiles": [
{
@rmpel
rmpel / widget-context-menu-widget.php
Created January 12, 2023 07:51
WordPress + Widget Context -> For use with a widget with a menu, to show the widget only on pages in that menu.
<?php
add_filter( 'widget_contexts', function ( $contexts ) {
$contexts['menu_content'] = [
'label' => 'Menu-widget content',
'description' => 'Show only on pages that have its url/page/post listed in a menu',
'weight' => 11,
];
return $contexts;
}, 10, 2 );
@rmpel
rmpel / .htaccess
Last active March 13, 2023 09:27
Fast image 404 in WordPress
# WordPress will serve a rich 404 page for missing images, in case of lots of images, this will put
# heavy load on the server and the 404 messages cannot be shown anyways
# So just send a light-weight Apache 404 message
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(jpg|jpeg|png|gif|svg)$ - [R=404,NC,L]
# Alternative version; send a 410 Gone, which is even faster.
@rmpel
rmpel / .editorconfig
Last active February 18, 2025 11:55
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 / .htaccess
Last active April 25, 2025 06:08
Redirect htaccess with Let's Encrypt bypass
RewriteEngine On
RewriteRule ^.well-known - [S=1]
RewriteRule ^ https://newdomain.com%{REQUEST_URI} [QSA,L,NC,R=307]
# use code 307 for "marketing" domains; redirects that will stay for quite a while.
# use code 308 in case the domain is deprecated and will be removed.
@rmpel
rmpel / wp_rewrite_rules.log
Created January 4, 2022 09:53 — forked from thenbrent/wp_rewrite_rules.log
Default WordPress Rewrite Rules
[rules] => Array (
[category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2]
[category/(.+?)/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2]
[category/(.+?)/page/?([0-9]{1,})/?$] => index.php?category_name=$matches[1]&paged=$matches[2]
[category/(.+?)/?$] => index.php?category_name=$matches[1]
[tag/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?tag=$matches[1]&feed=$matches[2]
[tag/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?tag=$matches[1]&feed=$matches[2]
[tag/([^/]+)/page/?([0-9]{1,})/?$] => index.php?tag=$matches[1]&paged=$matches[2]
[tag/([^/]+)/?$] => index.php?tag=$matches[1]
[type/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?post_format=$matches[1]&feed=$matches[2]
@rmpel
rmpel / mu-plugin-backfill-missing-uploads.php
Created October 30, 2021 07:28
backfill missing wordpress uploads from a live website to a development copy
<?php
// Backfill missing uploads
// build your dev copy using plugins, theme and database
// don't download all uploads
// access an image on it, for example /wp-content/uploads/2021/10/some-image.png
// (of course, just loading a page with images on it will do)
// you will get 404s on all images
// place this file in mu-plugins folder
// try to access the url/page again
@rmpel
rmpel / crawl.php
Created March 10, 2021 09:37
File/Folder crawler; list all files and folders in a CSV file
<?php
/** QUICK AND VERY DIRTY */
header('Content-Type: text/plain'); header('Content-Disposition: attachment; filename=crawl.csv');
?>
type,path,timestamp,date
<?php
___T(__DIR__);
function ___T($s) {
$l = array_merge( glob($s .'/.*'), glob($s .'/*') );
@rmpel
rmpel / .htaccess
Created January 22, 2021 13:34
multi-domain Access-Control-Allow-Origin .htaccess
<IfModule mod_headers.c>
SetEnvIf Origin "http(s)?://(www\.)?((subdomain.)?yourdomain.nl)$" AccessControlAllowOrigin=$0
Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
Header merge Vary Origin
</IfModule>