Skip to content

Instantly share code, notes, and snippets.

View soderlind's full-sized avatar

Per Søderlind soderlind

View GitHub Profile
soderlind / docker-compose.yml
Last active May 27, 2024 17:10
Buggregator for WordPress local development
condition: service_healthy
soderlind / class-google-maps-oembed-provider.php
Last active April 29, 2024 11:44
WordPress Google Maps oEmbed Provider using the Google Maps Embed API
* Create a Google Maps oEmbed Provider using the Google Maps Embed API
* @see
* @link
* @since 1.0.0
* @package Google_Maps_oEmbed_Provider
class DSS_oEmbed_Add_Provider {
soderlind / dropzonejs-wp-rest-api.js
Last active March 27, 2024 19:38
DropzoneJS & WordPress REST API
Uploading images is a two step process (from
POST the data to /wp/v2/media - this can either be as the request body, or in multipart format. This will upload the file, and give you a 201 Created response with a Location header. This header points to the post object for the attachment that has just been created.
PUT the post data to the endpoint returned in the Location header (which will look something like /wp/v2/media/{id}).
I do step 2 (PUT), if POST is a success, in myDropzone.on("success", function(file, response){}
// dropzoneWordpressRestApiForm is the configuration for the element that has an id attribute
soderlind / Install.txt
Last active March 5, 2024 20:30
macOS DoH! (DNS over HTTPS) using cloudflared
1) Install cloudflared using homebrew:
brew install cloudflare/cloudflare/cloudflared
2) Create /usr/local/etc/cloudflared/config.yaml, with the following content
proxy-dns: true
soderlind / a_faster_load_textdomain.php
Created October 26, 2015 22:08
A faster load_textdomain for WordPress
Plugin Name: A faster load_textdomain
Version: 0.0.1
Description: While we're wating for
Author: Per Soderlind
Author URI:
Plugin URI:
License: GPL
soderlind /
Last active January 23, 2024 16:06
WordPress Playground blueprint for a block plugin.

Live Preview for Jobbnorge Block

Plugin Previews are now available for opt-in, I've added a live preview to my block plugin

On, there are two things required for a plugin preview button to appear to all users:

  1. A valid blueprint.json file must be provided in the plugins assets/blueprints sub-directory.
  2. The plugin preview must be set to “public” from the plugin’s Advanced view by a committer.

Read the blueprint documentation for more information.

soderlind /
Last active December 19, 2023 03:21
Me talking with Copilot Chat

@soderlind: I need a bash script that read a list of domains from disk and use az cli to remove the domains from azure front door. I have several azure front doors in the resource group.

GitHub Copilot: Here's a step-by-step plan for the bash script:

  1. Define the script shebang to specify that the script should be run using bash.
  2. Read the file line by line using a while loop.
  3. Inside the loop, use the az network front-door frontend-endpoint delete command to delete the domain from each Azure Front Door in the resource group.
  4. The command requires the names of the resource group, the Front Door, and the endpoint (domain). You'll need to loop over each Front Door in the resource group.
  5. To get the list of Front Doors, use the az network front-door list command with the resource group name.
  6. Parse the output of the list command to extract the names of the Front Doors.
soderlind / hardcode-number-of-items.php
Created August 28, 2023 08:27
WordPress Admin: Hardcode max number of items per page.
* name
* @package Soderlind\MuPlugins\HardcodeNumberOfItems
* @author Per Soderlind
* @copyright 2021 Per Soderlind
* @license GPL-2.0+
soderlind / mb_similar_text.php
Last active June 27, 2023 03:28
Multibyte Similar Text for PHP, mb_similar_text()
* solves the problem at, not that I know Arabic, but Norwegian also has multibyte charachters: æøåÆØÅ
function mb_split_str($str) {
preg_match_all("/./u", $str, $arr);
return $arr[0];
soderlind / plausible-2f-fix.php
Last active May 25, 2023 09:53
Fix for Plausible Analytics %2f removal from shard link
* Plugin Name: Plausible 2f Fix
* Description: Fix for Plausible Analytics %2f removal from shard link.
* Plugin URI:
* License: GPL-2.0+
* License URI:
declare( strict_types = 1 );